made draft seasons redirect to season_league view
This commit is contained in:
@@ -2,6 +2,7 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"git.haelnorr.com/h/golib/hws"
|
"git.haelnorr.com/h/golib/hws"
|
||||||
@@ -41,6 +42,9 @@ func SeasonPage(
|
|||||||
}); !ok {
|
}); !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if season.Type == db.SeasonTypeDraft.String() {
|
||||||
|
http.Redirect(w, r, fmt.Sprintf("/seasons/%s/leagues/%s", season.ShortName, "Draft"), http.StatusTemporaryRedirect)
|
||||||
|
}
|
||||||
renderSafely(seasonsview.DetailPage(season, leaguesWithTeams), s, r, w)
|
renderSafely(seasonsview.DetailPage(season, leaguesWithTeams), s, r, w)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,33 +3,63 @@ package seasonsview
|
|||||||
import "git.haelnorr.com/h/oslstats/internal/view/baseview"
|
import "git.haelnorr.com/h/oslstats/internal/view/baseview"
|
||||||
import "git.haelnorr.com/h/oslstats/internal/db"
|
import "git.haelnorr.com/h/oslstats/internal/db"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
import "git.haelnorr.com/h/oslstats/internal/contexts"
|
||||||
|
import "git.haelnorr.com/h/oslstats/internal/permissions"
|
||||||
|
|
||||||
templ SeasonLeagueLayout(activeSection string, season *db.Season, league *db.League) {
|
templ SeasonLeagueLayout(activeSection string, season *db.Season, league *db.League) {
|
||||||
|
{{
|
||||||
|
permCache := contexts.Permissions(ctx)
|
||||||
|
canEditSeason := permCache.HasPermission(permissions.SeasonsUpdate)
|
||||||
|
isDraftSeason := season.Type == db.SeasonTypeDraft.String()
|
||||||
|
}}
|
||||||
@baseview.Layout(fmt.Sprintf("%s - %s", season.Name, league.Name)) {
|
@baseview.Layout(fmt.Sprintf("%s - %s", season.Name, league.Name)) {
|
||||||
<div class="max-w-screen-2xl mx-auto px-4 py-8">
|
<div class="max-w-screen-2xl mx-auto px-4 py-8">
|
||||||
<div class="bg-mantle border border-surface1 rounded-lg overflow-hidden">
|
<div class="bg-mantle border border-surface1 rounded-lg overflow-hidden">
|
||||||
<!-- Header Section -->
|
<!-- Header Section -->
|
||||||
<div class="bg-surface0 border-b border-surface1 px-6 py-8">
|
<div class="bg-surface0 border-b border-surface1 px-6 py-8">
|
||||||
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-4">
|
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-4">
|
||||||
<div>
|
<div>
|
||||||
<div class="flex items-center gap-3 mb-2">
|
<div class="flex items-center gap-3 mb-2">
|
||||||
<h1 class="text-4xl font-bold text-text">{ season.Name } - { league.Name }</h1>
|
if isDraftSeason {
|
||||||
<span class="text-lg font-mono text-subtext0 bg-surface1 px-2 py-0.5 rounded">{ season.ShortName }</span>
|
<h1 class="text-4xl font-bold text-text">{ season.Name }</h1>
|
||||||
|
} else {
|
||||||
|
<h1 class="text-4xl font-bold text-text">{ season.Name } - { league.Name }</h1>
|
||||||
|
}
|
||||||
|
<span class="text-lg font-mono text-subtext0 bg-surface1 px-2 py-0.5 rounded">{ season.ShortName }</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
|
@SeasonTypeBadge(season.Type)
|
||||||
|
@SlapVersionBadge(season.SlapVersion)
|
||||||
|
@StatusBadge(season, false, false)
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2 flex-wrap">
|
|
||||||
@SeasonTypeBadge(season.Type)
|
|
||||||
@SlapVersionBadge(season.SlapVersion)
|
|
||||||
@StatusBadge(season, false, false)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<a
|
if isDraftSeason {
|
||||||
href={ templ.SafeURL("/seasons/" + season.ShortName) }
|
if canEditSeason {
|
||||||
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center
|
<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
|
||||||
bg-surface1 hover:bg-surface2 text-text transition"
|
bg-surface1 hover:bg-surface2 text-text transition"
|
||||||
>
|
>
|
||||||
Back to Season
|
Back to Seasons
|
||||||
</a>
|
</a>
|
||||||
|
} else {
|
||||||
|
<a
|
||||||
|
href={ templ.SafeURL("/seasons/" + season.ShortName) }
|
||||||
|
class="rounded-lg px-4 py-2 hover:cursor-pointer text-center
|
||||||
|
bg-surface1 hover:bg-surface2 text-text transition"
|
||||||
|
>
|
||||||
|
Back to Season
|
||||||
|
</a>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Season Dates -->
|
<!-- Season Dates -->
|
||||||
|
|||||||
Reference in New Issue
Block a user