local changes
This commit is contained in:
@@ -217,6 +217,34 @@ def is_coach_user(usercoach,userrower):
|
||||
|
||||
return False
|
||||
|
||||
# checks if rower is coach of user (or is user himself)
|
||||
@rules.predicate
|
||||
def is_anonymous_or_coach(usercoach,userrower):
|
||||
print(usercoach,userrower)
|
||||
if usercoach == userrower:
|
||||
return True
|
||||
|
||||
if userrower.is_anonymous and userrower.is_anonymous:
|
||||
return True
|
||||
|
||||
if not is_coach(usercoach):
|
||||
return False
|
||||
|
||||
r = userrower.rower
|
||||
|
||||
coaches = []
|
||||
|
||||
for group in r.coachinggroups.all():
|
||||
newcoaches = group.get_coaches()
|
||||
for coach in newcoaches:
|
||||
coaches.append(coach)
|
||||
|
||||
for coach in coaches:
|
||||
if usercoach.rower == coach:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
# check if rower and user are members of the same team
|
||||
@rules.predicate
|
||||
def is_rower_team_member(user,rower):
|
||||
@@ -274,6 +302,7 @@ def can_plan_user(user,rower):
|
||||
rules.add_perm('rower.add_plan',can_plan_user) # replaces checkaccessplanuser
|
||||
rules.add_perm('rower.is_coach',is_coach_user) # replaces checkaccessuser
|
||||
rules.add_perm('rower.is_pro',ispromember)
|
||||
rules.add_perm('anonymous.is_coach',is_anonymous_or_coach)
|
||||
|
||||
# WORKOUT permissions
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
26,28,workouts_join_view,join workouts,TRUE,302,pro,302,302,pro,403,403,coach,302,403,FALSE,TRUE,FALSE,TRUE
|
||||
27,29,workouts_join_select,select workouts to join,TRUE,404,pro,200,302,pro,403,403,coach,200,403,FALSE,TRUE,FALSE,TRUE
|
||||
28,30,user_boxplot_select,select boxplots,TRUE,302,pro,200,302,pro,403,403,coach,200,302,FALSE,TRUE,FALSE,TRUE
|
||||
29,31,analysis_new,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,TRUE,FALSE,FALSE
|
||||
29,31,analysis_new,front page for analysis section,TRUE,200,basic,200,302,FALSE,200,302,coach,200,302,FALSE,TRUE,FALSE,TRUE
|
||||
30,32,user_multiflex_select,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,TRUE,FALSE,FALSE
|
||||
31,33,session_jobs_view,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE
|
||||
32,34,session_jobs_status,,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE
|
||||
|
||||
|
Reference in New Issue
Block a user