Merge branch 'feature/newpermissions' into develop
This commit is contained in:
+2
-2
@@ -24,7 +24,7 @@ class RowerInline(admin.StackedInline):
|
||||
('Billing Details',
|
||||
{'fields':('street_address','city','postal_code','country','paymentprocessor','customer_id')}),
|
||||
('Rower Plan',
|
||||
{'fields':('paidplan','rowerplan','paymenttype','planexpires','teamplanexpires','clubsize','protrialexpires','plantrialexpires',)}),
|
||||
{'fields':('paidplan','rowerplan','paymenttype','planexpires','teamplanexpires','protrialexpires','plantrialexpires',)}),
|
||||
('Rower Settings',
|
||||
{'fields':
|
||||
('gdproptin','gdproptindate','weightcategory','sex','adaptiveclass','birthdate','getemailnotifications',
|
||||
@@ -128,7 +128,7 @@ class IndoorVirtualRaceResultAdmin(admin.ModelAdmin):
|
||||
search_fields = ['race__name','username']
|
||||
|
||||
class PaidPlanAdmin(admin.ModelAdmin):
|
||||
list_display = ('name','shortname','price','paymenttype','paymentprocessor','clubsize','external_id')
|
||||
list_display = ('name','shortname','price','paymenttype','paymentprocessor','external_id')
|
||||
|
||||
admin.site.unregister(User)
|
||||
admin.site.register(User,UserAdmin)
|
||||
|
||||
@@ -44,7 +44,7 @@ else:
|
||||
)
|
||||
|
||||
|
||||
from rowers.models import Rower,PaidPlan
|
||||
from rowers.models import Rower,PaidPlan, CoachingGroup
|
||||
from rowers.utils import ProcessorCustomerError
|
||||
|
||||
def create_customer(rower,force=False):
|
||||
@@ -154,6 +154,7 @@ def update_subscription(rower,data,method='up'):
|
||||
return False,0
|
||||
|
||||
if result.is_success:
|
||||
yesterday = (timezone.now()-datetime.timedelta(days=1)).date()
|
||||
rower.paidplan = plan
|
||||
rower.planexpires = result.subscription.billing_period_end_date
|
||||
rower.teamplanexpires = result.subscription.billing_period_end_date
|
||||
@@ -161,12 +162,27 @@ def update_subscription(rower,data,method='up'):
|
||||
rower.paymenttype = plan.paymenttype
|
||||
rower.rowerplan = plan.shortname
|
||||
rower.subscription_id = result.subscription.id
|
||||
rower.protrialexpires = yesterday
|
||||
rower.plantrialexpires = yesterday
|
||||
rower.save()
|
||||
name = '{f} {l}'.format(
|
||||
f = rower.user.first_name,
|
||||
l = rower.user.last_name,
|
||||
)
|
||||
|
||||
if rower.paidplan != 'coach':
|
||||
try:
|
||||
coachgroup = coach.mycoachgroup
|
||||
except CoachingGroup.DoesNotExist:
|
||||
coachgroup = CoachingGroup()
|
||||
coachgroup.save()
|
||||
rower.mycoachgroup = coachgroup
|
||||
rower.save()
|
||||
|
||||
athletes = Rower.objects.filter(coachinggroups__in=[rower.mycoachgroup]).distinct()
|
||||
for athlete in athletes:
|
||||
athlete.coachinggroups.remove(rower.mycoachgroup)
|
||||
|
||||
if method == 'up':
|
||||
transactions = result.subscription.transactions
|
||||
|
||||
|
||||
+20
-17
@@ -692,10 +692,12 @@ def runcpupdate(
|
||||
|
||||
theids = [w.id for w in theworkouts]
|
||||
|
||||
if settings.DEBUG:
|
||||
job = handle_updatecp.delay(rower.id,theids,debug=True,table=table)
|
||||
else:
|
||||
job = queue.enqueue(handle_updatecp,rower.id,theids,table=table)
|
||||
job = myqueue(
|
||||
queue,
|
||||
handle_updatecp,
|
||||
rower.id,
|
||||
theids,
|
||||
table=table)
|
||||
|
||||
return job
|
||||
|
||||
@@ -704,10 +706,11 @@ def fetchcperg(rower,theworkouts):
|
||||
thefilenames = [w.csvfilename for w in theworkouts]
|
||||
cpdf = getcpdata_sql(rower.id,table='ergcpdata')
|
||||
|
||||
if settings.DEBUG:
|
||||
res = handle_updateergcp.delay(rower.id,thefilenames,debug=True)
|
||||
else:
|
||||
res = queue.enqueue(handle_updateergcp,rower.id,thefilenames)
|
||||
job = myqueue(
|
||||
queue,
|
||||
handle_updateergcp,
|
||||
rower.id,
|
||||
thefilenames)
|
||||
|
||||
return cpdf
|
||||
|
||||
@@ -738,10 +741,12 @@ def fetchcp(rower,theworkouts,table='cpdata'):
|
||||
if not cpdf.empty:
|
||||
return cpdf['delta'],cpdf['cp'],avgpower2
|
||||
else:
|
||||
if settings.DEBUG:
|
||||
res = handle_updatecp.delay(rower.id,theids,debug=True,table=table)
|
||||
else:
|
||||
res = queue.enqueue(handle_updatecp,rower.id,theids,table=table)
|
||||
job = myqueue(queue,
|
||||
handle_updatecp,
|
||||
rower.id,
|
||||
theids,
|
||||
table=table)
|
||||
|
||||
return [],[],avgpower2
|
||||
|
||||
|
||||
@@ -1315,13 +1320,11 @@ def new_workout_from_file(r, f2,
|
||||
message = "We couldn't recognize the file type"
|
||||
f4 = f2[:-5]+'a'+f2[-5:]
|
||||
copyfile(f2,f4)
|
||||
if settings.DEBUG:
|
||||
res = handle_sendemail_unrecognized.delay(f4,
|
||||
job = myqueue(queuehigh,
|
||||
handle_sendemail_unrecognized,
|
||||
f4,
|
||||
r.user.email)
|
||||
|
||||
else:
|
||||
res = queuehigh.enqueue(handle_sendemail_unrecognized,
|
||||
f4, r.user.email)
|
||||
return (0, message, f2)
|
||||
|
||||
# handle non-Painsled by converting it to painsled compatible CSV
|
||||
|
||||
+2
-2
@@ -752,7 +752,7 @@ class PlanSelectForm(forms.Form):
|
||||
).exclude(
|
||||
shortname="basic"
|
||||
).order_by(
|
||||
"price","clubsize","shortname"
|
||||
"price","shortname"
|
||||
)
|
||||
if rower and not includeall:
|
||||
try:
|
||||
@@ -765,7 +765,7 @@ class PlanSelectForm(forms.Form):
|
||||
).exclude(
|
||||
price__lte=amount
|
||||
).order_by(
|
||||
"price","clubsize","shortname"
|
||||
"price","shortname"
|
||||
)
|
||||
|
||||
|
||||
|
||||
+111
-19
@@ -30,7 +30,7 @@ from django.utils import timezone
|
||||
import pandas as pd
|
||||
from dateutil import parser
|
||||
import datetime
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from rowers.rows import validate_file_extension
|
||||
from collections import OrderedDict
|
||||
from timezonefinder import TimezoneFinder
|
||||
@@ -313,6 +313,13 @@ class C2WorldClassAgePerformance(models.Model):
|
||||
|
||||
return thestring
|
||||
|
||||
def is_not_basic(user):
|
||||
if user.rower.rowerplan == 'basic':
|
||||
raise ValidationError(
|
||||
"Basic user cannot be team manager"
|
||||
)
|
||||
|
||||
|
||||
# For future Team functionality
|
||||
class Team(models.Model):
|
||||
choices = (
|
||||
@@ -327,15 +334,34 @@ class Team(models.Model):
|
||||
|
||||
name = models.CharField(max_length=150,unique=True,verbose_name='Team Name')
|
||||
notes = models.CharField(blank=True,max_length=200,verbose_name='Team Purpose')
|
||||
manager = models.ForeignKey(User, null=True)
|
||||
manager = models.ForeignKey(User, null=True,) # validators=[is_not_basic])
|
||||
private = models.CharField(max_length=30,choices=choices,default='open',
|
||||
verbose_name='Team Type')
|
||||
|
||||
viewing = models.CharField(max_length=30,choices=viewchoices,default='allmembers',verbose_name='Sharing Behavior')
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
manager = self.manager
|
||||
if manager.rower.rowerplan == 'basic':
|
||||
if manager.rower.protrialexpires < datetime.date.today() and manager.rower.plantrialexpires < datetime.date.today():
|
||||
raise ValidationError(
|
||||
"Basic user cannot be team manager"
|
||||
)
|
||||
|
||||
if manager.rower.rowerplan in ['plan','pro']:
|
||||
otherteams = Team.objects.filter(manager=manager)
|
||||
if len(otherteams) >= 1:
|
||||
raise ValidationError(
|
||||
"Pro and Self-Coach users cannot have more than one team"
|
||||
)
|
||||
|
||||
super(Team, self).save(*args,**kwargs)
|
||||
|
||||
|
||||
class TeamForm(ModelForm):
|
||||
class Meta:
|
||||
model = Team
|
||||
@@ -361,7 +387,6 @@ class TeamInviteForm(ModelForm):
|
||||
|
||||
|
||||
|
||||
|
||||
class TeamRequest(models.Model):
|
||||
team = models.ForeignKey(Team)
|
||||
user = models.ForeignKey(User,null=True)
|
||||
@@ -607,6 +632,14 @@ class PaidPlan(models.Model):
|
||||
paymentprocessor = self.paymentprocessor,
|
||||
)
|
||||
|
||||
class CoachingGroup(models.Model):
|
||||
name = models.CharField(default='group',max_length=30,null=True,blank=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return 'Coaching Group {id}: {name}'.format(
|
||||
id = self.pk,
|
||||
name = self.name
|
||||
)
|
||||
|
||||
# Extension of User with rowing specific data
|
||||
class Rower(models.Model):
|
||||
@@ -671,8 +704,8 @@ class Rower(models.Model):
|
||||
planexpires = models.DateField(default=current_day)
|
||||
teamplanexpires = models.DateField(default=current_day)
|
||||
clubsize = models.IntegerField(default=0)
|
||||
protrialexpires = models.DateField(blank=True,null=True)
|
||||
plantrialexpires = models.DateField(blank=True,null=True)
|
||||
protrialexpires = models.DateField(default=datetime.date(1970,1,1))
|
||||
plantrialexpires = models.DateField(default=datetime.date(1970,1,1))
|
||||
|
||||
|
||||
# Privacy Data
|
||||
@@ -806,6 +839,8 @@ class Rower(models.Model):
|
||||
|
||||
# Friends/Team
|
||||
friends = models.ManyToManyField("self",blank=True)
|
||||
mycoachgroup = models.ForeignKey(CoachingGroup,related_name='coachingrole',null=True)
|
||||
coachinggroups = models.ManyToManyField(CoachingGroup,related_name='coaches')
|
||||
privacy = models.CharField(default='visible',max_length=30,
|
||||
choices=privacychoices)
|
||||
|
||||
@@ -829,6 +864,7 @@ class Rower(models.Model):
|
||||
def clean_email(self):
|
||||
return self.user.email.lower()
|
||||
|
||||
|
||||
class DeactivateUserForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = User
|
||||
@@ -842,12 +878,44 @@ class DeleteUserForm(forms.ModelForm):
|
||||
model = User
|
||||
fields = []
|
||||
|
||||
@receiver(models.signals.post_save,sender=Rower)
|
||||
def auto_delete_teams_on_change(sender, instance, **kwargs):
|
||||
if instance.rowerplan != 'coach':
|
||||
teams = Team.objects.filter(manager=instance.user)
|
||||
for team in teams:
|
||||
team.delete()
|
||||
# requestor is user
|
||||
class CoachRequest(models.Model):
|
||||
coach = models.ForeignKey(Rower)
|
||||
user = models.ForeignKey(User,null=True)
|
||||
issuedate = models.DateField(default=current_day)
|
||||
code = models.CharField(max_length=150,unique=True)
|
||||
|
||||
# requestor is coach
|
||||
class CoachOffer(models.Model):
|
||||
coach = models.ForeignKey(Rower)
|
||||
user = models.ForeignKey(User,null=True)
|
||||
issuedate = models.DateField(default=current_day)
|
||||
code = models.CharField(max_length=150,unique=True)
|
||||
|
||||
from django.db.models.signals import m2m_changed
|
||||
|
||||
def check_teams_on_change(sender, **kwargs):
|
||||
instance = kwargs.pop('instance', None)
|
||||
action = kwargs.pop('action', None)
|
||||
pk_set = kwargs.pop('pk_set',None)
|
||||
if action == 'pre_add' and instance.rowerplan=='basic':
|
||||
if instance.protrialexpires < datetime.date.today() and instance.plantrialexpires < datetime.date.today():
|
||||
for id in pk_set:
|
||||
team = Team.objects.get(id=id)
|
||||
if team.manager.rower.rowerplan not in ['coach']:
|
||||
raise ValidationError(
|
||||
"You cannot join a team led by a Pro or Self-Coach user"
|
||||
)
|
||||
|
||||
m2m_changed.connect(check_teams_on_change, sender=Rower.team.through)
|
||||
|
||||
|
||||
#@receiver(models.signals.post_save,sender=Rower)
|
||||
#def auto_delete_teams_on_change(sender, instance, **kwargs):
|
||||
# if instance.rowerplan != 'coach':
|
||||
# teams = Team.objects.filter(manager=instance.user)
|
||||
# for team in teams:
|
||||
# team.delete()
|
||||
|
||||
from rowers.metrics import axlabels
|
||||
favchartlabelsx = axlabels.copy()
|
||||
@@ -941,12 +1009,14 @@ def checkworkoutuser(user,workout):
|
||||
return False
|
||||
try:
|
||||
r = Rower.objects.get(user=user)
|
||||
teams = workout.team.all()
|
||||
if workout.user == r:
|
||||
return True
|
||||
elif teams:
|
||||
for team in teams:
|
||||
if user == team.manager and workout.privacy == 'visible':
|
||||
coaches = []
|
||||
for group in workout.user.coachinggroups.all():
|
||||
coach = Rower.objects.get(mycoachgroup=group)
|
||||
coaches.append(coach)
|
||||
for coach in coaches:
|
||||
if user.rower == coach and workout.privacy == 'visible':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -958,12 +1028,14 @@ 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 = []
|
||||
for group in rower.coachinggroups.all():
|
||||
coach = Rower.objects.get(mycoachgroup=group)
|
||||
coaches.append(coach)
|
||||
for coach in coaches:
|
||||
if user.rower == coach:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -1134,6 +1206,12 @@ class TrainingPlan(models.Model):
|
||||
return stri
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
manager = self.manager
|
||||
if manager.rowerplan in ['basic','pro']:
|
||||
raise ValidationError(
|
||||
"Basic user cannot have a training plan"
|
||||
)
|
||||
|
||||
if self.enddate < self.startdate:
|
||||
startdate = self.startdate
|
||||
enddate = self.enddate
|
||||
@@ -1179,6 +1257,7 @@ class TrainingPlan(models.Model):
|
||||
else:
|
||||
createmacrofillers(self)
|
||||
|
||||
|
||||
class TrainingPlanForm(ModelForm):
|
||||
class Meta:
|
||||
model = TrainingPlan
|
||||
@@ -1549,6 +1628,8 @@ class TrainingMacroCycle(models.Model):
|
||||
else:
|
||||
createmesofillers(self)
|
||||
|
||||
|
||||
|
||||
class TrainingMacroCycleForm(ModelForm):
|
||||
class Meta:
|
||||
model = TrainingMacroCycle
|
||||
@@ -1634,6 +1715,7 @@ class TrainingMesoCycle(models.Model):
|
||||
else:
|
||||
createmicrofillers(self)
|
||||
|
||||
|
||||
class TrainingMicroCycle(models.Model):
|
||||
plan = models.ForeignKey(TrainingMesoCycle)
|
||||
name = models.CharField(max_length=150,blank=True)
|
||||
@@ -1849,6 +1931,15 @@ class PlannedSession(models.Model):
|
||||
if self.sessionvalue <= 0:
|
||||
self.sessionvalue = 1
|
||||
|
||||
manager = self.manager
|
||||
if self.sessiontype not in ['race','indoorrace']:
|
||||
if manager.rower.rowerplan in ['basic','pro']:
|
||||
if manager.rower.plantrialexpires < timezone.now().date():
|
||||
raise ValidationError(
|
||||
"You must be a Self-Coach user or higher to create a planned session"
|
||||
)
|
||||
|
||||
|
||||
# sort units
|
||||
if self.sessionmode == 'distance':
|
||||
if self.sessionunit not in ['m','km']:
|
||||
@@ -3368,3 +3459,4 @@ class PlannedSessionCommentForm(ModelForm):
|
||||
'comment': forms.Textarea,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1699,6 +1699,57 @@ def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename,
|
||||
|
||||
# Team related remote tasks
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_coachrequest(email,name,code,coachname,
|
||||
debug=False,**kwargs):
|
||||
|
||||
fullemail = email
|
||||
subject = 'Invitation to add {n} to your athletes'.format(n=name)
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
siteurl = SITE_URL
|
||||
if debug:
|
||||
siteurl = SITE_URL_DEV
|
||||
|
||||
d = {
|
||||
'name':name,
|
||||
'coach':coachname,
|
||||
'code':code,
|
||||
'siteurl':siteurl
|
||||
}
|
||||
|
||||
form_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
res = send_template_email(from_email,[fullemail],
|
||||
subject,'coachrequestemail.html',d,
|
||||
**kwargs)
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_coacheerequest(email,name,code,coachname,
|
||||
debug=False,**kwargs):
|
||||
|
||||
fullemail = email
|
||||
subject = '{n} asks coach access to your data on rowsandall.com'.format(n=coachname)
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
siteurl = SITE_URL
|
||||
if debug:
|
||||
siteurl = SITE_URL_DEV
|
||||
|
||||
d = {
|
||||
'name':name,
|
||||
'coach':coachname,
|
||||
'code':code,
|
||||
'siteurl':siteurl
|
||||
}
|
||||
|
||||
form_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
res = send_template_email(from_email,[fullemail],
|
||||
subject,'coacheerequestemail.html',d,
|
||||
**kwargs)
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_invite(email, name, code, teamname, manager,
|
||||
|
||||
+232
-18
@@ -17,7 +17,8 @@ queuelow = django_rq.get_queue('low')
|
||||
queuehigh = django_rq.get_queue('low')
|
||||
|
||||
from rowers.models import (
|
||||
Rower, Workout, Team, TeamInvite,User,TeamRequest
|
||||
Rower, Workout, Team, TeamInvite,User,TeamRequest, CoachRequest, CoachOffer,
|
||||
CoachingGroup
|
||||
)
|
||||
|
||||
from rowers.tasks import (
|
||||
@@ -26,8 +27,11 @@ from rowers.tasks import (
|
||||
handle_sendemail_member_dropped,handle_sendemail_request_accept,
|
||||
handle_sendemail_request_reject,handle_sendemail_invite_reject,
|
||||
handle_sendemail_invite_accept,handle_sendemail_team_removed,
|
||||
handle_sendemail_coachrequest,handle_sendemail_coacheerequest,
|
||||
)
|
||||
|
||||
from rowers.models import ValidationError
|
||||
|
||||
# Low level functions - to be called by higher level methods
|
||||
|
||||
inviteduration = 14 # days
|
||||
@@ -61,6 +65,14 @@ def update_team(t,name,manager,private,notes,viewing):
|
||||
|
||||
def create_team(name,manager,private='open',notes='',viewing='allmembers'):
|
||||
# needs some error testing
|
||||
if manager.rower.rowerplan == 'basic':
|
||||
if manager.rower.protrialexpires < timezone.now().date() and manager.rower.plantrialexpires < timezone.now().date():
|
||||
return (0,'You need to upgrade to a paid plan to establish a team')
|
||||
if manager.rower.rowerplan != 'coach':
|
||||
ts = Team.objects.filter(manager=manager)
|
||||
if len(ts)>=1:
|
||||
return (0,'You need to upgrade to the Coach plan to have more than one team')
|
||||
|
||||
try:
|
||||
t = Team(name=name,manager=manager,notes=notes,
|
||||
private=private,viewing=viewing)
|
||||
@@ -77,29 +89,47 @@ def remove_team(id):
|
||||
send_team_delete_mail(t,r)
|
||||
return t.delete()
|
||||
|
||||
def set_teamplanexpires(rower):
|
||||
ts = Team.objects.filter(rower=rower)
|
||||
#def set_teamplanexpires(rower):
|
||||
# ts = Team.objects.filter(rower=rower)
|
||||
|
||||
texp = datetime.date(timezone.now())
|
||||
# texp = datetime.date(timezone.now())
|
||||
|
||||
for t in ts:
|
||||
mr = Rower.objects.get(user=t.manager)
|
||||
if mr.teamplanexpires > texp:
|
||||
rower.teamplanexpires = mr.teamplanexpires
|
||||
# for t in ts:
|
||||
# print t.name
|
||||
# mr = Rower.objects.get(user=t.manager)
|
||||
# if mr.teamplanexpires > texp:
|
||||
# rower.teamplanexpires = mr.teamplanexpires
|
||||
|
||||
t.save()
|
||||
# t.save()
|
||||
|
||||
return (1,'Updated rower team expiry')
|
||||
|
||||
def add_coach(coach,rower):
|
||||
# get coaching group
|
||||
coachgroup = coach.mycoachgroup
|
||||
if coachgroup is None:
|
||||
coachgroup = CoachingGroup(name=coach.user.first_name)
|
||||
coachgroup.save()
|
||||
coach.mycoachgroup = coachgroup
|
||||
coach.save()
|
||||
|
||||
rower.coachinggroups.add(coach.mycoachgroup)
|
||||
|
||||
return (1,"Added Coach")
|
||||
|
||||
def add_member(id,rower):
|
||||
t= Team.objects.get(id=id)
|
||||
try:
|
||||
rower.team.add(t)
|
||||
except ValidationError:
|
||||
return(0,"Couldn't add member")
|
||||
|
||||
# code to add all workouts
|
||||
ws = Workout.objects.filter(user=rower)
|
||||
|
||||
res = handle_add_workouts_team(ws,t)
|
||||
|
||||
set_teamplanexpires(rower)
|
||||
# set_teamplanexpires(rower)
|
||||
|
||||
return (id,'Member added')
|
||||
|
||||
@@ -111,9 +141,47 @@ def remove_member(id,rower):
|
||||
|
||||
res = handle_remove_workouts_team(ws,t)
|
||||
|
||||
set_teamplanexpires(rower)
|
||||
# set_teamplanexpires(rower)
|
||||
return (id,'Member removed')
|
||||
|
||||
def remove_coach(coach,rower):
|
||||
try:
|
||||
coachgroup = coach.mycoachgroup
|
||||
except CoachingGroup.DoesNotExist:
|
||||
coachgroup = CoachingGroup()
|
||||
coachgroup.save()
|
||||
coach.mycoachgroup = coachgroup
|
||||
coach.save()
|
||||
|
||||
rower.coachinggroups.remove(coachgroup)
|
||||
|
||||
return (1,'Coach removed')
|
||||
|
||||
def rower_get_coaches(rower):
|
||||
coaches = []
|
||||
for group in rower.coachinggroups.all():
|
||||
coach = Rower.objects.get(mycoachgroup=group)
|
||||
coaches.append(coach)
|
||||
|
||||
return coaches
|
||||
|
||||
|
||||
def coach_getcoachees(coach):
|
||||
return Rower.objects.filter(coachinggroups__in=[coach.mycoachgroup]).distinct()
|
||||
|
||||
def coach_remove_athlete(coach,rower):
|
||||
try:
|
||||
coachgroup = coach.mycoachgroup
|
||||
except CoachingGroup.DoesNotExist:
|
||||
coachgroup = CoachingGroup()
|
||||
coachgroup.save()
|
||||
coach.mycoachgroup = coachgroup
|
||||
coach.save()
|
||||
|
||||
rower.coachinggroups.remove(coachgroup)
|
||||
|
||||
return (1,'Coach removed')
|
||||
|
||||
def mgr_remove_member(id,manager,rower):
|
||||
t = Team.objects.get(id=id)
|
||||
if t.manager == manager:
|
||||
@@ -141,13 +209,58 @@ def count_club_members(manager):
|
||||
|
||||
# Medium level functionality
|
||||
|
||||
# request by user to be coached by coach
|
||||
def create_coaching_request(coach,user):
|
||||
if coach in rower_get_coaches(user.rower):
|
||||
return (0,'Already coached by that coach')
|
||||
|
||||
codes = [i.code for i in CoachRequest.objects.all()]
|
||||
code = uuid.uuid4().hex[:10].upper()
|
||||
while code in codes:
|
||||
code = uuid.uuid4().hex[:10].upper()
|
||||
|
||||
if coach.rowerplan == 'coach':
|
||||
rekwest = CoachRequest(coach=coach,user=user,code=code)
|
||||
rekwest.save()
|
||||
|
||||
send_coachrequest_email(rekwest)
|
||||
|
||||
return (rekwest.id,'The request was created')
|
||||
|
||||
else:
|
||||
return (0,'That person is not a coach')
|
||||
|
||||
def send_coachrequest_email(rekwest):
|
||||
name = rekwest.user.first_name + " " + rekwest.user.last_name
|
||||
email = rekwest.user.email
|
||||
|
||||
code = rekwest.code
|
||||
|
||||
coachname = rekwest.coach.user.first_name + " " + rekwest.coach.user.last_name
|
||||
|
||||
res = myqueue(queuehigh,
|
||||
handle_sendemail_coachrequest,
|
||||
email,name,code,coachname)
|
||||
|
||||
def send_coacheerequest_email(rekwest):
|
||||
name = rekwest.user.first_name + " " + rekwest.user.last_name
|
||||
email = rekwest.user.email
|
||||
|
||||
code = rekwest.code
|
||||
|
||||
coachname = rekwest.coach.user.first_name + " " + rekwest.coach.user.last_name
|
||||
|
||||
res = myqueue(queuehigh,
|
||||
handle_sendemail_coacheerequest,
|
||||
email,name,code,coachname)
|
||||
|
||||
def create_request(team,user):
|
||||
r2 = Rower.objects.get(user=user)
|
||||
r = Rower.objects.get(user=team.manager)
|
||||
if r2 in Rower.objects.filter(team=team):
|
||||
return (0,'Already a member of that team')
|
||||
|
||||
if count_club_members(team.manager)+count_invites(team.manager) <= r.clubsize:
|
||||
# if count_club_members(team.manager)+count_invites(team.manager) <= r.clubsize:
|
||||
codes = [i.code for i in TeamRequest.objects.all()]
|
||||
code = uuid.uuid4().hex[:10].upper()
|
||||
# prevent duplicates
|
||||
@@ -161,11 +274,35 @@ def create_request(team,user):
|
||||
send_request_email(rekwest)
|
||||
|
||||
return (rekwest.id,'The request was created')
|
||||
else:
|
||||
return (0,'That team has reached its maximum number of members')
|
||||
|
||||
return (0,'Something went wrong in create_request')
|
||||
|
||||
# request by coach to coach user
|
||||
def create_coaching_offer(coach,user):
|
||||
r = user.rower
|
||||
|
||||
if coach in rower_get_coaches(user.rower):
|
||||
return (0,'You are already coaching this person.')
|
||||
|
||||
codes = [i.code for i in CoachOffer.objects.all()]
|
||||
code = uuid.uuid4().hex[:10].upper()
|
||||
while code in codes:
|
||||
code = uuid.uuid4().hex[:10].upper()
|
||||
|
||||
if coach.rowerplan == 'coach':
|
||||
rekwest = CoachOffer(coach=coach,user=user,code=code)
|
||||
rekwest.save()
|
||||
|
||||
send_coacheerequest_email(rekwest)
|
||||
|
||||
return (rekwest.id,'The request was created')
|
||||
|
||||
else:
|
||||
return (0,'You are not a coach')
|
||||
|
||||
|
||||
|
||||
|
||||
def create_invite(team,manager,user=None,email=''):
|
||||
r = Rower.objects.get(user=manager)
|
||||
if team.manager != manager:
|
||||
@@ -189,7 +326,7 @@ def create_invite(team,manager,user=None,email=''):
|
||||
except Rower.MultipleObjectsReturned:
|
||||
return (0,'There is more than one user with that email address')
|
||||
|
||||
if count_club_members(team.manager)+count_invites(team.manager) <= r.clubsize:
|
||||
# if count_club_members(team.manager)+count_invites(team.manager) <= r.clubsize:
|
||||
codes = [i.code for i in TeamInvite.objects.all()]
|
||||
code = uuid.uuid4().hex[:10].upper()
|
||||
# prevent duplicates
|
||||
@@ -201,9 +338,6 @@ def create_invite(team,manager,user=None,email=''):
|
||||
return (invite.id,'Invitation created')
|
||||
|
||||
|
||||
else:
|
||||
return (0,'You are at your club size limit')
|
||||
|
||||
return (0,'Nothing done')
|
||||
|
||||
def revoke_request(user,id):
|
||||
@@ -220,6 +354,36 @@ def revoke_request(user,id):
|
||||
else:
|
||||
return (0,'You are not the requestor')
|
||||
|
||||
def reject_revoke_coach_offer(user,id):
|
||||
try:
|
||||
rekwest = CoachOffer.objects.get(id=id)
|
||||
except CoachOffer.DoesNotExist:
|
||||
return (0,'The request is invalid')
|
||||
|
||||
if rekwest.coach.user == user:
|
||||
rekwest.delete()
|
||||
return (1,'Request removed')
|
||||
elif rekwest.user == user:
|
||||
rekwest.delete()
|
||||
return (1,'Request removed')
|
||||
else:
|
||||
return (0,'Not permitted')
|
||||
|
||||
def reject_revoke_coach_request(user,id):
|
||||
try:
|
||||
rekwest = CoachRequest.objects.get(id=id)
|
||||
except CoachRequest.DoesNotExist:
|
||||
return (0,'The request is invalid')
|
||||
|
||||
if rekwest.coach.user == user:
|
||||
rekwest.delete()
|
||||
return (1,'Request rejected')
|
||||
elif rekwest.user == user:
|
||||
rekwest.delete()
|
||||
return (1,'Request rejected')
|
||||
else:
|
||||
return (0,'Not permitted')
|
||||
|
||||
def revoke_invite(manager,id):
|
||||
try:
|
||||
invite = TeamInvite.objects.get(id=id)
|
||||
@@ -402,7 +566,13 @@ def process_request_code(manager,code):
|
||||
return (0,'You are not the manager of this team')
|
||||
|
||||
result = add_member(t.id,r)
|
||||
if not result:
|
||||
return (result,"The member couldn't be added")
|
||||
|
||||
|
||||
send_request_accept_email(rekwest)
|
||||
|
||||
|
||||
rekwest.delete()
|
||||
return result
|
||||
|
||||
@@ -421,6 +591,10 @@ def process_invite_code(user,code):
|
||||
|
||||
t = invitation.team
|
||||
result = add_member(t.id,r)
|
||||
if not result:
|
||||
return (result,"The member couldn't be added")
|
||||
|
||||
|
||||
send_invite_accept_email(invitation)
|
||||
invitation.delete()
|
||||
return result
|
||||
@@ -433,3 +607,43 @@ def remove_expired_invites():
|
||||
revoke_invite(i.team.manager,i.id)
|
||||
|
||||
return (1,'Expired invitations deleted')
|
||||
|
||||
def process_coachrequest_code(coach,code):
|
||||
code = code.upper()
|
||||
|
||||
try:
|
||||
rekwest = CoachRequest.objects.get(code=code)
|
||||
except CoachRequest.DoesNotExist:
|
||||
return (0,'The request has been revoked or is invalid')
|
||||
|
||||
if rekwest.coach != coach:
|
||||
return (0,'The request is invalid')
|
||||
|
||||
result = add_coach(coach,rekwest.user.rower)
|
||||
if not result:
|
||||
return (result,"Something went wrong")
|
||||
|
||||
rekwest.delete()
|
||||
|
||||
return result
|
||||
|
||||
def process_coachoffer_code(user,code):
|
||||
code = code.upper()
|
||||
|
||||
try:
|
||||
rekwest = CoachOffer.objects.get(code=code)
|
||||
except CoachOffer.DoesNotExist:
|
||||
return (0,'The request has been revoked or is invalid')
|
||||
|
||||
if rekwest.user != user:
|
||||
return (0,'The request is invalid')
|
||||
|
||||
result = add_coach(rekwest.coach,rekwest.user.rower)
|
||||
if not result:
|
||||
return (result,"Something went wrong")
|
||||
|
||||
rekwest.delete()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{% extends "emailbase.html" %}
|
||||
|
||||
{% block body %}
|
||||
<p>Dear <strong>{{ name }}</strong>,</p>
|
||||
|
||||
<p>
|
||||
{{ coachname }} is offering to become your coach on rowsandall.com.
|
||||
</p>
|
||||
<p>
|
||||
By accepting the invite, {{ coachname }} will have access to your
|
||||
data and will be able to upload workouts and run analysis on rowsandall.com
|
||||
on behalf of you.
|
||||
</p>
|
||||
<p>
|
||||
By accepting the invite, you are agreeing with the sharing
|
||||
of personal data according to our privacy policy.
|
||||
</p>
|
||||
<p>
|
||||
To accept, login to the
|
||||
site and you will find the invitation here on the Teams page:
|
||||
<a href="{{ siteurl }}/rowers/me/teams">{{ siteurl }}/rowers/me/teams</a>
|
||||
</p>
|
||||
<p>
|
||||
You can also click the direct link:
|
||||
<a href="{{ siteurl }}/rowers/me/coachoffer/{{ code }}/accept/">
|
||||
{{ siteurl }}/rowers/me/coachoffer/{{ code }}/accept</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Best Regards, the Rowsandall Team
|
||||
</p>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,33 @@
|
||||
{% extends "emailbase.html" %}
|
||||
|
||||
{% block body %}
|
||||
<p>Dear <strong>{{ coachname }}</strong>,</p>
|
||||
|
||||
<p>
|
||||
{{ name }} is inviting you to become his/her coach
|
||||
on rowsandall.com
|
||||
</p>
|
||||
<p>
|
||||
By accepting the invite, you will have access to {{ name }}'s
|
||||
data and will be able to upload workouts and run analysis on rowsandall.com
|
||||
on behalf of {{ name }}.
|
||||
</p>
|
||||
<p>
|
||||
By accepting the invite, you are agreeing with the sharing
|
||||
of personal data according to our privacy policy.
|
||||
</p>
|
||||
<p>
|
||||
To accept the login to the
|
||||
site and you will find the invitation here on the Teams page:
|
||||
<a href="{{ siteurl }}/rowers/me/teams">{{ siteurl }}/rowers/me/teams</a>
|
||||
</p>
|
||||
<p>
|
||||
You can also click the direct link:
|
||||
<a href="{{ siteurl }}/rowers/me/coachrequest/{{ code }}/accept/">
|
||||
{{ siteurl }}/rowers/me/coachrequest/{{ code }}/accept/</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Best Regards, the Rowsandall Team
|
||||
</p>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,33 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Remove Athlete {% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<h1>Confirm removing {{ athlete.user.first_name }} {{ athlete.user.last_name }}</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<p>This will remove this rower from your list of athlete. The athlete can still
|
||||
be in one of your training groups, but you cannot upload workouts, run analysis
|
||||
or edit settings on their behalf.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<a class="button green small" href="/rowers/me/teams">Cancel</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a class="button red small" href="/rowers/coaches/{{ athlete.id }}/drop">Drop Athlete</a>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_teams.html' %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,35 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Remove Coach {% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<h1>Confirm removing {{ coach.user.first_name }} {{ coach.user.last_name }}</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_2">
|
||||
<p>This will remove this coach from your list of coaches.
|
||||
You can still be in this coach's training groups, but she/he is losing the ability to
|
||||
upload workouts for you, run analysis
|
||||
or edit your settings on your behalf.
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<a class="button green small" href="/rowers/me/teams">Cancel</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a class="button red small" href="/rowers/coaches/{{ coach.id }}/dropcoach">Drop Coach
|
||||
</a>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_teams.html' %}
|
||||
{% endblock %}
|
||||
@@ -71,21 +71,21 @@
|
||||
{% if user.is_authenticated and user|is_manager %}
|
||||
<p> </p>
|
||||
|
||||
{% if user|team_members %}
|
||||
{% if user|coach_rowers %}
|
||||
<ul class="cd-accordion-menu animated">
|
||||
<li class="has-children" id="athletes">
|
||||
<input type="checkbox" name="athlete-selector" id="athlete-selector">
|
||||
<label for="athlete-selector"><i class="fas fa-users fa-fw"></i> Athletes</label>
|
||||
<ul>
|
||||
{% for member in user|team_members %}
|
||||
<a href={{ request.path|userurl:member }}>
|
||||
{% for member in user|coach_rowers %}
|
||||
<a href={{ request.path|userurl:member.user }}>
|
||||
<i class="fas fa-user fa-fw"></i>
|
||||
{% if member == rower.user %}
|
||||
{% if member.user == rower.user %}
|
||||
•
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{{ member.first_name }} {{ member.last_name }}
|
||||
{{ member.user.first_name }} {{ member.user.last_name }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -87,21 +87,21 @@
|
||||
{% if user.is_authenticated and user|is_manager %}
|
||||
<p> </p>
|
||||
|
||||
{% if user|team_members %}
|
||||
{% if user|coach_rowers %}
|
||||
<ul class="cd-accordion-menu animated">
|
||||
<li class="has-children" id="athletes">
|
||||
<input type="checkbox" name="athlete-selector" id="athlete-selector">
|
||||
<label for="athlete-selector"><i class="fas fa-users fa-fw"></i> Athletes</label>
|
||||
<ul>
|
||||
{% for member in user|team_members %}
|
||||
<a href={{ request.path|userurl:member }}?when={{ timeperiod }}>
|
||||
{% for member in user|coach_rowers %}
|
||||
<a href={{ request.path|userurl:member.user }}?when={{ timeperiod }}>
|
||||
<i class="fas fa-user fa-fw"></i>
|
||||
{% if member == rower.user %}
|
||||
{% if member.user == rower.user %}
|
||||
•
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{{ member.first_name }} {{ member.last_name }}
|
||||
{{ member.user.first_name }} {{ member.user.last_name }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -39,21 +39,21 @@
|
||||
|
||||
{% if user.is_authenticated and user|is_manager %}
|
||||
<p> </p>
|
||||
{% if user|team_members %}
|
||||
{% if user|coach_rowers %}
|
||||
<ul class="cd-accordion-menu animated">
|
||||
<li class="has-children" id="athletes">
|
||||
<input type="checkbox" name="athlete-selector" id="athlete-selector">
|
||||
<label for="athlete-selector"><i class="fas fa-users fa-fw"></i> Athletes</label>
|
||||
<ul>
|
||||
{% for member in user|team_members %}
|
||||
<a href={{ request.path|userurl:member }}>
|
||||
{% for member in user|coach_rowers %}
|
||||
<a href={{ request.path|userurl:member.user }}>
|
||||
<i class="fas fa-user fa-fw"></i>
|
||||
{% if member == rower.user %}
|
||||
{% if member.user == rower.user %}
|
||||
•
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{{ member.first_name }} {{ member.last_name }}
|
||||
{{ member.user.first_name }} {{ member.user.last_name }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
<i class="fas fa-cog fa-fw"></i> Overview
|
||||
</a>
|
||||
</li>
|
||||
{% if user|is_manager %}
|
||||
<li id="create">
|
||||
<a href="/rowers/team/create/">
|
||||
<i class="fas fa-plus fa-fw"></i> New Team
|
||||
<i class="fas fa-plus fa-fw"></i> New Training Group
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul><!-- cd-accordion-menu -->
|
||||
|
||||
|
||||
|
||||
@@ -47,22 +47,22 @@
|
||||
|
||||
{% if user.is_authenticated and user|is_manager %}
|
||||
<p> </p>
|
||||
{% if user|team_members %}
|
||||
{% if user|coach_rowers %}
|
||||
<ul class="cd-accordion-menu animated">
|
||||
<li class="has-children" id="athletes">
|
||||
<input type="checkbox" name="athlete-selector" id="athlete-selector">
|
||||
<label for="athlete-selector"><i class="fas fa-users fa-fw"></i> Athletes</label>
|
||||
<ul>
|
||||
{% for member in user|team_members %}
|
||||
{% for member in user|coach_rowers %}
|
||||
<li>
|
||||
<a href={{ request.path|userurl:member }}>
|
||||
<a href={{ request.path|userurl:member.user }}>
|
||||
<i class="fas fa-user fa-fw"></i>
|
||||
{% if member == rower.user and not team %}
|
||||
{% if member.user == rower.user and not team %}
|
||||
•
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
{{ member.first_name }} {{ member.last_name }}
|
||||
{{ member.user.first_name }} {{ member.user.last_name }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
@@ -77,7 +77,7 @@
|
||||
<ul class="cd-accordion-menu animated">
|
||||
<li class="has-children" id="teams">
|
||||
<input type="checkbox" name="team-selector" id="team-selector">
|
||||
<label for="team-selector"><i class="fas fa-bullhorn fa-fw"></i> Teams</label>
|
||||
<label for="team-selector"><i class="fas fa-bullhorn fa-fw"></i> Groups</label>
|
||||
<ul>
|
||||
{% for tteam in teams %}
|
||||
<li>
|
||||
|
||||
@@ -257,19 +257,6 @@
|
||||
{% endif %}
|
||||
</button>
|
||||
</td>
|
||||
{% elif rower and rower.rowerplan == 'coach' and rower.clubsize < 100 %}
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>
|
||||
<button style="width:100%">
|
||||
{% if user|existing_customer %}
|
||||
<a href="/rowers/upgrade/">UPGRADE NOW</a>
|
||||
{% else %}
|
||||
<a href="/rowers/billing/">BUY NOW</a>
|
||||
{% endif %}
|
||||
</button>
|
||||
</td>
|
||||
{% else %}
|
||||
<td colspan=3>
|
||||
|
||||
</td>
|
||||
|
||||
@@ -59,13 +59,13 @@
|
||||
other fitness sites. You can actually revoke these at any time.
|
||||
<li>User preferences as shown on the user settings page
|
||||
<li>Your favorite Flex Charts if defined
|
||||
<li>The teams you are a member of.
|
||||
<li>The teams or groups you are a member of.
|
||||
<li>Estimated four minute, 2k and 1 hour ergometer and OTW power values,
|
||||
based on the workouts you upload, and their evolution during your
|
||||
usage of the site
|
||||
<li>For members on the Coach plan, the names and purposes of teams. Names
|
||||
of team members. (Members who delete their account will be erased from
|
||||
existing teams.)
|
||||
<li>For members on the Coach plan, the names and purposes of teams or groups. Names
|
||||
of team or group members. (Members who delete their account will be erased from
|
||||
existing teams or groups.)
|
||||
<li>Any rowing courses you uploaded
|
||||
<li>Training targets and training plans
|
||||
<li>Your uploaded workouts, their names, boat type, start time and date,
|
||||
@@ -212,57 +212,62 @@
|
||||
</p>
|
||||
|
||||
|
||||
<h3>Team Functionality</h3>
|
||||
<h3>Team Or Group Functionality</h3>
|
||||
|
||||
<p>
|
||||
On rowsandall.com, users with the paid "Coach" plan can establish teams and invite other users to become part of the team. The purpose
|
||||
of a team is to share workout and training plan data between the coach and the team members. In terms of sharing behavior, there are two types of teams:
|
||||
On rowsandall.com, users with the paid "Coach" plan can establish teams or groups and invite other users to become part of the team or group. The purpose
|
||||
of a team or group is to share workout and training plan data between the coach and the team or group members. In terms of sharing behavior, there are two types of teams or groups:
|
||||
<ul>
|
||||
<li>"All Members" - This is the default team type. All members can see workouts of all other members, except those workouts that the members have
|
||||
<li>"All Members" - This is the default team or group type. All members can see workouts of all other members, except those workouts that the members have
|
||||
marked as "private".
|
||||
<li>"Coach Only" - With this setting, each individual team member is sharing his workout data only with the team manager. Other members cannot see
|
||||
<li>"Coach Only" - With this setting, each individual team or group member is sharing his workout data only with the team or group manager. Other members cannot see
|
||||
his workouts.
|
||||
</ul>
|
||||
The sharing behavior is chosen by the team member when he establishes the team and can be changed during the existence of the team.
|
||||
The sharing behavior is chosen by the team or group member when he establishes the team or group and can be changed during the existence of the team or group.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
By accepting an "invitation" to become a member of a team, or by requesting to become part of a team, you agree to automatically
|
||||
share all your workout data (including workouts done prior to becoming a member of the team) to the team manager (coach) and,
|
||||
depending to the team policy, to other members of the team. When you leave
|
||||
a team, all your workout data will immediately become invisible to those who had access to it during your team membership, including
|
||||
workouts that cover the period of time when you were member of the team. As a member of a team, you grant the team manager
|
||||
By accepting an "invitation" to become a member of a team or group, or by requesting to become part of a team or group, you agree to automatically
|
||||
share all your workout data (including workouts done prior to becoming a member of the team or group) to the team or group manager (coach) and,
|
||||
depending to the team or group policy, to other members of the team or group. When you leave
|
||||
a team or group, all your workout data will immediately become invisible to those who had access to it during your team or group membership, including
|
||||
workouts that cover the period of time when you were member of the team or group. As a member of a team or group, you may grant the team or group manager
|
||||
permission to edit workout data
|
||||
on your behalf, including the creation of charts and cross workout analysis. You also grant the team manager permission to
|
||||
on your behalf, including the creation of charts and cross workout analysis.
|
||||
This includes permission to
|
||||
edit your heart rate and power settings, as well as functional threshold information and the account information accessible on your
|
||||
settings page under the header "Account Information". The team manager is not able to access or change your passwords, team memberships,
|
||||
favorite charts, export settings, workflow layout, or secret tokens. Also, the team manager is not able to download all your data,
|
||||
settings page under the header "Account Information". The team or group manager is not able to access or change your passwords, team or group memberships,
|
||||
favorite charts, export settings, workflow layout, or secret tokens. Also, the team or group manager is not able to download all your data,
|
||||
nor can he deactivate or delete your account.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Each team member is bound by this privacy policy and the GDPR regulation of the European Union regarding the personal data of other team
|
||||
members that he has access to. By accepting an invitation to a team, the new member agrees to limit the use of these data strictly to the
|
||||
Each team or group member is bound by this privacy policy and the GDPR regulation of the European Union regarding the personal data of other team or group
|
||||
members that he has access to. By accepting an invitation to a team or group, the new member agrees to limit the use of these data strictly to the
|
||||
allowed use according to this privacy policy and the GDPR.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Team managers can access requests of users to be added to one of their teams. By accepting the invitation, the manager accepts the responsibilities
|
||||
and duties associated with access to personal data of the new team member. He is bound by this privacy policy and the GDPR regulation
|
||||
Team Or Group managers can access requests of users to be added to one of their teams or groups.
|
||||
He can request or receive permission to edit an athlete's data and run analysis on an
|
||||
athlete's behalf as described above.
|
||||
By requesting or receiving these permissions, the manager accepts the responsibilities
|
||||
and duties associated with access to personal data of the new team or group member.
|
||||
He is bound by this privacy policy and the GDPR regulation
|
||||
of the European Union regarding the personal data that he has access to.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
In case that a team manager wants to change the sharing behavior of one of his teams from "Coach Only" to "All Members", he has to inform all
|
||||
impacted team members in due time. He shall give team members a minimum of three days to decide whether they agree with the new sharing policy, and
|
||||
collect the consent of the team members with the new sharing policy. The team manager must remove team members who did not give their active consent
|
||||
to the new policy from his team. If a team member has not responded within 7 days of being notified, the team manager will understand this as "no consent"
|
||||
and remove the team member.
|
||||
In case that a team or group manager wants to change the sharing behavior of one of his teams or groups from "Coach Only" to "All Members", he has to inform all
|
||||
impacted team or group members in due time. He shall give team or group members a minimum of three days to decide whether they agree with the new sharing policy, and
|
||||
collect the consent of the team or group members with the new sharing policy. The team or group manager must remove team or group members who did not give their active consent
|
||||
to the new policy from his team or group. If a team or group member has not responded within 7 days of being notified, the team or group manager will understand this as "no consent"
|
||||
and remove the team or group member.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
When notified of a change in team sharing behavior by the team manager, the team member has to decide whether he agrees. In case of disagreement, he shall
|
||||
revoke his team membership within less than 7 days of being notified.
|
||||
When notified of a change in team or group sharing behavior by the team or group manager, the team or group member has to decide whether he agrees. In case of disagreement, he shall
|
||||
revoke his team or group membership within less than 7 days of being notified.
|
||||
</p>
|
||||
|
||||
<h3>Third Party Sharing</h3>
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
{% endif %}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
{% if rower.clubsize < 100 and rower.user == user %}
|
||||
{% if rower.rowerplan != 'coach' and rower.user == user %}
|
||||
<p>
|
||||
<a href="/rowers/paidplans/">Upgrade</a>
|
||||
</p>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
{% for member in members %}
|
||||
<tr>
|
||||
{% if team.manager == user %}
|
||||
<td><a href="/rowers/me/preferences/{{ member.id }}/"> {{ member.user.first_name }} {{ member.user.last_name }}</a></td>
|
||||
<td><a href="/rowers/me/preferences/user/{{ member.user.id }}/"> {{ member.user.first_name }} {{ member.user.last_name }}</a></td>
|
||||
<td><a class="button red small" href="/rowers/me/team/{{ team.id }}/drop/{{ member.user.id }}/">Drop</a></td>
|
||||
{% else %}
|
||||
<td>{{ member.user.first_name }} {{ member.user.last_name }}</td>
|
||||
|
||||
+192
-20
@@ -1,12 +1,12 @@
|
||||
{% extends "newbase.html" %}
|
||||
|
||||
{% block title %}Teams {% endblock %}
|
||||
{% block title %}Groups {% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<ul class="main-content">
|
||||
{% if teams %}
|
||||
<li >
|
||||
<h2>My Teams</h2>
|
||||
<li class="grid_2">
|
||||
<h2>My Groups</h2>
|
||||
<table width="100%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -31,8 +31,8 @@
|
||||
{% endif %}
|
||||
|
||||
{% if otherteams %}
|
||||
<li >
|
||||
<h2>Other Teams</h2>
|
||||
<li class="grid_2">
|
||||
<h2>Open Groups</h2>
|
||||
<table width="100%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -56,17 +56,14 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if user.rower.rowerplan == 'coach' %}
|
||||
<li >
|
||||
<h2>Teams I manage</h2>
|
||||
<p>Number of members: {{ clubsize }}</p>
|
||||
<p>Maximum club size: {{ max_clubsize }}</p>
|
||||
<li class="grid_2">
|
||||
<h2>Groups I manage</h2>
|
||||
{% if myteams %}
|
||||
<table width="100%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Manager</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -83,26 +80,77 @@
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<a class="button green" href="/rowers/team/create/">New Team</a>
|
||||
<a href="/rowers/team/create/">Create New Training Group</a>
|
||||
</li>
|
||||
{% if coaches %}
|
||||
<li class="grid_2">
|
||||
<h2>My Coaches</h2>
|
||||
<table width="100%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Coach</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for coach in coaches %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ coach.user.first_name }} {{ coach.user.last_name }}
|
||||
</td>
|
||||
<td>
|
||||
<a class="button small red"
|
||||
href="/rowers/coaches/{{ coach.id }}/dropcoachconfirm/">Remove
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if coachees %}
|
||||
<li class="grid_2">
|
||||
<h2>My Rowers</h2>
|
||||
<table width="100%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for coachee in coachees %}
|
||||
<tr>
|
||||
<td>
|
||||
{{ coachee.user.first_name }} {{ coachee.user.last_name }}
|
||||
</td>
|
||||
<td>
|
||||
<a class="button small red"
|
||||
href="/rowers/coaches/{{ coachee.id }}/dropconfirm/">Remove
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if invites or requests or myrequests or myinvites %}
|
||||
<li class="grid_2">
|
||||
<h2>Invitations and Requests</h2>
|
||||
<p>This section lists open invites to join a team. By accepting
|
||||
a team invite, you are agreeing with the sharing
|
||||
of personal data between team members and coaches according to
|
||||
<h2>Group Invitations and Requests</h2>
|
||||
<p>This section lists open invites to join a group. By accepting
|
||||
a group invite, you are agreeing with the sharing
|
||||
of personal data between group members and coaches according to
|
||||
our <a href="/rowers/legal/">privacy policy</a>.
|
||||
</p>
|
||||
|
||||
<p>As a team manager, by accepting a team invite, you are agreeing
|
||||
with our <a href="/rowers/legal/">privacy policy</a> regarding teams and
|
||||
personal data owned by team members.</p>
|
||||
<p>As a group manager, by accepting a group invite, you are agreeing
|
||||
with our <a href="/rowers/legal/">privacy policy</a> regarding groups and
|
||||
personal data owned by group members.</p>
|
||||
|
||||
<table width="90%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Team</th>
|
||||
<th>Group</th>
|
||||
<th>Manager</th>
|
||||
<th>User</th>
|
||||
<th>Action</th>
|
||||
@@ -173,7 +221,131 @@
|
||||
<input class="button green" type="submit" value="Submit">
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if mycoachrequests or mycoachoffers or coachoffers or coachrequests %}
|
||||
<li class="grid_2">
|
||||
<h2>Coaching Offers and Requests</h2>
|
||||
<p>This section lists open offers and requests related to coaching.
|
||||
By accepting a coaching offer, the coach can run
|
||||
analysis, add workouts and edit settings on behalf of the athlete.
|
||||
You agree to the sharing
|
||||
of personal data between athletes and coaches according to
|
||||
our <a href="/rowers/legal/">privacy policy</a>.
|
||||
</p>
|
||||
<table width="90%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Coach</th>
|
||||
<th>User</th>
|
||||
<th>Action</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for i in coachrequests %}
|
||||
<tr>
|
||||
<td>{{ i.coach.user.first_name }} {{ i.coach.user.last_name }}</td>
|
||||
<td>{{ i.user.first_name }} {{ i.user.last_name }}</td>
|
||||
<td><a
|
||||
class="button small green"
|
||||
href="/rowers/me/coachrequest/{{ i.code }}/accept">Accept</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button small red" href="/rowers/me/coachrequest/{{ i.id }}/reject/">Reject</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for i in mycoachoffers %}
|
||||
<tr>
|
||||
<td>{{ i.coach.user.first_name }} {{ i.coach.user.last_name }}</td>
|
||||
<td>{{ i.user.first_name }} {{ i.user.last_name }}</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<a class="button small red" href="/rowers/me/coachoffer/{{ i.id }}/revoke/">Revoke</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for i in mycoachrequests %}
|
||||
<tr>
|
||||
<td>{{ i.coach.user.first_name }} {{ i.coach.user.last_name }}</td>
|
||||
<td>{{ i.user.first_name }} {{ i.user.last_name }}</td>
|
||||
<td> </td>
|
||||
<td>
|
||||
<a
|
||||
class="button small red"
|
||||
href="/rowers/me/coachrequest/{{ i.id }}/revoke/">Revoke</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% for i in coachoffers %}
|
||||
<tr>
|
||||
<td>{{ i.coach.user.first_name }} {{ i.coach.user.last_name }}</td>
|
||||
<td>{{ i.user.first_name }} {{ i.user.last_name }}</td>
|
||||
<td><a
|
||||
class="button small green"
|
||||
href="/rowers/me/coachoffer/{{ i.code }}/accept/">Accept</a>
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
class="button small red"
|
||||
href="/rowers/me/coachoffer/{{ i.id }}/revoke/">Reject</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% if potentialathletes %}
|
||||
<li class="grid_2">
|
||||
<h2>Rowers you could coach</h2>
|
||||
<table width="90%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for a in potentialathletes %}
|
||||
<tr>
|
||||
<td>{{ a.user.first_name }} {{ a.user.last_name }}</td>
|
||||
<td>
|
||||
<a
|
||||
class="button small green"
|
||||
href="/rowers/me/coachoffer/{{ a.user.id }}/">Offer Coaching</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if potentialcoaches %}
|
||||
<li class="grid_2">
|
||||
<h2>Coaches who could coach you</h2>
|
||||
<table width="90%" class="listtable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>User</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for c in potentialcoaches %}
|
||||
<tr>
|
||||
<td>{{ c.first_name }} {{ c.last_name }}</td>
|
||||
<td>
|
||||
<a
|
||||
class="button small green"
|
||||
href="/rowers/me/coachrequest/{{ c.id }}/">Request Coaching</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
@@ -376,6 +376,11 @@ def team_rowers(user):
|
||||
|
||||
return []
|
||||
|
||||
from rowers.teams import coach_getcoachees
|
||||
|
||||
@register.filter
|
||||
def coach_rowers(user):
|
||||
return coach_getcoachees(user.rower)
|
||||
|
||||
@register.filter
|
||||
def verbosetimeperiod(timeperiod):
|
||||
|
||||
@@ -69,12 +69,14 @@ class VirtualEventViewTest(TestCase):
|
||||
yesterday = nu-datetime.timedelta(days=1)
|
||||
tomorrow = nu+datetime.timedelta(days=1)
|
||||
nextweek = nu+datetime.timedelta(days=7)
|
||||
intwoweeks = nu+datetime.timedelta(days=14)
|
||||
lastweek = nu-datetime.timedelta(days=7)
|
||||
|
||||
self.yesterday = yesterday
|
||||
self.tomorrow = tomorrow
|
||||
self.nextweek = nextweek
|
||||
self.lastweek = lastweek
|
||||
self.intwoweeks = intwoweeks
|
||||
|
||||
|
||||
# erg races
|
||||
@@ -396,8 +398,8 @@ class VirtualEventViewTest(TestCase):
|
||||
'registration_form':'deadline',
|
||||
'registration_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'registration_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.intwoweeks.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.intwoweeks.strftime('%H:%M:%S'),
|
||||
'contact_phone': '',
|
||||
'contact_email': self.u.email,
|
||||
'timezone': 'UTC'
|
||||
@@ -440,8 +442,8 @@ class VirtualEventViewTest(TestCase):
|
||||
'registration_form':'deadline',
|
||||
'registration_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'registration_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.intwoweeks.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.intwoweeks.strftime('%H:%M:%S'),
|
||||
'contact_phone': '',
|
||||
'contact_email': self.u.email,
|
||||
'timezone': 'UTC'
|
||||
@@ -485,8 +487,8 @@ class VirtualEventViewTest(TestCase):
|
||||
'registration_form':'deadline',
|
||||
'registration_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'registration_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.intwoweeks.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.intwoweeks.strftime('%H:%M:%S'),
|
||||
'contact_phone': '',
|
||||
'contact_email': self.u.email,
|
||||
}
|
||||
@@ -522,8 +524,8 @@ class VirtualEventViewTest(TestCase):
|
||||
'registration_form':'deadline',
|
||||
'registration_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'registration_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.nextweek.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.nextweek.strftime('%H:%M:%S'),
|
||||
'evaluation_closure_0': self.intwoweeks.strftime('%Y-%m-%d'),
|
||||
'evaluation_closure_1': self.intwoweeks.strftime('%H:%M:%S'),
|
||||
'contact_phone': '',
|
||||
'contact_email': self.u.email,
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -131,7 +131,7 @@ class TrainingPlanTest(TestCase):
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
self.assertTrue(login)
|
||||
|
||||
url = '/rowers/sessions/create/'
|
||||
url = reverse('plannedsession_create_view')
|
||||
|
||||
startdate = nu.date()
|
||||
enddate = (nu+datetime.timedelta(days=3)).date()
|
||||
@@ -1051,6 +1051,8 @@ class PlannedSessionsView(TestCase):
|
||||
manager = self.u,
|
||||
)
|
||||
|
||||
self.team.save()
|
||||
|
||||
self.r.team.add(self.team)
|
||||
self.r2.team.add(self.team)
|
||||
self.r.save()
|
||||
|
||||
@@ -349,13 +349,4 @@ class TeamTestLowLevel(TestCase):
|
||||
id, comment = create_invite(self.t, self.users[3],self.users[4])
|
||||
self.assertEqual(id,0)
|
||||
|
||||
# cannot exceed club size
|
||||
for i in range(5):
|
||||
id, comment = create_invite(self.t,self.u,user=self.users[i+1])
|
||||
|
||||
if i <= self.u.rower.clubsize:
|
||||
self.assertEqual(comment,'Invitation created')
|
||||
else:
|
||||
self.assertEqual(id,0)
|
||||
|
||||
|
||||
|
||||
BIN
Binary file not shown.
@@ -410,6 +410,30 @@ urlpatterns = [
|
||||
url(r'^team/(?P<id>\d+)/leave/$',views.team_leave_view,name='team_leave_view'),
|
||||
url(r'^team/(?P<id>\d+)/deleteconfirm/$',views.team_deleteconfirm_view,name='team_deleteconfirm_view'),
|
||||
url(r'^team/(?P<teamid>\d+)/requestmembership/(?P<userid>\d+)/$',views.team_requestmembership_view,name='team_requestmembership_view'),
|
||||
url(r'^me/coachrequest/(?P<id>\d+)/reject/$',views.reject_revoke_coach_request,
|
||||
name='reject_revoke_coach_request'),
|
||||
url(r'^coaches/(?P<id>\d+)/dropconfirm/$',views.coach_drop_athlete_confirm_view,
|
||||
name='coach_drop_athlete_confirm_view'),
|
||||
url(r'^coaches/(?P<id>\d+)/drop/$',views.coach_drop_athlete_view,
|
||||
name='coach_drop_athlete_view'),
|
||||
url(r'^coaches/(?P<id>\d+)/dropcoachconfirm/$',views.athlete_drop_coach_confirm_view,
|
||||
name='athlete_drop_coach_confirm_view'),
|
||||
url(r'^coaches/(?P<id>\d+)/dropcoach/$',views.athlete_drop_coach_view,
|
||||
name='athlete_drop_coach_view'),
|
||||
url(r'^me/coachrequest/(?P<id>\d+)/revoke/$',views.reject_revoke_coach_request,
|
||||
name='reject_revoke_coach_request'),
|
||||
url(r'^me/coachoffer/(?P<id>\d+)/reject/$',views.reject_revoke_coach_offer,
|
||||
name='reject_revoke_coach_offer'),
|
||||
url(r'^me/coachoffer/(?P<id>\d+)/revoke/$',views.reject_revoke_coach_offer,
|
||||
name='reject_revoke_coach_offer'),
|
||||
url(r'^me/coachrequest/(?P<coachid>\d+)/$',views.request_coaching_view,
|
||||
name='request_coaching_view'),
|
||||
url(r'^me/coachoffer/(?P<userid>\d+)/$',views.offer_coaching_view,
|
||||
name='offer_coaching_view'),
|
||||
url(r'^me/coachrequest/(?P<code>\w+.*)/accept/$',views.coach_accept_coachrequest_view,
|
||||
name='coach_accept_coachrequest_view'),
|
||||
url(r'^me/coachoffer/(?P<code>\w+.*)/accept/$',views.rower_accept_coachoffer_view,
|
||||
name='rower_accept_coachoffer_view'),
|
||||
url(r'^team/(?P<id>\d+)/delete/$',views.team_delete_view,name='team_delete_view'),
|
||||
url(r'^team/create/$',views.team_create_view,name='team_create_view'),
|
||||
url(r'^me/team/(?P<teamid>\d+)/drop/(?P<userid>\d+)/$',views.manager_member_drop_view,name='manager_member_drop_view'),
|
||||
|
||||
+10
-1
@@ -298,11 +298,14 @@ def myqueue(queue,function,*args,**kwargs):
|
||||
if settings.TESTING:
|
||||
return MockJob()
|
||||
|
||||
if settings.DEBUG:
|
||||
if settings.CELERY:
|
||||
kwargs['debug'] = True
|
||||
|
||||
job = function.delay(*args,**kwargs)
|
||||
else:
|
||||
if settings.DEBUG:
|
||||
kwargs['debug'] = True
|
||||
|
||||
job_id = str(uuid.uuid4())
|
||||
kwargs['job_id'] = job_id
|
||||
kwargs['jobkey'] = job_id
|
||||
@@ -405,6 +408,12 @@ def isprorower(r):
|
||||
|
||||
return result
|
||||
|
||||
def iscoach(m,r):
|
||||
result = False
|
||||
result = m in r.coaches
|
||||
|
||||
return result
|
||||
|
||||
# Exponentially weighted moving average
|
||||
# Used for data smoothing of the jagged data obtained by Strava
|
||||
# See bitbucket issue 72
|
||||
|
||||
@@ -88,7 +88,7 @@ from rowers.models import (
|
||||
microcyclecheckdates,mesocyclecheckdates,macrocyclecheckdates,
|
||||
TrainingMesoCycleForm, TrainingMicroCycleForm,
|
||||
RaceLogo,RowerBillingAddressForm,PaidPlan,
|
||||
PlannedSessionComment,
|
||||
PlannedSessionComment,CoachRequest,CoachOffer,
|
||||
)
|
||||
from rowers.models import (
|
||||
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
||||
@@ -928,6 +928,23 @@ def iscoachmember(user):
|
||||
|
||||
return result
|
||||
|
||||
def cancreateteam(user):
|
||||
if user.is_anonymous():
|
||||
return False
|
||||
|
||||
try:
|
||||
r = Rower.objects.get(user=user)
|
||||
except Rower.DoesNotExist:
|
||||
r = Rower(user=user)
|
||||
r.save()
|
||||
|
||||
if user.is_authenticated() and (r.rowerplan=='coach'):
|
||||
return True
|
||||
elif user.is_athenticated() and r.rowerplan in ['plan','pro']:
|
||||
ts = Team.objects.filter(manager=user)
|
||||
if len(otherteams) >= 1:
|
||||
return False
|
||||
|
||||
# Check if a user can create planned sessions
|
||||
def hasplannedsessions(user):
|
||||
if not user.is_anonymous():
|
||||
|
||||
+260
-17
@@ -167,13 +167,38 @@ def rower_teams_view(request,message='',successmessage=''):
|
||||
myteams, memberteams, otherteams = get_teams(request)
|
||||
teams.remove_expired_invites()
|
||||
|
||||
|
||||
invites = TeamInvite.objects.filter(user=request.user)
|
||||
requests = TeamRequest.objects.filter(user=request.user)
|
||||
myrequests = TeamRequest.objects.filter(team__in=myteams)
|
||||
myinvites = TeamInvite.objects.filter(team__in=myteams)
|
||||
clubsize = teams.count_invites(request.user)+teams.count_club_members(request.user)
|
||||
max_clubsize = r.clubsize
|
||||
|
||||
# user invites (as coach)
|
||||
mycoachoffers = CoachOffer.objects.filter(coach=r)
|
||||
# user is invited (by coach)
|
||||
coachoffers = CoachOffer.objects.filter(user=r.user)
|
||||
|
||||
# user requests a coach
|
||||
mycoachrequests = CoachRequest.objects.filter(user=r.user)
|
||||
# user is requested to coach
|
||||
coachrequests = CoachRequest.objects.filter(coach=r)
|
||||
|
||||
invitedathletes = [rekwest.user for rekwest in mycoachoffers]
|
||||
invitedcoaches = [rekwest.coach for rekwest in mycoachrequests]
|
||||
|
||||
coaches = teams.rower_get_coaches(r)
|
||||
potentialcoaches = [t.manager for t in memberteams if t.manager not in coaches ]
|
||||
potentialcoaches = [c for c in potentialcoaches if c.rower not in invitedcoaches]
|
||||
coachees = teams.coach_getcoachees(r)
|
||||
|
||||
potentialathletes = Rower.objects.filter(
|
||||
team__in=myteams).exclude(
|
||||
user__in=invitedathletes).exclude(
|
||||
user=request.user
|
||||
).exclude(coachinggroups__in=[request.user.rower.mycoachgroup])
|
||||
|
||||
|
||||
# clubsize = teams.count_invites(request.user)+teams.count_club_members(request.user)
|
||||
# max_clubsize = r.clubsize
|
||||
|
||||
messages.info(request,successmessage)
|
||||
messages.error(request,message)
|
||||
@@ -185,13 +210,12 @@ def rower_teams_view(request,message='',successmessage=''):
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
return render(request, 'teams.html',
|
||||
{
|
||||
'teams':ts,
|
||||
'active':'nav-teams',
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'clubsize':clubsize,
|
||||
'max_clubsize':max_clubsize,
|
||||
'myteams':myteams,
|
||||
'memberteams':memberteams,
|
||||
'invites':invites,
|
||||
@@ -200,9 +224,17 @@ def rower_teams_view(request,message='',successmessage=''):
|
||||
'myrequests':myrequests,
|
||||
'form':form,
|
||||
'myinvites':myinvites,
|
||||
'mycoachrequests':mycoachrequests,
|
||||
'mycoachoffers':mycoachoffers,
|
||||
'coachrequests':coachrequests,
|
||||
'coachoffers':coachoffers,
|
||||
'coaches':coaches,
|
||||
'potentialcoaches':potentialcoaches,
|
||||
'coachees':coachees,
|
||||
'potentialathletes':potentialathletes,
|
||||
})
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def invitation_revoke_view(request,id):
|
||||
res,text = teams.revoke_invite(request.user,id)
|
||||
if res:
|
||||
@@ -216,7 +248,7 @@ def invitation_revoke_view(request,id):
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def manager_member_drop_view(request,teamid,userid,
|
||||
message='',successmessage=''):
|
||||
rower = Rower.objects.get(user__id=userid)
|
||||
@@ -230,7 +262,7 @@ def manager_member_drop_view(request,teamid,userid,
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def manager_requests_view(request,code=None,message='',successmessage=''):
|
||||
if code:
|
||||
res,text = teams.process_request_code(request.user,code)
|
||||
@@ -247,6 +279,101 @@ def manager_requests_view(request,code=None,message='',successmessage=''):
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def athlete_drop_coach_confirm_view(request,id):
|
||||
r = getrower(request.user)
|
||||
try:
|
||||
coach = Rower.objects.get(id=id)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("This rower doesn't exist")
|
||||
if coach not in teams.rower_get_coaches(r):
|
||||
raise PermissionDenied("You are not allowed to do this")
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url':reverse('rower_teams_view'),
|
||||
'name': 'Teams'
|
||||
},
|
||||
{
|
||||
'url':reverse('athlete_drop_coach_confirm_view',kwargs={'id':id}),
|
||||
'name': 'Confirm drop athlete'
|
||||
}
|
||||
]
|
||||
|
||||
return render(request,'dropcoachconfirm.html',
|
||||
{
|
||||
'rower':r,
|
||||
'coach':coach
|
||||
})
|
||||
|
||||
@login_required()
|
||||
def coach_drop_athlete_confirm_view(request,id):
|
||||
r = getrower(request.user)
|
||||
try:
|
||||
rower = Rower.objects.get(id=id)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("This rower doesn't exist")
|
||||
if rower not in teams.coach_getcoachees(r):
|
||||
raise PermissionDenied("You are not allowed to do this")
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url':reverse('rower_teams_view'),
|
||||
'name': 'Teams'
|
||||
},
|
||||
{
|
||||
'url':reverse('coach_drop_athlete_confirm_view',kwargs={'id':id}),
|
||||
'name': 'Confirm drop athlete'
|
||||
}
|
||||
]
|
||||
|
||||
return render(request,'dropathleteconfirm.html',
|
||||
{
|
||||
'rower':r,
|
||||
'athlete':rower
|
||||
})
|
||||
|
||||
@login_required()
|
||||
def coach_drop_athlete_view(request,id):
|
||||
r = getrower(request.user)
|
||||
try:
|
||||
rower = Rower.objects.get(id=id)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("This rower doesn't exist")
|
||||
if rower not in teams.coach_getcoachees(r):
|
||||
raise PermissionDenied("You are not allowed to do this")
|
||||
|
||||
res,text = teams.coach_remove_athlete(r,rower)
|
||||
|
||||
if res:
|
||||
messages.info(request,'You are not coaching this athlete any more')
|
||||
else:
|
||||
messages.error(request,'There was an error dropping the athlete from your list')
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def athlete_drop_coach_view(request,id):
|
||||
r = getrower(request.user)
|
||||
try:
|
||||
coach = Rower.objects.get(id=id)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("This coach doesn't exist")
|
||||
if coach not in teams.rower_get_coaches(r):
|
||||
raise PermissionDenied("You are not allowed to do this")
|
||||
|
||||
res,text = teams.coach_remove_athlete(coach,r)
|
||||
|
||||
if res:
|
||||
messages.info(request,'Removal successful')
|
||||
else:
|
||||
messages.error(request,'There was an error dropping the coach from your list')
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def team_requestmembership_view(request,teamid,userid):
|
||||
@@ -255,19 +382,94 @@ def team_requestmembership_view(request,teamid,userid):
|
||||
except Team.DoesNotExist:
|
||||
raise Http404("Team doesn't exist")
|
||||
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
if t.manager.rower.rowerplan in ['plan','pro'] and r.rowerplan == 'basic':
|
||||
messages.error(request,
|
||||
"You have to be on a paid plan (Pro or higher) to join this team. As a basic user you can only join teams managed by users on the Coach plan.")
|
||||
|
||||
url = reverse('paidplans')
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
res,text = teams.create_request(t,userid)
|
||||
if res:
|
||||
messages.info(request,text)
|
||||
else:
|
||||
messages.error(request,text)
|
||||
|
||||
url = reverse(team_view,kwargs={
|
||||
|
||||
url = reverse('team_view',kwargs={
|
||||
'id':int(teamid),
|
||||
})
|
||||
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def request_coaching_view(request,coachid):
|
||||
r = getrequestrower(request)
|
||||
|
||||
coach = User.objects.get(id=coachid).rower
|
||||
|
||||
if coach.rowerplan == 'coach':
|
||||
res,text = teams.create_coaching_request(coach,request.user)
|
||||
if res:
|
||||
messages.info(request,text)
|
||||
else:
|
||||
messages.error(request,text)
|
||||
else:
|
||||
messages.error(request,'That person is not a coach')
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
def offer_coaching_view(request,userid):
|
||||
try:
|
||||
u = User.objects.get(id=userid)
|
||||
except User.DoesNotExist:
|
||||
raise Http404("This user doesn't exist")
|
||||
|
||||
coach = getrequestrower(request)
|
||||
|
||||
res,text = teams.create_coaching_offer(coach,u)
|
||||
|
||||
if res:
|
||||
messages.info(request,text)
|
||||
else:
|
||||
messages.error(request,text)
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def reject_revoke_coach_request(request,id=0):
|
||||
res, text = teams.reject_revoke_coach_request(request.user,id)
|
||||
|
||||
if res:
|
||||
messages.info(request,text)
|
||||
else:
|
||||
messages.error(request,text)
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def reject_revoke_coach_offer(request,id=0):
|
||||
res, text = teams.reject_revoke_coach_offer(request.user,id)
|
||||
|
||||
if res:
|
||||
messages.info(request,text)
|
||||
else:
|
||||
messages.error(request,text)
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def request_revoke_view(request,id=0):
|
||||
res,text = teams.revoke_request(request.user,id)
|
||||
@@ -282,7 +484,7 @@ def request_revoke_view(request,id=0):
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def request_reject_view(request,id=0):
|
||||
res,text = teams.reject_request(request.user,id)
|
||||
|
||||
@@ -295,7 +497,7 @@ def request_reject_view(request,id=0):
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def invitation_reject_view(request,id=0):
|
||||
res,text = teams.reject_invitation(request.user,id)
|
||||
|
||||
@@ -331,7 +533,7 @@ def rower_invitations_view(request,code=None,message='',successmessage=''):
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def team_edit_view(request,id=0):
|
||||
try:
|
||||
t = Team.objects.get(id=id)
|
||||
@@ -395,8 +597,19 @@ def team_edit_view(request,id=0):
|
||||
'team':t,
|
||||
})
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
#@user_passes_test(cancreateteam,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def team_create_view(request):
|
||||
r = getrequestrower(request)
|
||||
|
||||
if r.rowerplan == 'basic':
|
||||
if r.protrialexpires < timezone.now().date() and r.plantrialexpires < timezone.now().date():
|
||||
messages.error(request,"You must upgrade to Pro or higher to create teams/training groups")
|
||||
url = reverse('paidplans')
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
|
||||
|
||||
if request.method == 'POST':
|
||||
teamcreateform = TeamForm(request.POST)
|
||||
if teamcreateform.is_valid():
|
||||
@@ -408,7 +621,13 @@ def team_create_view(request):
|
||||
viewing = cd['viewing']
|
||||
res,message=teams.create_team(name,manager,private,notes,
|
||||
viewing)
|
||||
url = reverse(rower_teams_view)
|
||||
|
||||
if not res:
|
||||
messages.error(request,message)
|
||||
url = reverse('paidplans')
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
response = HttpResponseRedirect(url)
|
||||
return response
|
||||
|
||||
@@ -438,7 +657,7 @@ def team_create_view(request):
|
||||
'breadcrumbs':breadcrumbs,
|
||||
})
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def team_deleteconfirm_view(request,id):
|
||||
r = getrower(request.user)
|
||||
try:
|
||||
@@ -474,7 +693,7 @@ def team_deleteconfirm_view(request,id):
|
||||
'active':'nav-teams',
|
||||
})
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def team_delete_view(request,id):
|
||||
r = getrower(request.user)
|
||||
try:
|
||||
@@ -490,7 +709,7 @@ def team_delete_view(request,id):
|
||||
response = HttpResponseRedirect(url)
|
||||
return response
|
||||
|
||||
@user_passes_test(iscoachmember,login_url="/rowers/paidplans",redirect_field_name=None)
|
||||
@login_required()
|
||||
def team_members_stats_view(request,id):
|
||||
r = getrower(request.user)
|
||||
try:
|
||||
@@ -534,3 +753,27 @@ def team_members_stats_view(request,id):
|
||||
})
|
||||
|
||||
return response
|
||||
|
||||
@login_required()
|
||||
def rower_accept_coachoffer_view(request,code=None):
|
||||
if code:
|
||||
res, text = teams.process_coachoffer_code(request.user,code)
|
||||
if res:
|
||||
messages.info(request,text)
|
||||
else:
|
||||
messages.error(request,text)
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required()
|
||||
def coach_accept_coachrequest_view(request,code=None):
|
||||
if code:
|
||||
res, text = teams.process_coachrequest_code(request.user.rower,code)
|
||||
if res:
|
||||
messages.info(request,text)
|
||||
else:
|
||||
messages.error(request,text)
|
||||
|
||||
url = reverse('rower_teams_view')
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@@ -4,7 +4,7 @@ from statements import *
|
||||
def start_trial_view(request):
|
||||
r = getrower(request.user)
|
||||
|
||||
if r.protrialexpires is not None:
|
||||
if r.protrialexpires > datetime.date(1970,1,1):
|
||||
messages.error(request,'You do not qualify for a trial')
|
||||
url = '/rowers/paidplans'
|
||||
return HttpResponseRedirect(url)
|
||||
@@ -31,7 +31,7 @@ def start_trial_view(request):
|
||||
def start_plantrial_view(request):
|
||||
r = getrower(request.user)
|
||||
|
||||
if r.plantrialexpires is not None:
|
||||
if r.plantrialexpires > datetime.date(1970,1,1):
|
||||
messages.error(request,'You do not qualify for a trial')
|
||||
url = '/rowers/paidplans'
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from statements import *
|
||||
|
||||
import rowers.teams as teams
|
||||
|
||||
# Show the EMpower Oarlock generated Stroke Profile
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans/",
|
||||
@@ -4235,16 +4235,18 @@ def team_workout_upload_view(request,message="",
|
||||
|
||||
rowerform = TeamInviteForm(request.POST)
|
||||
rowerform.fields.pop('email')
|
||||
rowerform.fields['user'].queryset = User.objects.filter(rower__isnull=False,rower__team__in=myteams).distinct()
|
||||
rowers = Rower.objects.filter(coachinggroups__in=[r.mycoachgroup]).distinct()
|
||||
rowerform.fields['user'].queryset = User.objects.filter(rower__in=rowers).distinct()
|
||||
if form.is_valid():
|
||||
f = request.FILES['file']
|
||||
res = handle_uploaded_file(f)
|
||||
t = form.cleaned_data['title']
|
||||
offline = form.cleaned_data['offline']
|
||||
boattype = form.cleaned_data['boattype']
|
||||
workouttype = form.cleaned_data['workouttype']
|
||||
if rowerform.is_valid():
|
||||
u = rowerform.cleaned_data['user']
|
||||
if u:
|
||||
if u and request.user.rower in teams.rower_get_coaches(u.rower):
|
||||
r = getrower(u)
|
||||
else:
|
||||
message = 'Please select a rower'
|
||||
@@ -4331,7 +4333,7 @@ def team_workout_upload_view(request,message="",
|
||||
url = reverse('team_workout_upload_view')
|
||||
|
||||
response = HttpResponseRedirect(url)
|
||||
w = Workout.objects.get(id=encoder.decode_hex(id))
|
||||
w = Workout.objects.get(id=id)
|
||||
|
||||
r = getrower(request.user)
|
||||
if (make_plot):
|
||||
|
||||
@@ -467,3 +467,9 @@ try:
|
||||
OPAQUE_SECRET_KEY = CFG['opaque_secret_key']
|
||||
except KeyError:
|
||||
OPAQUE_SECRET_KEY = 0xa193443a
|
||||
|
||||
# Celery or RQ
|
||||
try:
|
||||
CELERY = CFG['use_celery']
|
||||
except KeyError:
|
||||
CELERY = False
|
||||
|
||||
@@ -216,7 +216,7 @@
|
||||
</li>
|
||||
<li id="nav-teams">
|
||||
<a href="/rowers/me/teams/">
|
||||
<i class="fas fa-bullhorn"></i> Teams
|
||||
<i class="fas fa-bullhorn"></i> Groups
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
</li>
|
||||
<li id="nav-teams">
|
||||
<a href="/rowers/me/teams/">
|
||||
<i class="fas fa-bullhorn"></i> Teams
|
||||
<i class="fas fa-bullhorn"></i> Groups
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user