diff --git a/rowers/models.py b/rowers/models.py index f9632550..b62f0f78 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -801,6 +801,7 @@ class PlannedSession(models.Model): ('session','Training Session'), ('challenge','Challenge'), ('test','Mandatory Test'), + ('cycletarget','Cycle Target'), ) sessionmodechoices = ( @@ -894,6 +895,18 @@ class PlannedSession(models.Model): return stri + def save(self, *args, **kwargs): + # sort units + if self.sessionmode == 'distance': + if self.sessionunit not in ['m','km']: + self.sessionunit = 'm' + elif self.sessionmode == 'time': + self.sessionunit = 'min' + else: + self.sessionunit = 'None' + + super(PlannedSession,self).save(*args, **kwargs) + # Date input utility class DateInput(forms.DateInput): input_type = 'date' @@ -950,7 +963,7 @@ class PlannedSessionFormSmall(ModelForm): 'enddate': DateInput(attrs={'size':10}), 'name': forms.TextInput(attrs={'size':10}), 'comment': forms.TextInput(attrs={'size':10}), - 'sessionvalue': forms.TextInput(attrs={'style':'width:3em', + 'sessionvalue': forms.TextInput(attrs={'style':'width:5em', 'type':'number'}), 'manager': forms.HiddenInput(), } diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 3cc15766..449de9e1 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -33,7 +33,7 @@ def add_workouts_plannedsession(ws,ps): # check if all sessions have same date dates = [w.date for w in ws] - if (not all(d == dates[0] for d in dates)) and ps.sessiontype != 'challenge': + if (not all(d == dates[0] for d in dates)) and ps.sessiontype not in ['challenge','cycletarget']: errors.append('For tests and training sessions, selected workouts must all be done on the same date') return result,comments,errors @@ -158,7 +158,7 @@ def is_session_complete_ws(ws,ps): status = 'partial' - if ps.sessiontype == 'session': + if ps.sessiontype in ['session','cycletarget']: if ps.criterium == 'exact': if ratio == 1.0: return ratio,'completed' diff --git a/rowers/templates/plannedsession_multicreate.html b/rowers/templates/plannedsession_multicreate.html index 8ec43d64..d1be9b95 100644 --- a/rowers/templates/plannedsession_multicreate.html +++ b/rowers/templates/plannedsession_multicreate.html @@ -2,7 +2,7 @@ {% load staticfiles %} {% load rowerfilters %} -{% block title %}New Planned Session{% endblock %} +{% block title %}Plan entire microcycle{% endblock %} {% block content %}
On this page, you can create and edit sessions for an entire time - period. + period. You see a list of the current sessions planned for the + selected time period. Each row in the table is a session. You can + remove a session by clicking "remove" at the end of a row. + You can edit the date in the forms. If you need to add a new session, + click the "Add More" button to add a new session. Use the "Submit" + button to commit any changes you made.