we have fixtures ladies and gentleman
This commit is contained in:
@@ -24,19 +24,14 @@ func GetSeasonLeague(ctx context.Context, tx bun.Tx, seasonShortName, leagueShor
|
||||
return nil, nil, nil, errors.New("league short_name cannot be empty")
|
||||
}
|
||||
|
||||
// Get the season
|
||||
season, err := GetSeason(ctx, tx, seasonShortName)
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(err, "GetSeason")
|
||||
}
|
||||
|
||||
// Get the league
|
||||
league, err := GetLeague(ctx, tx, leagueShortName)
|
||||
league, err := season.GetLeague(leagueShortName)
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(err, "GetLeague")
|
||||
}
|
||||
if !season.HasLeague(league.ID) {
|
||||
return nil, nil, nil, BadRequestNotAssociated("season", "league", seasonShortName, leagueShortName)
|
||||
return nil, nil, nil, errors.Wrap(err, "season.GetLeague")
|
||||
}
|
||||
|
||||
// Get all teams participating in this season+league
|
||||
@@ -63,8 +58,9 @@ func NewSeasonLeague(ctx context.Context, tx bun.Tx, seasonShortName, leagueShor
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "GetLeague")
|
||||
}
|
||||
if season.HasLeague(league.ID) {
|
||||
return BadRequestAssociated("season", "league", seasonShortName, leagueShortName)
|
||||
if season.HasLeague(league) {
|
||||
return BadRequestAssociated("season", "league",
|
||||
"id", "id", season.ID, league.ID)
|
||||
}
|
||||
seasonLeague := &SeasonLeague{
|
||||
SeasonID: season.ID,
|
||||
@@ -84,12 +80,9 @@ func NewSeasonLeague(ctx context.Context, tx bun.Tx, seasonShortName, leagueShor
|
||||
}
|
||||
|
||||
func (s *Season) RemoveLeague(ctx context.Context, tx bun.Tx, leagueShortName string, audit *AuditMeta) error {
|
||||
league, err := GetLeague(ctx, tx, leagueShortName)
|
||||
league, err := s.GetLeague(leagueShortName)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "GetLeague")
|
||||
}
|
||||
if !s.HasLeague(league.ID) {
|
||||
return errors.New("league not in season")
|
||||
return errors.Wrap(err, "s.GetLeague")
|
||||
}
|
||||
info := &AuditInfo{
|
||||
string(permissions.SeasonsRemoveLeague),
|
||||
@@ -107,3 +100,12 @@ func (s *Season) RemoveLeague(ctx context.Context, tx bun.Tx, leagueShortName st
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Team) InTeams(teams []*Team) bool {
|
||||
for _, team := range teams {
|
||||
if t.ID == team.ID {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user