we have fixtures ladies and gentleman
This commit is contained in:
@@ -28,17 +28,17 @@ const (
|
||||
type Season struct {
|
||||
bun.BaseModel `bun:"table:seasons,alias:s"`
|
||||
|
||||
ID int `bun:"id,pk,autoincrement"`
|
||||
Name string `bun:"name,unique,notnull"`
|
||||
ShortName string `bun:"short_name,unique,notnull"`
|
||||
StartDate time.Time `bun:"start_date,notnull"`
|
||||
EndDate bun.NullTime `bun:"end_date"`
|
||||
FinalsStartDate bun.NullTime `bun:"finals_start_date"`
|
||||
FinalsEndDate bun.NullTime `bun:"finals_end_date"`
|
||||
SlapVersion string `bun:"slap_version,notnull,default:'rebound'"`
|
||||
ID int `bun:"id,pk,autoincrement" json:"id"`
|
||||
Name string `bun:"name,unique,notnull" json:"name"`
|
||||
ShortName string `bun:"short_name,unique,notnull" json:"short_name"`
|
||||
StartDate time.Time `bun:"start_date,notnull" json:"start_date"`
|
||||
EndDate bun.NullTime `bun:"end_date" json:"end_date"`
|
||||
FinalsStartDate bun.NullTime `bun:"finals_start_date" json:"finals_start_date"`
|
||||
FinalsEndDate bun.NullTime `bun:"finals_end_date" json:"finals_end_date"`
|
||||
SlapVersion string `bun:"slap_version,notnull,default:'rebound'" json:"slap_version"`
|
||||
|
||||
Leagues []League `bun:"m2m:season_leagues,join:Season=League"`
|
||||
Teams []Team `bun:"m2m:team_participations,join:Season=Team"`
|
||||
Leagues []League `bun:"m2m:season_leagues,join:Season=League" json:"-"`
|
||||
Teams []Team `bun:"m2m:team_participations,join:Season=Team" json:"-"`
|
||||
}
|
||||
|
||||
// NewSeason creats a new season
|
||||
@@ -163,11 +163,21 @@ func (s *Season) GetDefaultTab() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Season) HasLeague(leagueID int) bool {
|
||||
for _, league := range s.Leagues {
|
||||
if league.ID == leagueID {
|
||||
func (s *Season) HasLeague(league *League) bool {
|
||||
for _, league_ := range s.Leagues {
|
||||
if league_.ID == league.ID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *Season) GetLeague(leagueShortName string) (*League, error) {
|
||||
for _, league := range s.Leagues {
|
||||
if league.ShortName == leagueShortName {
|
||||
return &league, nil
|
||||
}
|
||||
}
|
||||
return nil, BadRequestNotAssociated("season", "league",
|
||||
"id", "short_name", s.ID, leagueShortName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user