mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-16 22:52:27 +00:00
Add ability to hide levels
This commit is contained in:
parent
0d7d8c25f3
commit
ef6acbb210
11 changed files with 106 additions and 32 deletions
|
@ -523,10 +523,10 @@ public class SlotsController : ControllerBase
|
|||
if (gameFilterType == "both")
|
||||
// Get game versions less than the current version
|
||||
// Needs support for LBP3 ("both" = LBP1+2)
|
||||
whereSlots = this.database.Slots.Where(s => s.Type == SlotType.User && s.GameVersion <= gameVersion && s.FirstUploaded >= oldestTime);
|
||||
whereSlots = this.database.Slots.Where(s => s.Type == SlotType.User && !s.Hidden && s.GameVersion <= gameVersion && s.FirstUploaded >= oldestTime);
|
||||
else
|
||||
// Get game versions exactly equal to gamefiltertype
|
||||
whereSlots = this.database.Slots.Where(s => s.Type == SlotType.User && s.GameVersion == gameVersion && s.FirstUploaded >= oldestTime);
|
||||
whereSlots = this.database.Slots.Where(s => s.Type == SlotType.User && !s.Hidden && s.GameVersion == gameVersion && s.FirstUploaded >= oldestTime);
|
||||
|
||||
return whereSlots.Include(s => s.Creator).Include(s => s.Location);
|
||||
}
|
||||
|
|
|
@ -20,22 +20,6 @@ public class AdminUserController : ControllerBase
|
|||
this.database = database;
|
||||
}
|
||||
|
||||
[HttpGet("unban")]
|
||||
public async Task<IActionResult> UnbanUser([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsModerator) return this.NotFound();
|
||||
|
||||
User? targetedUser = await this.database.Users.FirstOrDefaultAsync(u => u.UserId == id);
|
||||
if (targetedUser == null) return this.NotFound();
|
||||
|
||||
targetedUser.PermissionLevel = PermissionLevel.Default;
|
||||
targetedUser.BannedReason = null;
|
||||
|
||||
await this.database.SaveChangesAsync();
|
||||
return this.Redirect($"/user/{targetedUser.UserId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the user's earth decorations to a blank state. Useful for users who abuse audio for example.
|
||||
/// </summary>
|
||||
|
|
|
@ -42,15 +42,18 @@ public class LandingPage : BaseLayout
|
|||
|
||||
const int maxShownLevels = 5;
|
||||
|
||||
this.LatestTeamPicks = await this.Database.Slots.Where
|
||||
(s => s.Type == SlotType.User)
|
||||
this.LatestTeamPicks = await this.Database.Slots.Where(s => s.Type == SlotType.User && s.Type == SlotType.User)
|
||||
.Where(s => s.TeamPick)
|
||||
.OrderByDescending(s => s.FirstUploaded)
|
||||
.Take(maxShownLevels)
|
||||
.Include(s => s.Creator)
|
||||
.ToListAsync();
|
||||
|
||||
this.NewestLevels = await this.Database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(s => s.FirstUploaded).Take(maxShownLevels).Include(s => s.Creator).ToListAsync();
|
||||
this.NewestLevels = await this.Database.Slots.Where(s => s.Type == SlotType.User && s.Type == SlotType.User)
|
||||
.OrderByDescending(s => s.FirstUploaded)
|
||||
.Take(maxShownLevels)
|
||||
.Include(s => s.Creator)
|
||||
.ToListAsync();
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,18 @@
|
|||
bool isMobile = this.Request.IsMobile();
|
||||
}
|
||||
|
||||
@if (Model.Slot.Hidden)
|
||||
{
|
||||
<div class="ui inverted red segment">
|
||||
<h2>This level is currently hidden.</h2>
|
||||
<p><b>Only you and moderators may view this level.</b></p>
|
||||
|
||||
<b>Reason:</b> <span>"@Model.Slot.HiddenReason"</span>
|
||||
|
||||
<p><b>For more information please contact a moderator.</b></p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@await Html.PartialAsync("Partials/SlotCardPartial", Model.Slot, new ViewDataDictionary(ViewData)
|
||||
{
|
||||
{
|
||||
|
@ -210,5 +222,15 @@
|
|||
<span>Delete</span>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
@if (!(bool)Model.Slot?.Hidden)
|
||||
{
|
||||
<a href="/moderation/newCase?type=@((int)CaseType.LevelHide)&affectedId=@Model.Slot?.SlotId">
|
||||
<div class="ui yellow button">
|
||||
<i class="lock icon"></i>
|
||||
<span>Hide</span>
|
||||
</div>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
}
|
|
@ -26,8 +26,7 @@ public class SlotPage : BaseLayout
|
|||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int id)
|
||||
{
|
||||
Slot? slot = await this.Database.Slots.Include
|
||||
(s => s.Creator)
|
||||
Slot? slot = await this.Database.Slots.Include(s => s.Creator)
|
||||
.Where(s => s.Type == SlotType.User)
|
||||
.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (slot == null) return this.NotFound();
|
||||
|
@ -55,6 +54,8 @@ public class SlotPage : BaseLayout
|
|||
}
|
||||
}
|
||||
|
||||
if (slot.Hidden && (this.User != slot.Creator && !(bool)this.User?.IsModerator)) return this.NotFound();
|
||||
|
||||
this.Slot = slot;
|
||||
|
||||
if (this.CommentsEnabled)
|
||||
|
|
|
@ -24,12 +24,8 @@
|
|||
<b>Reason:</b>
|
||||
<span>"@Model.ProfileUser.BannedReason"</span>
|
||||
<p>
|
||||
<i>Note: Only you and other admins may view the ban reason.</i>
|
||||
<i>Note: Only you and other moderators may view the ban reason.</i>
|
||||
</p>
|
||||
<a class="ui inverted button" href="/moderation/user/@Model.ProfileUser.UserId/unban">
|
||||
<i class="ban icon"></i>
|
||||
<span>Unban User</span>
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ public enum CaseType
|
|||
UserBan = 2,
|
||||
UserCommentsDisabled = 3,
|
||||
|
||||
LevelLock = 4,
|
||||
LevelHide = 4,
|
||||
LevelCommentsDisabled = 5,
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public static class CaseTypeExtensions
|
|||
{
|
||||
return type switch
|
||||
{
|
||||
CaseType.LevelLock => true,
|
||||
CaseType.LevelHide => true,
|
||||
CaseType.LevelCommentsDisabled => true,
|
||||
_ => false,
|
||||
};
|
||||
|
|
|
@ -41,7 +41,14 @@ public class PerformCaseActionsTask : IRepeatingTask
|
|||
break;
|
||||
};
|
||||
case CaseType.UserCommentsDisabled: break;
|
||||
case CaseType.LevelLock: break;
|
||||
|
||||
case CaseType.LevelHide:
|
||||
{
|
||||
slot!.Hidden = false;
|
||||
slot.HiddenReason = "";
|
||||
|
||||
break;
|
||||
}
|
||||
case CaseType.LevelCommentsDisabled: break;
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
@ -70,7 +77,14 @@ public class PerformCaseActionsTask : IRepeatingTask
|
|||
break;
|
||||
}
|
||||
case CaseType.UserCommentsDisabled: break;
|
||||
case CaseType.LevelLock: break;
|
||||
|
||||
case CaseType.LevelHide:
|
||||
{
|
||||
slot!.Hidden = true;
|
||||
slot.HiddenReason = @case.Reason;
|
||||
|
||||
break;
|
||||
}
|
||||
case CaseType.LevelCommentsDisabled: break;
|
||||
default: throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
|
|
@ -246,6 +246,12 @@ public class Slot
|
|||
[XmlElement("vitaCrossControlRequired")]
|
||||
public bool CrossControllerRequired { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool Hidden { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string HiddenReason { get; set; }
|
||||
|
||||
public string SerializeResources()
|
||||
{
|
||||
return this.Resources.Aggregate("", (current, resource) => current + LbpSerializer.StringElement("resource", resource)) +
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
using LBPUnion.ProjectLighthouse;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ProjectLighthouse.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20220806013840_AddHiddenSlots")]
|
||||
public partial class AddHiddenSlots : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "Hidden",
|
||||
table: "Slots",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "HiddenReason",
|
||||
table: "Slots",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Hidden",
|
||||
table: "Slots");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HiddenReason",
|
||||
table: "Slots");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -250,6 +250,13 @@ namespace ProjectLighthouse.Migrations
|
|||
b.Property<int>("GameVersion")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("Hidden")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("HiddenReason")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("IconHash")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue