add a button for team admins to re-enable disabled teams
parent
e5d0b3402a
commit
e6e23d9c32
|
@ -197,7 +197,7 @@ final class Team(
|
|||
def disable(id: String) =
|
||||
Auth { implicit ctx => me =>
|
||||
WithOwnedTeam(id) { team =>
|
||||
api.disable(team, me) >>
|
||||
api.toggleEnabled(team, me) >>
|
||||
env.mod.logApi.disableTeam(me.id, team.id, team.name) inject
|
||||
Redirect(routes.Team show id).flashSuccess
|
||||
}
|
||||
|
|
|
@ -87,6 +87,13 @@ object form {
|
|||
cls := "text button button-empty button-red confirm",
|
||||
st.title := "Deletes the team and its memberships. Cannot be reverted!"
|
||||
)(trans.delete())
|
||||
),
|
||||
(t.disabled && isGranted(_.ManageTeam)) option
|
||||
postForm(cls := "inline", action := routes.Team.disable(t.id))(
|
||||
submitButton(
|
||||
cls := "button button-empty confirm",
|
||||
st.title := "Re-enables the team and restores memberships"
|
||||
)("Re-enable")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -271,18 +271,19 @@ final class TeamApi(
|
|||
teamIds.nonEmpty ?? teamRepo.coll.exists($inIds(teamIds) ++ $doc("leaders" -> leader))
|
||||
}
|
||||
|
||||
def enable(team: Team): Funit =
|
||||
teamRepo.enable(team).void >>- (indexer ! InsertTeam(team))
|
||||
|
||||
def disable(team: Team, by: User): Funit =
|
||||
if (lila.security.Granter(_.ManageTeam)(by) || team.createdBy == by.id || !team.leaders(team.createdBy))
|
||||
teamRepo.disable(team).void >>
|
||||
memberRepo.userIdsByTeam(team.id).map {
|
||||
_ foreach cached.invalidateTeamIds
|
||||
} >>
|
||||
requestRepo.removeByTeam(team.id).void >>-
|
||||
(indexer ! RemoveTeam(team.id))
|
||||
else
|
||||
def toggleEnabled(team: Team, by: User): Funit =
|
||||
if (
|
||||
lila.security.Granter(_.ManageTeam)(by) || team.createdBy == by.id ||
|
||||
(team.leaders(by.id) && !team.leaders(team.createdBy))
|
||||
) {
|
||||
if (team.enabled)
|
||||
teamRepo.disable(team).void >>
|
||||
memberRepo.userIdsByTeam(team.id).map { _ foreach cached.invalidateTeamIds } >>
|
||||
requestRepo.removeByTeam(team.id).void >>-
|
||||
(indexer ! RemoveTeam(team.id))
|
||||
else
|
||||
teamRepo.enable(team).void >>- (indexer ! InsertTeam(team))
|
||||
} else
|
||||
teamRepo.setLeaders(team.id, team.leaders - by.id)
|
||||
|
||||
// delete for ever, with members but not forums
|
||||
|
|
|
@ -12,8 +12,6 @@ final private[team] class TeamCli(
|
|||
|
||||
def process = {
|
||||
|
||||
case "team" :: "enable" :: team :: Nil => perform(team)(api.enable)
|
||||
|
||||
case "team" :: "recompute" :: "nbMembers" :: "all" :: Nil =>
|
||||
api.recomputeNbMembers
|
||||
fuccess("In progress... it will take a while")
|
||||
|
|
Loading…
Reference in New Issue