Limit total number of teams (#1867)

* Adds support for a total teams limit
This commit is contained in:
Chris Frohoff
2021-06-25 20:00:40 -07:00
committed by GitHub
parent df27d0e7a9
commit dd05f57b6a
9 changed files with 110 additions and 1 deletions

View File

@@ -197,6 +197,14 @@ def new():
description="Team creation is currently disabled. Please join an existing team.",
)
num_teams_limit = int(get_config("num_teams", default=0))
num_teams = Teams.query.filter_by(banned=False, hidden=False).count()
if num_teams_limit and num_teams >= num_teams_limit:
abort(
403,
description=f"Reached the maximum number of teams ({num_teams_limit}). Please join an existing team.",
)
user = get_current_user_attrs()
if user.team_id:
errors.append("You are already in a team. You cannot join another.")