From 7fcce1516d40ef0e5a828b1b3b8e0a4ee23f69f1 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 27 Sep 2024 13:33:47 +1000 Subject: [PATCH 1/5] Minor refactor to `Submissions.EditModel.OnPost` and add a message for if client-side validation is skipped --- TASVideos/Pages/Submissions/Edit.cshtml.cs | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/TASVideos/Pages/Submissions/Edit.cshtml.cs b/TASVideos/Pages/Submissions/Edit.cshtml.cs index de3bc30ca..0deb7636b 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml.cs +++ b/TASVideos/Pages/Submissions/Edit.cshtml.cs @@ -21,6 +21,8 @@ public class EditModel( ITopicWatcher topicWatcher) : BasePageModel { + internal const string ErrMsgMayNotReplaceFile = "You don't have permission to replace movie files directly; upload a userfile and ask a staff member to swap it out"; + private const string FileFieldName = $"{nameof(Submission)}.{nameof(SubmissionEdit.ReplaceMovieFile)}"; [FromRoute] @@ -107,22 +109,26 @@ public async Task OnGet() public async Task OnPost() { - if (User.Has(PermissionTo.ReplaceSubmissionMovieFile) && Submission.ReplaceMovieFile is not null) + if (Submission.ReplaceMovieFile is not null) { - if (!Submission.ReplaceMovieFile.IsZip()) + if (User.Has(PermissionTo.ReplaceSubmissionMovieFile)) { - ModelState.AddModelError(FileFieldName, "Not a valid .zip file"); - } + if (!Submission.ReplaceMovieFile.IsZip()) + { + ModelState.AddModelError(FileFieldName, "Not a valid .zip file"); + } - if (!User.Has(PermissionTo.OverrideSubmissionConstraints) && !Submission.ReplaceMovieFile.LessThanMovieSizeLimit()) + if (!User.Has(PermissionTo.OverrideSubmissionConstraints) && !Submission.ReplaceMovieFile.LessThanMovieSizeLimit()) + { + ModelState.AddModelError(FileFieldName, ".zip is too big, are you sure this is a valid movie file?"); + } + } + else { - ModelState.AddModelError(FileFieldName, ".zip is too big, are you sure this is a valid movie file?"); + Submission.ReplaceMovieFile = null; + ModelState.AddModelError(FileFieldName, ErrMsgMayNotReplaceFile); } } - else if (!User.Has(PermissionTo.ReplaceSubmissionMovieFile)) - { - Submission.ReplaceMovieFile = null; - } // TODO: this has to be done anytime a string-list TagHelper is used, can we make this automatic with model binders? Submission.Authors = Submission.Authors.RemoveEmpty(); From ebbf4de9e5fad100a678a519991fa5e42a87fb5b Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 27 Sep 2024 14:10:50 +1000 Subject: [PATCH 2/5] Improve UX for users looking to replace the movie files in their submissions --- TASVideos/Pages/Submissions/Edit.cshtml | 24 +++++++++++++++++----- TASVideos/Pages/Submissions/Edit.cshtml.cs | 4 +++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/TASVideos/Pages/Submissions/Edit.cshtml b/TASVideos/Pages/Submissions/Edit.cshtml index 0e17618d6..c0e99f0ab 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml +++ b/TASVideos/Pages/Submissions/Edit.cshtml @@ -14,12 +14,26 @@ - +
- - -
Your movie packed in a ZIP file (max size: 150k)
- + @if (ViewContext.HttpContext.User.Has(PermissionTo.ReplaceSubmissionMovieFile)) + { + + +
Your movie packed in a ZIP file (max size: 150k)
+ + } + else + { + + +
+ @EditModel.ErrMsgMayNotReplaceFile + (go to upload form; + go to forum thread) +
+ }
diff --git a/TASVideos/Pages/Submissions/Edit.cshtml.cs b/TASVideos/Pages/Submissions/Edit.cshtml.cs index 0deb7636b..8e0f62699 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml.cs +++ b/TASVideos/Pages/Submissions/Edit.cshtml.cs @@ -62,7 +62,8 @@ public async Task OnGet() Publisher = s.Publisher != null ? s.Publisher.UserName : "", IntendedPublicationClass = s.IntendedClassId, RejectionReason = s.RejectionReasonId, - ExternalAuthors = s.AdditionalAuthors + ExternalAuthors = s.AdditionalAuthors, + TopicId = s.TopicId, }) .SingleOrDefaultAsync(); @@ -503,5 +504,6 @@ public class SubmissionEdit public string? Judge { get; init; } public string? Publisher { get; init; } public string? ExternalAuthors { get; init; } + public int? TopicId { get; init; } } } From 4b2280e170616e10be027c2e0f3bf157b8f9cbc1 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 1 Oct 2024 11:24:12 +1000 Subject: [PATCH 3/5] Revert "Improve UX for users looking to replace the movie files in their submissions" This reverts commit 070b9ff8b5c78929e257bb9b8e9888a95e7f1c2b. --- TASVideos/Pages/Submissions/Edit.cshtml | 24 +++++----------------- TASVideos/Pages/Submissions/Edit.cshtml.cs | 4 +--- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/TASVideos/Pages/Submissions/Edit.cshtml b/TASVideos/Pages/Submissions/Edit.cshtml index c0e99f0ab..0e17618d6 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml +++ b/TASVideos/Pages/Submissions/Edit.cshtml @@ -14,26 +14,12 @@ - +
- @if (ViewContext.HttpContext.User.Has(PermissionTo.ReplaceSubmissionMovieFile)) - { - - -
Your movie packed in a ZIP file (max size: 150k)
- - } - else - { - - -
- @EditModel.ErrMsgMayNotReplaceFile - (go to upload form; - go to forum thread) -
- } + + +
Your movie packed in a ZIP file (max size: 150k)
+
diff --git a/TASVideos/Pages/Submissions/Edit.cshtml.cs b/TASVideos/Pages/Submissions/Edit.cshtml.cs index 8e0f62699..0deb7636b 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml.cs +++ b/TASVideos/Pages/Submissions/Edit.cshtml.cs @@ -62,8 +62,7 @@ public async Task OnGet() Publisher = s.Publisher != null ? s.Publisher.UserName : "", IntendedPublicationClass = s.IntendedClassId, RejectionReason = s.RejectionReasonId, - ExternalAuthors = s.AdditionalAuthors, - TopicId = s.TopicId, + ExternalAuthors = s.AdditionalAuthors }) .SingleOrDefaultAsync(); @@ -504,6 +503,5 @@ public class SubmissionEdit public string? Judge { get; init; } public string? Publisher { get; init; } public string? ExternalAuthors { get; init; } - public int? TopicId { get; init; } } } From 1c8faf3a53aa3d90b054b5a39878a64eba716fa8 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 1 Oct 2024 11:27:03 +1000 Subject: [PATCH 4/5] Revert "Minor refactor to `Submissions.EditModel.OnPost`" This reverts commit f8db0867564a6ade203943b395b0a414ed1c4492. --- TASVideos/Pages/Submissions/Edit.cshtml.cs | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/TASVideos/Pages/Submissions/Edit.cshtml.cs b/TASVideos/Pages/Submissions/Edit.cshtml.cs index 0deb7636b..de3bc30ca 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml.cs +++ b/TASVideos/Pages/Submissions/Edit.cshtml.cs @@ -21,8 +21,6 @@ public class EditModel( ITopicWatcher topicWatcher) : BasePageModel { - internal const string ErrMsgMayNotReplaceFile = "You don't have permission to replace movie files directly; upload a userfile and ask a staff member to swap it out"; - private const string FileFieldName = $"{nameof(Submission)}.{nameof(SubmissionEdit.ReplaceMovieFile)}"; [FromRoute] @@ -109,26 +107,22 @@ public async Task OnGet() public async Task OnPost() { - if (Submission.ReplaceMovieFile is not null) + if (User.Has(PermissionTo.ReplaceSubmissionMovieFile) && Submission.ReplaceMovieFile is not null) { - if (User.Has(PermissionTo.ReplaceSubmissionMovieFile)) + if (!Submission.ReplaceMovieFile.IsZip()) { - if (!Submission.ReplaceMovieFile.IsZip()) - { - ModelState.AddModelError(FileFieldName, "Not a valid .zip file"); - } - - if (!User.Has(PermissionTo.OverrideSubmissionConstraints) && !Submission.ReplaceMovieFile.LessThanMovieSizeLimit()) - { - ModelState.AddModelError(FileFieldName, ".zip is too big, are you sure this is a valid movie file?"); - } + ModelState.AddModelError(FileFieldName, "Not a valid .zip file"); } - else + + if (!User.Has(PermissionTo.OverrideSubmissionConstraints) && !Submission.ReplaceMovieFile.LessThanMovieSizeLimit()) { - Submission.ReplaceMovieFile = null; - ModelState.AddModelError(FileFieldName, ErrMsgMayNotReplaceFile); + ModelState.AddModelError(FileFieldName, ".zip is too big, are you sure this is a valid movie file?"); } } + else if (!User.Has(PermissionTo.ReplaceSubmissionMovieFile)) + { + Submission.ReplaceMovieFile = null; + } // TODO: this has to be done anytime a string-list TagHelper is used, can we make this automatic with model binders? Submission.Authors = Submission.Authors.RemoveEmpty(); From 47cd251d7b7a9bf9e67dfd039bc2752b25cfd689 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Tue, 1 Oct 2024 11:25:57 +1000 Subject: [PATCH 5/5] Add a notice (system page) to the submission edit form --- TASVideos/Constants.cs | 1 + TASVideos/Pages/Submissions/Edit.cshtml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/TASVideos/Constants.cs b/TASVideos/Constants.cs index 9e26e77a0..d3679db58 100644 --- a/TASVideos/Constants.cs +++ b/TASVideos/Constants.cs @@ -19,6 +19,7 @@ public static class SystemWiki public const string ActivitySummary = "System/ActivitySummary"; public const string AvatarRequirements = "System/AvatarRequirements"; public const string ClassEditingHelp = "System/ClassEditingHelp"; + public const string EditMovieHeader = "System/EditMovieHeader"; public const string EmailConfirmationSentMessage = "System/EmailConfirmationSentMessage"; public const string Error = "System/Error"; public const string FilesEditingHelp = "System/FilesEditingHelp"; diff --git a/TASVideos/Pages/Submissions/Edit.cshtml b/TASVideos/Pages/Submissions/Edit.cshtml index 0e17618d6..d974f0116 100644 --- a/TASVideos/Pages/Submissions/Edit.cshtml +++ b/TASVideos/Pages/Submissions/Edit.cshtml @@ -5,6 +5,9 @@ var canEditPublicationClass = User.Has(PermissionTo.JudgeSubmissions) && Model.AvailableStatuses.Any(s => s == SubmissionStatus.Accepted); } + + @await Html.RenderWiki(SystemWiki.EditMovieHeader) + Delete