Allow admin to upload and manage program videos with optional PDF handouts#473
Conversation
Co-authored-by: JoeProgrammer88 <7156063+JoeProgrammer88@users.noreply.github.com>
Co-authored-by: JoeProgrammer88 <7156063+JoeProgrammer88@users.noreply.github.com>
JoeProgrammer88
left a comment
There was a problem hiding this comment.
If the user enters a full YouTube video URL, we should extract the id for them. This will be better for our non-tech savvy users
| return View(); | ||
| } | ||
|
|
||
| [Authorize(Roles = IdentityHelper.Admin)] |
There was a problem hiding this comment.
Instead of authorizing Admin on these actions, let's do it at the controller level but then use AllowAnonymous on the Index action since it doesn't need authorization
There was a problem hiding this comment.
Done in ef0abcb. [Authorize(Roles = IdentityHelper.Admin)] is now on the controller class, and [AllowAnonymous] is applied to the Index action. All per-action [Authorize] attributes have been removed.
| <h1>@video.Title</h1> | ||
| </div> | ||
| <div class="player" id="player-@video.ProgramVideoId"></div> | ||
| @if (!string.IsNullOrEmpty(video.PdfLocation)) |
There was a problem hiding this comment.
Let's style the PDF's like we do on the Focus Newsletters view for consistency
There was a problem hiding this comment.
Done in ef0abcb. PDF attachments now render as Bootstrap cards matching the Focus Newsletters style — red PDF icon, filename as the card title, "PDF Handout" subtitle, and a full-width "Download PDF" button.
… URL extraction Co-authored-by: JoeProgrammer88 <7156063+JoeProgrammer88@users.noreply.github.com>
Done in ef0abcb. Both the Create and Edit video forms now auto-extract the video ID when the user pastes a full YouTube URL (supports |
JoeProgrammer88
left a comment
There was a problem hiding this comment.
It looks like the JS script for extractYouTubeId is duplicated on the CreateVideo and EditVideo pages. Let's move that into a .js file and just reference it twice
Co-authored-by: JoeProgrammer88 <7156063+JoeProgrammer88@users.noreply.github.com>
Done in 4d47f8a. The shared logic is now in |
JoeProgrammer88
left a comment
There was a problem hiding this comment.
On CreateVideo and EditVideo there is also a checkFileSize function that is duplicated. Let's name the youtube-id-extractor.js something more generic and move the checkFileSize() function to that file as well
…heckFileSize Co-authored-by: JoeProgrammer88 <7156063+JoeProgrammer88@users.noreply.github.com>
Done in 807481a. |
Enables admins to manage program videos (YouTube-hosted) via a full CRUD interface, replacing hardcoded video IDs in the view. Admins can also attach optional PDF handouts to each video, stored in Azure Blob Storage.
Data Layer
ProgramVideomodel:Title,YouTubeVideoId, required;PdfLocation,PdfName, nullableProgramVideoDB: static CRUD helpers (AddAsync,GetAllAsync,GetVideoAsync,UpdateAsync,DeleteAsync)ProgramVideostableController
ProgramVideosControlleris authorized at the class level with[Authorize(Roles = IdentityHelper.Admin)]; the publicIndex()action uses[AllowAnonymous]to remain accessible to all usersViews
Index.cshtmlrenders YouTube players and PDF attachments dynamically from DB (replaces hardcoded player IDs/video IDs); PDF handouts are styled as cards matching the Focus Newsletters page (Bootstrap icon, filename, and "Download PDF" button)ManageVideos,CreateVideo,EditVideo,DeleteVideoCreateVideoandEditVideoforms auto-extract the YouTube video ID when a full YouTube URL is pasted (supportsyoutube.com/watch?v=,youtu.be/,/embed/, and/v/formats); extraction logic and PDF file-size validation live in the sharedwwwroot/js/program-videos.jsfile, referenced by both viewsTests
ProgramVideoDBTestscovers all CRUD operationsCopilot Summary
This PR adds a database-driven program video management system. Previously, videos were hardcoded into the Razor view. Admins can now add, edit, and delete YouTube videos with optional PDF attachments through a standard CRUD interface consistent with other admin features (newsletters, staff, board members). Authorization is enforced at the controller level, the public video listing page is open to all users, PDF handouts match the Focus Newsletters card style for consistency, and admin forms automatically extract a YouTube video ID from a pasted full URL for ease of use. Shared client-side logic (
extractYouTubeIdandcheckFileSize) is consolidated inwwwroot/js/program-videos.jsand referenced by both the Create and Edit views, eliminating duplication.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.