def get_organiser_actions(self): """Get all the actions the user can perform as a TO""" # Find all tournaments that can have their rounds set modifiable_tournaments = all_tournaments_with_permission( PERMISSIONS.get('MODIFY_TOURNAMENT'), self.username) set_rounds = [ self.action('Set num rounds for {}'.format(x), 'set_rounds', tourn=x) for x in modifiable_tournaments] # Find all tournaments that can have their missions set set_mission_actions = [ self.action('Set missions for {}'.format(x), 'set_missions', tourn=x) for x in modifiable_tournaments] # Find all tournaments that can have their score_categories set set_cats = [ self.action('Set scoring categories for {}'.format(x), 'set_score_categories', tourn=x) \ for x in modifiable_tournaments] actions = [self.action('Create a Tournament', 'create_tournament')] \ + set_rounds + set_cats + set_mission_actions return { 'title': 'Organise', 'actions': strip_none(actions) }
def wrapped(*args, **kwargs): # pylint: disable=missing-docstring user = getattr(request.authorization, "username", None) target = getattr(g, "username", None) checker = PermissionsChecker() # pylint: disable=undefined-variable checker.check_permission( PERMISSIONS.get(permission.get("permission")), user, target, getattr(g, "tournament_id", None) ) return func(*args, **kwargs)