mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 07:58:40 +00:00
Add ability for cases to perform actions
This commit is contained in:
parent
bfaef6ba4c
commit
4718970f6b
10 changed files with 169 additions and 41 deletions
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue