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 print_function
from __future__ import unicode_literals from __future__ import unicode_literals
# All the data preparation, data cleaning and data mangling should # All the data preparation, data cleaning and data mangling should
# be defined here # be defined here
from __future__ import unicode_literals, absolute_import from __future__ import unicode_literals, absolute_import
@@ -28,6 +30,7 @@ from pandas import DataFrame, Series
from django.utils import timezone from django.utils import timezone
from django.utils.timezone import get_current_timezone from django.utils.timezone import get_current_timezone
from django_mailbox.models import Message,Mailbox,MessageAttachment from django_mailbox.models import Message,Mailbox,MessageAttachment
from django.core.exceptions import ValidationError
from time import strftime from time import strftime
import arrow import arrow
@@ -1100,8 +1103,11 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
try: try:
w.save() w.save()
except ValidationError: except ValidationError:
try:
w.startdatetime = timezone.now() w.startdatetime = timezone.now()
w.save() w.save()
except ValidationError:
return (0,'Unable to create your workout')
if privacy == 'visible': if privacy == 'visible':
ts = Team.objects.filter(rower=r) 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') raise forms.ValidationError('Must be at least 16 years old to register')
return self.cleaned_data['birthdate'] return self.cleaned_data['birthdate']
sex = forms.ChoiceField(required=True, sex = forms.ChoiceField(required=False,
choices=sexcategories, choices=sexcategories,
initial='not specified', initial='not specified',
label='Sex') label='Sex')
weightcategory = forms.ChoiceField(label='Weight Category', weightcategory = forms.ChoiceField(label='Weight Category',
choices=weightcategories) choices=weightcategories,initial='hwt',required=False)
adaptiveclass = forms.ChoiceField(label='Adaptive Classification', adaptiveclass = forms.ChoiceField(label='Adaptive Classification',
choices=adaptivecategories) choices=adaptivecategories,initial='None',required=False)
# def __init__(self, *args, **kwargs): # def __init__(self, *args, **kwargs):
# self.fields['sex'].initial = 'not specified' # self.fields['sex'].initial = 'not specified'

View File

@@ -2580,7 +2580,7 @@ class Workout(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
user = self.user user = self.user
if self.user.rowerplan == 'freecoach': 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) 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) coords = get_strava_stream(r,'latlng',stravaid)
power = get_strava_stream(r,'power',stravaid) power = get_strava_stream(r,'power',stravaid)
if nr_rows is not None:
nr_rows = len(t) nr_rows = len(t)
else:
return 0
if nr_rows == 0: if nr_rows == 0:
return 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.rowerplan == 'basic':
if manager.rower.protrialexpires < timezone.now().date() and manager.rower.plantrialexpires < timezone.now().date(): 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') 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) ts = Team.objects.filter(manager=manager)
if len(ts)>=1: if len(ts)>=1:
return (0,'You need to upgrade to the Coach plan to have more than one team') 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): def coach_getcoachees(coach):
if coach.mycoachgroup and coach.rowerplan == 'coach': if coach.mycoachgroup and coach.rowerplan in ('coach','freecoach'):
return Rower.objects.filter( return Rower.objects.filter(
coachinggroups__in=[coach.mycoachgroup] coachinggroups__in=[coach.mycoachgroup]
).distinct().order_by("user__last_name","user__first_name") ).distinct().order_by("user__last_name","user__first_name")
@@ -237,7 +237,7 @@ def create_coaching_request(coach,user):
while code in codes: while code in codes:
code = uuid.uuid4().hex[:10].upper() code = uuid.uuid4().hex[:10].upper()
if coach.rowerplan == 'coach': if 'coach' in coach.rowerplan:
rekwest = CoachRequest(coach=coach,user=user,code=code) rekwest = CoachRequest(coach=coach,user=user,code=code)
rekwest.save() rekwest.save()
@@ -316,7 +316,7 @@ def create_coaching_offer(coach,user):
while code in codes: while code in codes:
code = uuid.uuid4().hex[:10].upper() 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 = CoachOffer(coach=coach,user=user,code=code)
rekwest.save() rekwest.save()

View File

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

View File

@@ -178,6 +178,8 @@
<td> <td>
{% if rower.rowerplan == 'coach' %} {% if rower.rowerplan == 'coach' %}
<h3>COACH ({{ rower.paymenttype }})</h3> <h3>COACH ({{ rower.paymenttype }})</h3>
{% elif rower.rowerplan == 'freecoach' %}
<h3>Free COACH</h3>
{% else %} {% else %}
&nbsp; &nbsp;
{% endif %} {% endif %}
@@ -298,6 +300,14 @@
can purchase upgrades to "Pro" and "Self-Coach" plans. can purchase upgrades to "Pro" and "Self-Coach" plans.
</p> </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 <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> through rowsandall.com, contact me throught the contact form.</p>

View File

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

View File

@@ -1041,7 +1041,7 @@ def hasplannedsessions(user):
r = Rower(user=user) r = Rower(user=user)
r.save() 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: if not result and r.plantrialexpires:
result = user.is_authenticated and r.plantrialexpires >= datetime.date.today() result = user.is_authenticated and r.plantrialexpires >= datetime.date.today()
else: else:

View File

@@ -200,10 +200,10 @@ def rower_teams_view(request,message='',successmessage=''):
coaches = teams.rower_get_coaches(r) 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 = [ offercoaches = [
r.user for r in Rower.objects.filter( 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 = list(set(potentialcoaches+offercoaches))
potentialcoaches = [c for c in potentialcoaches if c.rower not in invitedcoaches+coaches] 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__in=invitedathletes).exclude(
user=request.user user=request.user
).exclude(coachinggroups__in=[request.user.rower.mycoachgroup]) ).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: else:
potentialathletes = [] potentialathletes = []
@@ -437,7 +447,7 @@ def request_coaching_view(request,coachid):
coach = User.objects.get(id=coachid).rower 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) res,text = teams.create_coaching_request(coach,request.user)
if res: if res:
messages.info(request,text) messages.info(request,text)

View File

@@ -161,7 +161,7 @@
<a href="/rowers/me/preferences/" title="Profile"> <a href="/rowers/me/preferences/" title="Profile">
{% if user.rower.rowerplan == 'pro' %} {% if user.rower.rowerplan == 'pro' %}
<i class="fas fa-user-ninja "></i> <i class="fas fa-user-ninja "></i>
{% elif user.rower.rowerplan == 'coach' %} {% elif 'coach' in user.rower.rowerplan %}
<i class="fas fa-users "></i> <i class="fas fa-users "></i>
{% elif user.rower.rowerplan == 'plan' %} {% elif user.rower.rowerplan == 'plan' %}
<i class="fas fa-user-chart "></i> <i class="fas fa-user-chart "></i>

View File

@@ -169,7 +169,7 @@
<a href="/rowers/me/preferences/" title="Profile"> <a href="/rowers/me/preferences/" title="Profile">
{% if user.rower.rowerplan == 'pro' %} {% if user.rower.rowerplan == 'pro' %}
<i class="fas fa-user-ninja "></i> <i class="fas fa-user-ninja "></i>
{% elif user.rower.rowerplan == 'coach' %} {% elif 'coach' in user.rower.rowerplan %}
<i class="fas fa-users "></i> <i class="fas fa-users "></i>
{% elif user.rower.rowerplan == 'plan' %} {% elif user.rower.rowerplan == 'plan' %}
<i class="fas fa-user-tie "></i> <i class="fas fa-user-tie "></i>