From 7ba50e26f5048ef0dd59d90edb4d97360c6240e3 Mon Sep 17 00:00:00 2001 From: jvyden Date: Wed, 27 Jul 2022 17:53:20 -0400 Subject: [PATCH] Add mod notes to ban cases, improve case display --- .../Admin/ModerationSlotController.cs | 1 + .../Pages/Admin/ModerationBanUserPage.cshtml | 9 +++++++-- .../Pages/Admin/ModerationBanUserPage.cshtml.cs | 4 ++-- .../Pages/Partials/ModerationCasePartial.cshtml | 16 +++++++++++----- .../Pages/UserPage.cshtml | 14 +++++++------- .../Administration/ModerationCase.cs | 4 ++-- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs b/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs index 14eb49d2..7cfbba56 100644 --- a/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs +++ b/ProjectLighthouse.Servers.Website/Controllers/Admin/ModerationSlotController.cs @@ -59,6 +59,7 @@ public class ModerationSlotController : ControllerBase if (slot == null) return this.Ok(); await this.database.RemoveSlot(slot); + this.database.Cases.Add(ModerationCase.NewLevelDeletionCase(user.UserId, slot.SlotId)); return this.Ok(); } diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml index 71e882af..8777d36b 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml @@ -14,12 +14,17 @@
-

+

+ +
+ + +


-

+



\ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml.cs b/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml.cs index 80ef016c..8f5af0e2 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml.cs +++ b/ProjectLighthouse.Servers.Website/Pages/Admin/ModerationBanUserPage.cshtml.cs @@ -26,7 +26,7 @@ public class ModeratorBanUserPage : BaseLayout return this.Page(); } - public async Task OnPost([FromRoute] int id, string reason, DateTime caseExpires) + public async Task OnPost([FromRoute] int id, string reason, string modNotes, DateTime caseExpires) { User? user = this.Database.UserFromWebRequest(this.Request); if (user == null || !user.IsModerator) return this.NotFound(); @@ -44,7 +44,7 @@ public class ModeratorBanUserPage : BaseLayout this.Database.WebTokens.RemoveRange(this.Database.WebTokens.Where(t => t.UserId == this.TargetedUser.UserId)); // generate & add moderation case - this.Database.Add(ModerationCase.NewBanCase(user.UserId, this.TargetedUser.UserId, reason, caseExpires)); + this.Database.Add(ModerationCase.NewBanCase(user.UserId, this.TargetedUser.UserId, reason, modNotes, caseExpires)); await this.Database.SaveChangesAsync(); return this.Redirect($"/user/{this.TargetedUser.UserId}"); diff --git a/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml b/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml index b9bc362e..c2248f48 100644 --- a/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/Partials/ModerationCasePartial.cshtml @@ -18,16 +18,12 @@ This case expired on @Model.CaseExpires!.Value.ToString("MM/dd/yyyy @ h:mm tt"). } - + Case created by @Model.CaseCreator.Username on @Model.CaseCreated.ToString("MM/dd/yyyy @ h:mm tt")
- - Description: @Model.CaseDescription -
- @if (Model.CaseType.AffectsLevel()) { Slot slot = await Model.GetSlotAsync(database); @@ -38,4 +34,14 @@ User user = await Model.GetUserAsync(database);

Affected user: @user.Username

} + + @if (!string.IsNullOrWhiteSpace(Model.CaseDescription)) + { +

Description

+
@Model.CaseDescription
+ } + else + { + No description was provided. + } \ No newline at end of file diff --git a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml index 2f488bcc..3050ef8d 100644 --- a/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml +++ b/ProjectLighthouse.Servers.Website/Pages/UserPage.cshtml @@ -17,14 +17,14 @@ {

User is currently banned!

- @if (Model.User != null && Model.User.IsAdmin) + @if (Model.User != null && Model.User.IsModerator) { Reason: "@Model.ProfileUser.BannedReason"

Note: Only you and other admins may view the ban reason.

- + Unban User @@ -94,7 +94,7 @@

Recent Activity

-

Coming soon!

+

Coming soon?

@@ -118,10 +118,10 @@ @await Html.PartialAsync("Partials/CommentsPartial") -@if (Model.User != null && Model.User.IsAdmin) +@if (Model.User != null && Model.User.IsModerator) { -
-

Admin Options

+
+

Moderator Options

@if (!Model.ProfileUser.IsBanned) { @@ -135,7 +135,7 @@ }
- + Wipe user's earth decorations diff --git a/ProjectLighthouse/Administration/ModerationCase.cs b/ProjectLighthouse/Administration/ModerationCase.cs index d2714c8d..b5f205cb 100644 --- a/ProjectLighthouse/Administration/ModerationCase.cs +++ b/ProjectLighthouse/Administration/ModerationCase.cs @@ -68,11 +68,11 @@ public class ModerationCase #endregion #region User - public static ModerationCase NewBanCase(int caseCreator, int userId, string reason, DateTime caseExpires) + public static ModerationCase NewBanCase(int caseCreator, int userId, string reason, string modNotes, DateTime caseExpires) => new() { CaseType = CaseType.UserBan, - CaseDescription = $"Banned for reason '{reason}'", + CaseDescription = $"Banned for reason '{reason}'\nModeration notes: {modNotes}", CaseCreatorId = caseCreator, CaseCreated = DateTime.Now, CaseExpires = caseExpires,