This commit is contained in:
@@ -23,7 +23,7 @@ from app.models import (
|
||||
TeamPlayer,
|
||||
)
|
||||
from app.pagination import paginate
|
||||
from app.permissions import can_manage_org_team, coach_org_teams, visible_org_teams
|
||||
from app.permissions import coach_org_teams, representative_org_teams, visible_org_teams
|
||||
from app.responders import respond_after_change
|
||||
from app.routes.matches import default_end_time
|
||||
from app.services.scheduling import notify_participants, zip_participants
|
||||
@@ -36,10 +36,11 @@ team_matches_bp = Blueprint('team_matches', __name__, url_prefix='/team-matches'
|
||||
def can_manage_team_match(team):
|
||||
"""Whether the current user can manage matches for this team.
|
||||
|
||||
Same rule as administering the team itself, so it is the same call.
|
||||
This function used to restate it, and the restatement drifted.
|
||||
Everyone who administers the team, plus the player named as its
|
||||
responsible. Narrower than administering the team itself: a responsible
|
||||
schedules and edits matches, but does not touch the roster.
|
||||
"""
|
||||
return can_manage_org_team(current_user, team)
|
||||
return current_user.can_manage_team_matches(team)
|
||||
|
||||
|
||||
def season_locked():
|
||||
@@ -300,13 +301,13 @@ def delete_match(match_id):
|
||||
@login_required
|
||||
def api_manageable_teams():
|
||||
"""API endpoint returning teams the current user can schedule matches for."""
|
||||
if not current_user.can_schedule_matches():
|
||||
return jsonify([])
|
||||
|
||||
if isinstance(current_user, (Admin, Manager)):
|
||||
teams = OrgTeam.query.order_by(OrgTeam.name).all()
|
||||
elif isinstance(current_user, Coach):
|
||||
teams = coach_org_teams(current_user)
|
||||
elif isinstance(current_user, Player):
|
||||
# A responsible schedules matches for their own team(s) only.
|
||||
teams = representative_org_teams(current_user)
|
||||
else:
|
||||
return jsonify([])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user