athlete edit permissions in place
This commit is contained in:
@@ -340,6 +340,7 @@ class Team(models.Model):
|
||||
|
||||
viewing = models.CharField(max_length=30,choices=viewchoices,default='allmembers',verbose_name='Sharing Behavior')
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
@@ -831,6 +832,7 @@ class Rower(models.Model):
|
||||
|
||||
# Friends/Team
|
||||
friends = models.ManyToManyField("self",blank=True)
|
||||
coaches = models.ManyToManyField("self",blank=True)
|
||||
privacy = models.CharField(default='visible',max_length=30,
|
||||
choices=privacychoices)
|
||||
|
||||
@@ -986,12 +988,12 @@ def checkworkoutuser(user,workout):
|
||||
return False
|
||||
try:
|
||||
r = Rower.objects.get(user=user)
|
||||
teams = workout.team.all()
|
||||
coaches = user.rower.coaches.filter(rowerplan='coach')
|
||||
if workout.user == r:
|
||||
return True
|
||||
elif teams:
|
||||
for team in teams:
|
||||
if user == team.manager and workout.privacy == 'visible':
|
||||
elif coaches:
|
||||
for coach in coaches:
|
||||
if user.rower == coach and workout.privacy == 'visible':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -1003,17 +1005,17 @@ def checkworkoutuser(user,workout):
|
||||
def checkaccessuser(user,rower):
|
||||
try:
|
||||
r = Rower.objects.get(user=user)
|
||||
teams = Team.objects.filter(manager=user)
|
||||
if rower == r:
|
||||
return True
|
||||
elif teams:
|
||||
for team in teams:
|
||||
if team in rower.team.all():
|
||||
coaches = rower.coaches.filter(rowerplan='coach')
|
||||
if coaches:
|
||||
for coach in coaches:
|
||||
if user.rower == coach:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except Rower.DoesNotExist:
|
||||
return False
|
||||
return False
|
||||
|
||||
timezones = (
|
||||
(x,x) for x in pytz.common_timezones
|
||||
|
||||
Reference in New Issue
Block a user