diff --git a/rowers/forms.py b/rowers/forms.py index 53139c5a..290e5f00 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -963,7 +963,6 @@ class PlannedSessionTeamForm(forms.Form): return cd = self.cleaned_data - print cd['team'],'aap' if not cd['team']: raise forms.ValidationError( 'You must select at least one team' diff --git a/rowers/models.py b/rowers/models.py index 1db6d745..5db5bb25 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -973,18 +973,24 @@ class TrainingTargetForm(ModelForm): } def __init__(self,*args, **kwargs): + user = kwargs.pop('user',None) super(TrainingTargetForm, self).__init__(*args, **kwargs) try: teams = Team.objects.filter(manager=self.instance.manager.user) - if not teams: - self.fields.pop('rowers') - else: - self.fields['rowers'].queryset = Rower.objects.filter( - team__in=teams - ).distinct().order_by("user__last_name","user__first_name") except AttributeError: + if user: + teams = Team.objects.filter(manager=user) + else: + teams = [] + + if not teams: self.fields.pop('rowers') + else: + self.fields['rowers'].queryset = Rower.objects.filter( + team__in=teams + ).distinct().order_by("user__last_name","user__first_name") + # SportTracks has a TrainingGoal like this @@ -1095,6 +1101,7 @@ class TrainingPlanForm(ModelForm): def __init__(self,*args, **kwargs): targets = kwargs.pop('targets',None) + user = kwargs.pop('user',None) super(TrainingPlanForm, self).__init__(*args, **kwargs) if targets: @@ -1110,15 +1117,18 @@ class TrainingPlanForm(ModelForm): try: teams = Team.objects.filter(manager=self.instance.manager.user) - - if not teams: - self.fields.pop('rowers') - else: - self.fields['rowers'].queryset = Rower.objects.filter( - team__in=teams - ).distinct().order_by("user__last_name","user__first_name") except AttributeError: + if user: + teams = Team.objects.filter(manager=user) + else: + teams = [] + + if not teams: self.fields.pop('rowers') + else: + self.fields['rowers'].queryset = Rower.objects.filter( + team__in=teams + ).distinct().order_by("user__last_name","user__first_name") cycletypechoices = ( ('filler','System Defined'), @@ -1628,7 +1638,7 @@ class PlannedSession(models.Model): ('session','Training Session'), ('challenge','Challenge'), ('test','Mandatory Test'), - ('cycletarget','Cycle Target'), + ('cycletarget','Total for a time period'), ('coursetest','OTW test over a course'), ('race','Virtual Race'), ) diff --git a/rowers/tasks.py b/rowers/tasks.py index fbe58f3f..51e86064 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -873,6 +873,28 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname, return 1 +@app.task +def handle_sendemailics(first_name, last_name, email, icsfile, **kwargs): + # send email with attachment + fullemail = first_name + " " + last_name + " " + "<" + email + ">" + subject = "Calendar File from Rowsandall.com" + + + d = {'first_name':first_name, + 'siteurl':siteurl, + } + + from_email = 'Rowsandall ' + + + res = send_template_email(from_email,[fullemail], + subject,'icsemail.html',d, + attach_file=icsfile,**kwargs) + + os.remove(icsfile) + return 1 + + @app.task def handle_sendemailkml(first_name, last_name, email, kmlfile,**kwargs): diff --git a/rowers/templates/icsemail.html b/rowers/templates/icsemail.html new file mode 100644 index 00000000..ffab16ea --- /dev/null +++ b/rowers/templates/icsemail.html @@ -0,0 +1,14 @@ +{% extends "emailbase.html" %} + +{% block body %} +

Dear {{ first_name }},

+ +

+ Please find attached the requested ICS Calendar file. You can import + this file to your calendar app. +

+ +

+ Best Regards, the Rowsandall Team +

+{% endblock %} diff --git a/rowers/templates/plannedsessions.html b/rowers/templates/plannedsessions.html index b2f0fdca..8500b376 100644 --- a/rowers/templates/plannedsessions.html +++ b/rowers/templates/plannedsessions.html @@ -129,7 +129,12 @@ Print View +   + + Get Calendar File

+
  • {% if unmatchedworkouts %} diff --git a/rowers/templates/trainingplan.html b/rowers/templates/trainingplan.html index 8e2e57d0..770f457b 100644 --- a/rowers/templates/trainingplan.html +++ b/rowers/templates/trainingplan.html @@ -6,6 +6,17 @@ {% block main %} + +

    Training Plan - {{ plan.name }}

    This plan starts on {{ plan.startdate }} and ends on {{ plan.enddate }}. {% if plan.target %} @@ -18,6 +29,7 @@

    Plan Macro, Meso and Micro Cycles

    +

    Unfold/Fold all