mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-22 10:19:32 +00:00
Fix bug where users can't be deleted (#648)
* Add username to mod cases if user is deleted * Add timezone package to docker container * Remove extra space in migration sql statement * Changes from self-review
This commit is contained in:
parent
2c2f31ad38
commit
4559d26a54
15 changed files with 170 additions and 83 deletions
|
@ -21,8 +21,8 @@ public class NewCasePage : BaseLayout
|
|||
if (type == null) return this.BadRequest();
|
||||
if (affectedId == null) return this.BadRequest();
|
||||
|
||||
this.Type = (CaseType)type;
|
||||
this.AffectedId = (int)affectedId;
|
||||
this.Type = type.Value;
|
||||
this.AffectedId = affectedId.Value;
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
|
@ -38,19 +38,19 @@ public class NewCasePage : BaseLayout
|
|||
reason ??= string.Empty;
|
||||
modNotes ??= string.Empty;
|
||||
|
||||
// this is fucking ugly
|
||||
// if id is invalid then return bad request
|
||||
if (!(await ((CaseType)type).IsIdValid((int)affectedId, this.Database))) return this.BadRequest();
|
||||
if (!await type.Value.IsIdValid((int)affectedId, this.Database)) return this.BadRequest();
|
||||
|
||||
ModerationCase @case = new()
|
||||
{
|
||||
Type = (CaseType)type,
|
||||
Type = type.Value,
|
||||
Reason = reason,
|
||||
ModeratorNotes = modNotes,
|
||||
ExpiresAt = expires,
|
||||
CreatedAt = DateTime.Now,
|
||||
CreatorId = user.UserId,
|
||||
AffectedId = (int)affectedId,
|
||||
CreatorUsername = user.Username,
|
||||
AffectedId = affectedId.Value,
|
||||
};
|
||||
|
||||
this.Database.Cases.Add(@case);
|
||||
|
|
|
@ -21,24 +21,44 @@
|
|||
|
||||
@if (Model.Dismissed)
|
||||
{
|
||||
Debug.Assert(Model.Dismisser != null);
|
||||
Debug.Assert(Model.DismissedAt != null);
|
||||
|
||||
@if (Model.Dismisser != null)
|
||||
{
|
||||
<h3 class="ui @color header">
|
||||
This case was dismissed by <a href="/user/@Model.Dismisser.UserId">@Model.DismisserUsername</a> on @TimeZoneInfo.ConvertTime(Model.DismissedAt.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
|
||||
</h3>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h3 class="ui @color header">
|
||||
This case was dismissed by @Model.DismisserUsername on @TimeZoneInfo.ConvertTime(Model.DismissedAt.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
|
||||
</h3>
|
||||
}
|
||||
|
||||
<h3 class="ui @color header">
|
||||
This case was dismissed by <a href="/user/@Model.Dismisser.UserId">@Model.Dismisser.Username</a> on @TimeZoneInfo.ConvertTime(Model.DismissedAt.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
|
||||
</h3>
|
||||
}
|
||||
else if (Model.Expired && Model.ExpiresAt != null)
|
||||
else if (Model.Expired)
|
||||
{
|
||||
<h3 class="ui @color header">
|
||||
This case expired on @TimeZoneInfo.ConvertTime(Model.ExpiresAt.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
|
||||
This case expired on @TimeZoneInfo.ConvertTime(Model.ExpiresAt!.Value, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt").
|
||||
</h3>
|
||||
}
|
||||
|
||||
@if (Model.Creator != null && Model.Creator.Username.Length != 0)
|
||||
{
|
||||
<span>
|
||||
Case created by <a href="/user/@Model.Creator.UserId">@Model.Creator.Username</a>
|
||||
on @TimeZoneInfo.ConvertTime(Model.CreatedAt, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")
|
||||
</span><br>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>
|
||||
Case created by @Model.CreatorUsername
|
||||
on @TimeZoneInfo.ConvertTime(Model.CreatedAt, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")
|
||||
</span><br>
|
||||
}
|
||||
|
||||
<span>
|
||||
Case created by <a href="/user/@Model.Creator!.UserId">@Model.Creator.Username</a>
|
||||
on @TimeZoneInfo.ConvertTime(Model.CreatedAt, timeZoneInfo).ToString("M/d/yyyy @ h:mm tt")
|
||||
</span><br>
|
||||
|
||||
@if (Model.Type.AffectsLevel())
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue