Private
Public Access
1
0

added freecoach to coach priviliges

This commit is contained in:
Sander Roosendaal
2019-05-15 15:40:51 +02:00
parent d9a5ac2c06
commit 0f8a9f285b
12 changed files with 50 additions and 18 deletions

View File

@@ -3,6 +3,8 @@ from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# All the data preparation, data cleaning and data mangling should
# be defined here
from __future__ import unicode_literals, absolute_import
@@ -28,6 +30,7 @@ from pandas import DataFrame, Series
from django.utils import timezone
from django.utils.timezone import get_current_timezone
from django_mailbox.models import Message,Mailbox,MessageAttachment
from django.core.exceptions import ValidationError
from time import strftime
import arrow
@@ -1100,8 +1103,11 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
try:
w.save()
except ValidationError:
w.startdatetime = timezone.now()
w.save()
try:
w.startdatetime = timezone.now()
w.save()
except ValidationError:
return (0,'Unable to create your workout')
if privacy == 'visible':
ts = Team.objects.filter(rower=r)

View File

@@ -632,16 +632,16 @@ class RegistrationFormSex(RegistrationFormUniqueEmail):
raise forms.ValidationError('Must be at least 16 years old to register')
return self.cleaned_data['birthdate']
sex = forms.ChoiceField(required=True,
sex = forms.ChoiceField(required=False,
choices=sexcategories,
initial='not specified',
label='Sex')
weightcategory = forms.ChoiceField(label='Weight Category',
choices=weightcategories)
choices=weightcategories,initial='hwt',required=False)
adaptiveclass = forms.ChoiceField(label='Adaptive Classification',
choices=adaptivecategories)
choices=adaptivecategories,initial='None',required=False)
# def __init__(self, *args, **kwargs):
# self.fields['sex'].initial = 'not specified'

View File

@@ -2580,7 +2580,7 @@ class Workout(models.Model):
def save(self, *args, **kwargs):
user = self.user
if self.user.rowerplan == 'freecoach':
raise ValidationError("Free Coach User cannot have any workouts")
raise forms.ValidationError("Free Coach User cannot have any workouts")
super(Workout, self).save(*args, **kwargs)

View File

@@ -701,7 +701,10 @@ def handle_strava_import_stroke_data(title,
coords = get_strava_stream(r,'latlng',stravaid)
power = get_strava_stream(r,'power',stravaid)
nr_rows = len(t)
if nr_rows is not None:
nr_rows = len(t)
else:
return 0
if nr_rows == 0:
return 0

View File

@@ -77,7 +77,7 @@ def create_team(name,manager,private='open',notes='',viewing='allmembers'):
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':
if manager.rower.rowerplan not in ('coach','freecoach'):
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')
@@ -180,7 +180,7 @@ def rower_get_coaches(rower):
def coach_getcoachees(coach):
if coach.mycoachgroup and coach.rowerplan == 'coach':
if coach.mycoachgroup and coach.rowerplan in ('coach','freecoach'):
return Rower.objects.filter(
coachinggroups__in=[coach.mycoachgroup]
).distinct().order_by("user__last_name","user__first_name")
@@ -237,7 +237,7 @@ def create_coaching_request(coach,user):
while code in codes:
code = uuid.uuid4().hex[:10].upper()
if coach.rowerplan == 'coach':
if 'coach' in coach.rowerplan:
rekwest = CoachRequest(coach=coach,user=user,code=code)
rekwest.save()
@@ -316,7 +316,7 @@ def create_coaching_offer(coach,user):
while code in codes:
code = uuid.uuid4().hex[:10].upper()
if coach.rowerplan == 'coach' and get_coach_club_size(coach)<coach.clubsize:
if 'coach' in coach.rowerplan and get_coach_club_size(coach)<coach.clubsize:
rekwest = CoachOffer(coach=coach,user=user,code=code)
rekwest.save()

View File

@@ -1,7 +1,7 @@
{% extends "newbase.html" %}
{% load staticfiles %}
{% load rowerfilters %}
{% block title %}New User Registration{% endblock title %}
{% block title %}New Coach Registration{% endblock title %}
{% block meta %}
{% endblock %}

View File

@@ -178,6 +178,8 @@
<td>
{% if rower.rowerplan == 'coach' %}
<h3>COACH ({{ rower.paymenttype }})</h3>
{% elif rower.rowerplan == 'freecoach' %}
<h3>Free COACH</h3>
{% else %}
&nbsp;
{% endif %}
@@ -298,6 +300,14 @@
can purchase upgrades to "Pro" and "Self-Coach" plans.
</p>
<p>
The Coach plans come in two versions: free and paid. On the free coach plan,
you can only have athletes who are on the PRO paid plans or higher, and you
cannot upload any workouts to your own account. On the paid
plans, your athletes can be on the free plan, and you have full access to the
site functionality for your own workouts and those of your athletes.
</p>
<p>If you would like to find a coach who helps you plan your training
through rowsandall.com, contact me throught the contact form.</p>

View File

@@ -638,6 +638,9 @@ def freecoach_register_view(request):
'next':nextpage,})
else:
form = RegistrationFormSex()
form.fields.pop('sex')
form.fields.pop('weightcategory')
form.fields.pop('adaptiveclass')
return render(request,
"freecoach_registration_form.html",
{'form':form,

View File

@@ -1041,7 +1041,7 @@ def hasplannedsessions(user):
r = Rower(user=user)
r.save()
result = user.is_authenticated and (r.rowerplan=='coach' or r.rowerplan=='plan')
result = user.is_authenticated and (r.rowerplan=='coach' or r.rowerplan=='freecoach' or r.rowerplan=='plan')
if not result and r.plantrialexpires:
result = user.is_authenticated and r.plantrialexpires >= datetime.date.today()
else:

View File

@@ -200,10 +200,10 @@ def rower_teams_view(request,message='',successmessage=''):
coaches = teams.rower_get_coaches(r)
potentialcoaches = [t.manager for t in memberteams if t.manager not in coaches and t.manager.rower.rowerplan == 'coach']
potentialcoaches = [t.manager for t in memberteams if t.manager not in coaches and 'coach' in t.manager.rower.rowerplan]
offercoaches = [
r.user for r in Rower.objects.filter(
offercoaching=True,rowerplan='coach').exclude(user=request.user)
offercoaching=True,rowerplan__in='coach').exclude(user=request.user)
]
potentialcoaches = list(set(potentialcoaches+offercoaches))
potentialcoaches = [c for c in potentialcoaches if c.rower not in invitedcoaches+coaches]
@@ -218,6 +218,16 @@ def rower_teams_view(request,message='',successmessage=''):
user__in=invitedathletes).exclude(
user=request.user
).exclude(coachinggroups__in=[request.user.rower.mycoachgroup])
elif request.user.rower.rowerplan == 'freecoach':
potentialathletes = Rower.objects.filter(
team__in=myteams).exclude(
user__in=invitedathletes).exclude(
user=request.user
).exclude(
coachinggroups__in=[request.user.rower.mycoachgroup]
).exclude(
rowerplan__in=['basic','freecoach']
)
else:
potentialathletes = []
@@ -437,7 +447,7 @@ def request_coaching_view(request,coachid):
coach = User.objects.get(id=coachid).rower
if coach.rowerplan == 'coach':
if 'coach' in coach.rowerplan:
res,text = teams.create_coaching_request(coach,request.user)
if res:
messages.info(request,text)