Skip to content

Commit

Permalink
Allow any member of a team to create a team-only simul.
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Jan 22, 2025
1 parent 2ab6257 commit f24ed84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/controllers/Simul.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ final class Simul(env: Env) extends LilaController(env):
NoLameOrBot:
Ok.async:
env.team.api
.lightsByTourLeader(me)
.lightsOf(me)
.map: teams =>
views.simul.form.create(forms.create(teams), teams)
}

def create = AuthBody { ctx ?=> me ?=>
NoLameOrBot:
env.team.api
.lightsByTourLeader(me)
.lightsOf(me)
.flatMap: teams =>
bindForm(forms.create(teams))(
err => BadRequest.page(views.simul.form.create(err, teams)),
Expand Down Expand Up @@ -138,15 +138,15 @@ final class Simul(env: Env) extends LilaController(env):
def edit(id: SimulId) = Auth { ctx ?=> me ?=>
AsHost(id): simul =>
Ok.async:
env.team.api.lightsByTourLeader(me).map { teams =>
env.team.api.lightsOf(me).map { teams =>
views.simul.form.edit(forms.edit(teams, simul), teams, simul)
}
}

def update(id: SimulId) = AuthBody { ctx ?=> me ?=>
AsHost(id): simul =>
env.team.api
.lightsByTourLeader(me)
.lightsOf(me)
.flatMap: teams =>
def errPage(err: lila.simul.SimulForm.EitherForm) =
BadRequest.page(views.simul.form.edit(err, teams, simul))
Expand Down
3 changes: 3 additions & 0 deletions modules/team/src/main/TeamApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ final class TeamApi(
def lightsByTourLeader[U: UserIdOf](leader: U): Fu[List[LightTeam]] =
memberRepo.teamsLedBy(leader, Some(_.Tour)).flatMap(teamRepo.lightsByIds)

def lightsOf[U: UserIdOf](member: U): Fu[List[LightTeam]] =
cached.teamIdsList(member).flatMap(teamRepo.lightsByIds)

def forumAccessOf(id: TeamId) = cached.forumAccess.get(id)

def request(id: TeamRequest.ID) = requestRepo.coll.byId[TeamRequest](id)
Expand Down

0 comments on commit f24ed84

Please sign in to comment.