Add ability to hide levels

This commit is contained in:
jvyden 2022-08-05 21:34:43 -04:00
commit ef6acbb210
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
11 changed files with 106 additions and 32 deletions

View file

@ -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>

View file

@ -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();
}

View file

@ -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>
}

View file

@ -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)

View file

@ -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
{