added player names

This commit is contained in:
2026-02-19 20:48:31 +11:00
parent 71373c4747
commit c3d8e6c675
5 changed files with 43 additions and 5 deletions

View File

@@ -0,0 +1,31 @@
package migrations
import (
"context"
"git.haelnorr.com/h/oslstats/internal/db"
"github.com/uptrace/bun"
)
func init() {
Migrations.MustRegister(
// UP migration
func(ctx context.Context, conn *bun.DB) error {
// Add your migration code here
_, err := conn.NewAddColumn().
Model((*db.Player)(nil)).
IfNotExists().
ColumnExpr("name VARCHAR NOT NULL").
Exec(ctx)
if err != nil {
return err
}
return nil
},
// DOWN migration
func(ctx context.Context, conn *bun.DB) error {
// Add your rollback code here
return nil
},
)
}

View File

@@ -14,6 +14,7 @@ type Player struct {
SlapID *uint32 `bun:"slap_id,unique" json:"slap_id"`
DiscordID string `bun:"discord_id,unique,notnull" json:"discord_id"`
UserID *int `bun:"user_id,unique" json:"user_id"`
Name string `bun:"name,notnull" json:"name"`
User *User `bun:"rel:belongs-to,join:user_id=id" json:"-"`
}

View File

@@ -14,6 +14,7 @@ type Config struct {
OAuthScopes string // Authorisation scopes for OAuth
RedirectPath string // ENV DISCORD_REDIRECT_PATH: Path for the OAuth redirect handler (required)
BotToken string // ENV DISCORD_BOT_TOKEN: Token for the discord bot (required)
GuildID string // ENV DISCORD_GUILD_ID: ID for the discord server the bot should connect to (required)
}
func ConfigFromEnv() (any, error) {
@@ -23,6 +24,7 @@ func ConfigFromEnv() (any, error) {
OAuthScopes: getOAuthScopes(),
RedirectPath: env.String("DISCORD_REDIRECT_PATH", ""),
BotToken: env.String("DISCORD_BOT_TOKEN", ""),
GuildID: env.String("DISCORD_GUILD_ID", ""),
}
// Check required fields
@@ -38,6 +40,9 @@ func ConfigFromEnv() (any, error) {
if cfg.BotToken == "" {
return nil, errors.New("Envar not set: DISCORD_BOT_TOKEN")
}
if cfg.GuildID == "" {
return nil, errors.New("Envar not set: DISCORD_GUILD_ID")
}
return cfg, nil
}

View File

@@ -24,10 +24,11 @@ const (
LeaguesDelete Permission = "leagues.delete"
// Teams permissions
TeamsCreate Permission = "teams.create"
TeamsUpdate Permission = "teams.update"
TeamsDelete Permission = "teams.delete"
TeamsAddToLeague Permission = "teams.add_to_league"
TeamsCreate Permission = "teams.create"
TeamsUpdate Permission = "teams.update"
TeamsDelete Permission = "teams.delete"
TeamsAddToLeague Permission = "teams.add_to_league"
TeamsManagePlayers Permission = "teams.manage_players"
// Users permissions
UsersUpdate Permission = "users.update"

View File

@@ -122,7 +122,7 @@ templ SeasonLeagueTeams(season *db.Season, league *db.League, teams []*db.Team,
} else {
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
for _, team := range teams {
<div class="bg-surface0 border border-surface1 rounded-lg p-6 hover:bg-surface1 transition-colors">
<div class="bg-surface0 border border-surface1 rounded-lg p-6 hover:bg-surface1 transition-colors hover:cursor-pointer">
<div class="flex justify-between items-start mb-3">
<h3 class="text-xl font-bold text-text">{ team.Name }</h3>
if team.Color != "" {