Add ability for cases to perform actions

This commit is contained in:
jvyden 2022-08-05 20:32:35 -04:00
commit 4718970f6b
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
10 changed files with 169 additions and 41 deletions

View file

@ -27,26 +27,11 @@ public class ModerationCaseController : ControllerBase
@case.DismissedAt = DateTime.Now;
@case.DismisserId = user.UserId;
@case.Processed = false;
await this.database.SaveChangesAsync();
return this.Ok();
}
[HttpGet("undoDismiss")]
public async Task<IActionResult> UndoDismissCase([FromRoute] int id)
{
User? user = this.database.UserFromWebRequest(this.Request);
if (user == null || !user.IsModerator) return this.StatusCode(403, "");
ModerationCase? @case = await this.database.Cases.FirstOrDefaultAsync(c => c.CaseId == id);
if (@case == null) return this.NotFound();
@case.DismissedAt = null;
@case.DismisserId = null;
await this.database.SaveChangesAsync();
return this.Ok();
}
}

View file

@ -35,7 +35,7 @@ public class CasePage : BaseLayout
.Include(c => c.Dismisser)
.OrderByDescending(c => c.CaseId)
.ToListAsync();
this.CaseCount = await this.Database.Cases.CountAsync(c => c.Description.Contains(this.SearchValue));
this.CaseCount = await this.Database.Cases.CountAsync(c => c.Reason.Contains(this.SearchValue));
this.PageNumber = pageNumber;
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.CaseCount / ServerStatics.PageSize));

View file

@ -23,7 +23,7 @@ public class NewCasePage : BaseLayout
ModerationCase @case = new()
{
Type = (CaseType)type,
Description = description,
Reason = description,
ExpiresAt = expires,
CreatedAt = DateTime.Now,
CreatorId = 1,

View file

@ -49,14 +49,24 @@
<p><strong>Affected user:</strong> <a href="/user/@user.UserId">@user.Username</a></p>
}
@if (!string.IsNullOrWhiteSpace(Model.Description))
<h3>Reason</h3>
@if (!string.IsNullOrWhiteSpace(Model.Reason))
{
<h3>Description</h3>
<pre>@Model.Description</pre>
<pre>@Model.Reason</pre>
}
else
{
<b>No description was provided.</b>
<pre><b>No reason was provided.</b></pre>
}
<h3>Moderator Notes</h3>
@if (!string.IsNullOrWhiteSpace(Model.ModeratorNotes))
{
<pre>@Model.ModeratorNotes</pre>
}
else
{
<pre><b>No notes were provided.</b></pre>
}
@if (!Model.Dismissed)
@ -66,11 +76,4 @@
<span>Dismiss</span>
</a>
}
else
{
<a class="ui yellow small button" href="/moderation/case/@Model.CaseId/undoDismiss">
<i class="undo icon"></i>
<span>Undo dismission</span> @* TODO: fix english here lol wtf is this *@
</a>
}
</div>