mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-19 16:02:26 +00:00
Rename case properties, add dismissal button
This commit is contained in:
parent
b3d91fd470
commit
1996c1cdbb
7 changed files with 233 additions and 45 deletions
|
@ -33,7 +33,7 @@ public class CasePage : BaseLayout
|
||||||
this.Cases = await this.Database.Cases
|
this.Cases = await this.Database.Cases
|
||||||
.OrderByDescending(c => c.CaseId)
|
.OrderByDescending(c => c.CaseId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
this.CaseCount = await this.Database.Cases.CountAsync(c => c.CaseDescription.Contains(this.SearchValue));
|
this.CaseCount = await this.Database.Cases.CountAsync(c => c.Description.Contains(this.SearchValue));
|
||||||
|
|
||||||
this.PageNumber = pageNumber;
|
this.PageNumber = pageNumber;
|
||||||
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.CaseCount / ServerStatics.PageSize));
|
this.PageAmount = Math.Max(1, (int)Math.Ceiling((double)this.CaseCount / ServerStatics.PageSize));
|
||||||
|
|
|
@ -22,11 +22,11 @@ public class NewCasePage : BaseLayout
|
||||||
{
|
{
|
||||||
ModerationCase @case = new()
|
ModerationCase @case = new()
|
||||||
{
|
{
|
||||||
CaseType = (CaseType)type,
|
Type = (CaseType)type,
|
||||||
CaseDescription = description,
|
Description = description,
|
||||||
CaseExpires = expires,
|
ExpiresAt = expires,
|
||||||
CaseCreated = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CaseCreatorId = 1,
|
CreatorId = 1,
|
||||||
AffectedId = affectedId,
|
AffectedId = affectedId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
@using System.Diagnostics
|
||||||
@using LBPUnion.ProjectLighthouse
|
@using LBPUnion.ProjectLighthouse
|
||||||
@using LBPUnion.ProjectLighthouse.Administration
|
@using LBPUnion.ProjectLighthouse.Administration
|
||||||
@using LBPUnion.ProjectLighthouse.Configuration
|
@using LBPUnion.ProjectLighthouse.Configuration
|
||||||
|
@ -7,43 +8,59 @@
|
||||||
|
|
||||||
@{
|
@{
|
||||||
Database database = new();
|
Database database = new();
|
||||||
string color = Model.Expired ? "red" : "green";
|
string color = "blue";
|
||||||
|
|
||||||
|
if (Model.Expired) color = "yellow";
|
||||||
|
if (Model.Dismissed) color = "green";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="ui @color segment">
|
<div class="ui @color segment">
|
||||||
<h2>Case #@Model.CaseId: @Model.CaseType</h2>
|
<h2>Case #@Model.CaseId: @Model.Type</h2>
|
||||||
@if (Model.Expired)
|
|
||||||
|
@if (Model.Dismissed)
|
||||||
|
{
|
||||||
|
Debug.Assert(Model.Dismisser != null);
|
||||||
|
Debug.Assert(Model.DismissedAt != null);
|
||||||
|
|
||||||
|
<h3 class="ui red header">
|
||||||
|
This case was dismissed by <a href="/user/@Model.Dismisser.UserId">@Model.Dismisser.Username</a> on @Model.DismissedAt.Value.ToString("MM/dd/yyyy @ h:mm tt").
|
||||||
|
</h3>
|
||||||
|
}
|
||||||
|
else if (Model.Expired)
|
||||||
{
|
{
|
||||||
<h3 class="ui red header">
|
<h3 class="ui red header">
|
||||||
This case expired on @Model.CaseExpires!.Value.ToString("MM/dd/yyyy @ h:mm tt").
|
This case expired on @Model.ExpiresAt!.Value.ToString("MM/dd/yyyy @ h:mm tt").
|
||||||
</h3>
|
</h3>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
Case created by <a href="/user/@Model.CaseCreator!.UserId">@Model.CaseCreator.Username</a>
|
Case created by <a href="/user/@Model.Creator!.UserId">@Model.Creator.Username</a>
|
||||||
on @Model.CaseCreated.ToString("MM/dd/yyyy @ h:mm tt")
|
on @Model.CreatedAt.ToString("MM/dd/yyyy @ h:mm tt")
|
||||||
</span><br>
|
</span><br>
|
||||||
|
|
||||||
@if (Model.CaseType.AffectsLevel())
|
@if (Model.Type.AffectsLevel())
|
||||||
{
|
{
|
||||||
Slot slot = await Model.GetSlotAsync(database);
|
Slot slot = await Model.GetSlotAsync(database);
|
||||||
<p><strong>Affected level:</strong> <a href="/slot/@slot.SlotId">@slot.Name</a></p>
|
<p><strong>Affected level:</strong> <a href="/slot/@slot.SlotId">@slot.Name</a></p>
|
||||||
}
|
}
|
||||||
else if (Model.CaseType.AffectsUser())
|
else if (Model.Type.AffectsUser())
|
||||||
{
|
{
|
||||||
User user = await Model.GetUserAsync(database);
|
User user = await Model.GetUserAsync(database);
|
||||||
<p><strong>Affected user:</strong> <a href="/user/@user.UserId">@user.Username</a></p>
|
<p><strong>Affected user:</strong> <a href="/user/@user.UserId">@user.Username</a></p>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!string.IsNullOrWhiteSpace(Model.CaseDescription))
|
@if (!string.IsNullOrWhiteSpace(Model.Description))
|
||||||
{
|
{
|
||||||
<h3>Description</h3>
|
<h3>Description</h3>
|
||||||
<pre>@Model.CaseDescription</pre>
|
<pre>@Model.Description</pre>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<b>No description was provided.</b>
|
<b>No description was provided.</b>
|
||||||
}
|
}
|
||||||
|
|
||||||
<a href="/moderation/case/@Model.CaseId/expire"></a>
|
<a class="ui green small button" href="/moderation/case/@Model.CaseId/dismiss">
|
||||||
|
<i class="checkmark icon"></i>
|
||||||
|
<span>Dismiss</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
|
@ -114,6 +114,7 @@
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Braaains/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Braaains/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=brun/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=brun/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=deflater/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=deflater/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dismisser/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=dpadrate/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=dpadrate/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=dumbass/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=dumbass/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ezoiar/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=ezoiar/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
|
|
@ -15,32 +15,38 @@ public class ModerationCase
|
||||||
[Key]
|
[Key]
|
||||||
public int CaseId { get; set; }
|
public int CaseId { get; set; }
|
||||||
|
|
||||||
public CaseType CaseType { get; set; }
|
public CaseType Type { get; set; }
|
||||||
|
|
||||||
public string CaseDescription { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public DateTime CaseCreated { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
|
|
||||||
public DateTime? CaseExpires { get; set; }
|
public DateTime? ExpiresAt { get; set; }
|
||||||
public bool Expired => this.CaseExpires != null && this.CaseExpires < DateTime.Now;
|
public bool Expired => this.ExpiresAt != null && this.ExpiresAt < DateTime.Now;
|
||||||
|
|
||||||
public int CaseCreatorId { get; set; }
|
public DateTime? DismissedAt { get; set; }
|
||||||
|
public bool Dismissed => this.DismissedAt != null;
|
||||||
|
public int? DismisserId { get; set; }
|
||||||
|
[ForeignKey(nameof(DismisserId))]
|
||||||
|
public User? Dismisser { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(CaseCreatorId))]
|
public int CreatorId { get; set; }
|
||||||
public User? CaseCreator { get; set; }
|
|
||||||
|
[ForeignKey(nameof(CreatorId))]
|
||||||
|
public User? Creator { get; set; }
|
||||||
|
|
||||||
public int AffectedId { get; set; }
|
public int AffectedId { get; set; }
|
||||||
|
|
||||||
#region Get affected id result
|
#region Get affected id result
|
||||||
public Task<User> GetUserAsync(Database database)
|
public Task<User> GetUserAsync(Database database)
|
||||||
{
|
{
|
||||||
Debug.Assert(CaseType.AffectsUser());
|
Debug.Assert(this.Type.AffectsUser());
|
||||||
return database.Users.FirstOrDefaultAsync(u => u.UserId == this.AffectedId)!;
|
return database.Users.FirstOrDefaultAsync(u => u.UserId == this.AffectedId)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Slot> GetSlotAsync(Database database)
|
public Task<Slot> GetSlotAsync(Database database)
|
||||||
{
|
{
|
||||||
Debug.Assert(CaseType.AffectsLevel());
|
Debug.Assert(this.Type.AffectsLevel());
|
||||||
return database.Slots.FirstOrDefaultAsync(u => u.SlotId == this.AffectedId)!;
|
return database.Slots.FirstOrDefaultAsync(u => u.SlotId == this.AffectedId)!;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -54,11 +60,11 @@ public class ModerationCase
|
||||||
public static ModerationCase NewBanCase(int caseCreator, int userId, string reason, string modNotes, DateTime caseExpires)
|
public static ModerationCase NewBanCase(int caseCreator, int userId, string reason, string modNotes, DateTime caseExpires)
|
||||||
=> new()
|
=> new()
|
||||||
{
|
{
|
||||||
CaseType = CaseType.UserBan,
|
Type = CaseType.UserBan,
|
||||||
CaseDescription = $"Banned for reason '{reason}'\nModeration notes: {modNotes}",
|
Description = $"Banned for reason '{reason}'\nModeration notes: {modNotes}",
|
||||||
CaseCreatorId = caseCreator,
|
CreatorId = caseCreator,
|
||||||
CaseCreated = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
CaseExpires = caseExpires,
|
ExpiresAt = caseExpires,
|
||||||
AffectedId = userId,
|
AffectedId = userId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
using System;
|
||||||
|
using LBPUnion.ProjectLighthouse;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace ProjectLighthouse.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(Database))]
|
||||||
|
[Migration("20220805213150_RenameCaseProperties")]
|
||||||
|
public partial class RenameCaseProperties : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.Sql("DELETE FROM Cases;");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Cases_Users_CaseCreatorId",
|
||||||
|
table: "Cases");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CaseType",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "Type");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CaseExpires",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "ExpiresAt");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CaseDescription",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "Description");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CaseCreatorId",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "CreatorId");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CaseCreated",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "CreatedAt");
|
||||||
|
|
||||||
|
migrationBuilder.RenameIndex(
|
||||||
|
name: "FK_Cases_Users_CaseCreatorId",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "FK_Cases_Users_CreatorId");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<DateTime>(
|
||||||
|
name: "DismissedAt",
|
||||||
|
table: "Cases",
|
||||||
|
type: "datetime(6)",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "DismisserId",
|
||||||
|
table: "Cases",
|
||||||
|
type: "int",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Cases_DismisserId",
|
||||||
|
table: "Cases",
|
||||||
|
column: "DismisserId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Cases_Users_CreatorId",
|
||||||
|
table: "Cases",
|
||||||
|
column: "CreatorId",
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Cases_Users_DismisserId",
|
||||||
|
table: "Cases",
|
||||||
|
column: "DismisserId",
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "UserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Cases_Users_CreatorId",
|
||||||
|
table: "Cases");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Cases_Users_DismisserId",
|
||||||
|
table: "Cases");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Cases_DismisserId",
|
||||||
|
table: "Cases");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DismissedAt",
|
||||||
|
table: "Cases");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "DismisserId",
|
||||||
|
table: "Cases");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Type",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "CaseType");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "ExpiresAt",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "CaseExpires");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Description",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "CaseDescription");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CreatorId",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "CaseCreatorId");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "CreatedAt",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "CaseCreated");
|
||||||
|
|
||||||
|
migrationBuilder.RenameIndex(
|
||||||
|
name: "IX_Cases_CreatorId",
|
||||||
|
table: "Cases",
|
||||||
|
newName: "IX_Cases_CaseCreatorId");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "Banned",
|
||||||
|
table: "Users",
|
||||||
|
type: "tinyint(1)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Cases_Users_CaseCreatorId",
|
||||||
|
table: "Cases",
|
||||||
|
column: "CaseCreatorId",
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "UserId",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,25 +41,33 @@ namespace ProjectLighthouse.Migrations
|
||||||
b.Property<int>("AffectedId")
|
b.Property<int>("AffectedId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<DateTime>("CaseCreated")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
b.Property<int>("CaseCreatorId")
|
b.Property<int>("CreatorId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("CaseDescription")
|
b.Property<string>("Description")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<DateTime?>("CaseExpires")
|
b.Property<DateTime?>("DismissedAt")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
b.Property<int>("CaseType")
|
b.Property<int?>("DismisserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("ExpiresAt")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.HasKey("CaseId");
|
b.HasKey("CaseId");
|
||||||
|
|
||||||
b.HasIndex("CaseCreatorId");
|
b.HasIndex("CreatorId");
|
||||||
|
|
||||||
|
b.HasIndex("DismisserId");
|
||||||
|
|
||||||
b.ToTable("Cases");
|
b.ToTable("Cases");
|
||||||
});
|
});
|
||||||
|
@ -690,9 +698,6 @@ namespace ProjectLighthouse.Migrations
|
||||||
b.Property<string>("ApprovedIPAddress")
|
b.Property<string>("ApprovedIPAddress")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<bool>("Banned")
|
|
||||||
.HasColumnType("tinyint(1)");
|
|
||||||
|
|
||||||
b.Property<string>("BannedReason")
|
b.Property<string>("BannedReason")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
@ -919,13 +924,19 @@ namespace ProjectLighthouse.Migrations
|
||||||
|
|
||||||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Administration.ModerationCase", b =>
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Administration.ModerationCase", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "CaseCreator")
|
b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "Creator")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("CaseCreatorId")
|
.HasForeignKey("CreatorId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("CaseCreator");
|
b.HasOne("LBPUnion.ProjectLighthouse.PlayerData.Profiles.User", "Dismisser")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("DismisserId");
|
||||||
|
|
||||||
|
b.Navigation("Creator");
|
||||||
|
|
||||||
|
b.Navigation("Dismisser");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Administration.Reports.GriefReport", b =>
|
modelBuilder.Entity("LBPUnion.ProjectLighthouse.Administration.Reports.GriefReport", b =>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue