Skip to content

Commit

Permalink
Add new permisison for deleting game entries, resolves #1292
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Aug 13, 2022
1 parent 12c9dc4 commit fd7512f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions TASVideos.Data/Entity/PermissionTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ public enum PermissionTo
[Description("The ability to create and modify publication awards")]
CreateAwards = 307,

[Group("Publication Maintenance")]
[Description("The ability to delete a game entry")]
DeleteGameEntries = 308,

[Group("Publication Maintenance")]
[Description("The ability to add, edit, and remove the tags used for publications")]
TagMaintenance = 390,
Expand Down
2 changes: 1 addition & 1 deletion TASVideos/Pages/Games/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
string returnUrl = HttpContext.Request.ReturnUrl();
}
<form-group>
<delete-button condition="@Model.CanDelete" asp-href="/Games/Edit/@(Model.Id ?? 0)?handler=Delete" class="float-end">Delete</delete-button>
<delete-button permission="DeleteGameEntries" condition="@Model.CanDelete" asp-href="/Games/Edit/@(Model.Id ?? 0)?handler=Delete" class="float-end">Delete</delete-button>
</form-group>
<div class="text-danger">
@Html.ValidationSummary()
Expand Down
5 changes: 5 additions & 0 deletions TASVideos/Pages/Games/Edit.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ public async Task<IActionResult> OnPostDelete()
return NotFound();
}

if (!User.Has(PermissionTo.DeleteGameEntries))
{
return AccessDenied();
}

if (!await CanBeDeleted())
{
ErrorStatusMessage($"Unable to delete Game {Id}, game is used by a publication or submission.");
Expand Down

0 comments on commit fd7512f

Please sign in to comment.