added perm checks to season pages
This commit is contained in:
@@ -4,6 +4,8 @@ import "git.haelnorr.com/h/oslstats/internal/db"
|
||||
import "git.haelnorr.com/h/oslstats/internal/view/baseview"
|
||||
import "time"
|
||||
import "strconv"
|
||||
import "git.haelnorr.com/h/oslstats/internal/permissions"
|
||||
import "git.haelnorr.com/h/oslstats/internal/contexts"
|
||||
|
||||
templ DetailPage(season *db.Season) {
|
||||
@baseview.Layout(season.Name) {
|
||||
@@ -14,6 +16,10 @@ templ DetailPage(season *db.Season) {
|
||||
}
|
||||
|
||||
templ SeasonDetails(season *db.Season) {
|
||||
{{
|
||||
permCache := contexts.Permissions(ctx)
|
||||
canEditSeason := permCache.HasPermission(permissions.SeasonsUpdate)
|
||||
}}
|
||||
<div class="bg-mantle border border-surface1 rounded-lg overflow-hidden">
|
||||
<!-- Header Section -->
|
||||
<div class="bg-surface0 border-b border-surface1 px-6 py-8">
|
||||
@@ -25,13 +31,15 @@ templ SeasonDetails(season *db.Season) {
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<a
|
||||
href={ templ.SafeURL("/seasons/" + season.ShortName + "/edit") }
|
||||
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center
|
||||
bg-blue hover:bg-blue/75 text-mantle transition"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
if canEditSeason {
|
||||
<a
|
||||
href={ templ.SafeURL("/seasons/" + season.ShortName + "/edit") }
|
||||
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center
|
||||
bg-blue hover:bg-blue/75 text-mantle transition"
|
||||
>
|
||||
Edit
|
||||
</a>
|
||||
}
|
||||
<a
|
||||
href="/seasons"
|
||||
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center
|
||||
|
||||
Reference in New Issue
Block a user