initial
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
from rowers.utils import rankingdistances, rankingdurations
|
from rowers.utils import rankingdistances, rankingdurations
|
||||||
from rowers.utils import (
|
from rowers.utils import (
|
||||||
workflowleftpanel, workflowmiddlepanel,
|
workflowleftpanel, workflowmiddlepanel,
|
||||||
defaultleft, defaultmiddle
|
defaultleft, defaultmiddle,
|
||||||
|
workout_name_element,
|
||||||
)
|
)
|
||||||
from rowers.utils import palettes
|
from rowers.utils import palettes
|
||||||
from time import strftime
|
from time import strftime
|
||||||
@@ -497,6 +498,15 @@ class WorkFlowMiddlePanelElement(forms.Form):
|
|||||||
initial='None',
|
initial='None',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class WorkoutNameTemplateElement(forms.Form):
|
||||||
|
templatechoices = tuple(list(workout_name_element)+[('None', 'None')])
|
||||||
|
|
||||||
|
element = forms.ChoiceField(
|
||||||
|
label='',
|
||||||
|
choices=templatechoices,
|
||||||
|
initial='None'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# The form to indicate additional actions to be performed immediately
|
# The form to indicate additional actions to be performed immediately
|
||||||
# after a successful upload
|
# after a successful upload
|
||||||
|
|||||||
@@ -231,6 +231,34 @@ class AlternativeEmails(models.TextField):
|
|||||||
value = self._get_val_from_obj(obj)
|
value = self._get_val_from_obj(obj)
|
||||||
return self.get_deb_prep_value(value)
|
return self.get_deb_prep_value(value)
|
||||||
|
|
||||||
|
|
||||||
|
# model for Workout Name template list
|
||||||
|
|
||||||
|
class WorkoutNameTemplateField(models.TextField):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(WorkoutNameTemplateField, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def to_python(self, value): # pragma: no cover
|
||||||
|
if not value:
|
||||||
|
return
|
||||||
|
return json.loads(value)
|
||||||
|
|
||||||
|
def from_db_value(self, value, expression, connection):
|
||||||
|
if not value:
|
||||||
|
return
|
||||||
|
return json.loads(value)
|
||||||
|
|
||||||
|
def get_db_prep_value(self, value, connection, prepared=False):
|
||||||
|
if not value:
|
||||||
|
return
|
||||||
|
return json.dumps(value)
|
||||||
|
|
||||||
|
def value_to_string(self, obj): # pragma: no cover
|
||||||
|
value = self._get_val_from_obj(obj)
|
||||||
|
return self.get_deb_prep_value(value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# model for Planned Session Steps
|
# model for Planned Session Steps
|
||||||
|
|
||||||
|
|
||||||
@@ -1094,6 +1122,8 @@ class Rower(models.Model):
|
|||||||
choices=landingpages2,
|
choices=landingpages2,
|
||||||
verbose_name="Title link on workout list")
|
verbose_name="Title link on workout list")
|
||||||
|
|
||||||
|
workoutnametemplate = WorkoutNameTemplateField(default=['date','name','distance','ownerfirst','ownerlast','duration','boattype','workouttype'])
|
||||||
|
|
||||||
# Access tokens
|
# Access tokens
|
||||||
c2token = models.CharField(
|
c2token = models.CharField(
|
||||||
default='', max_length=200, blank=True, null=True)
|
default='', max_length=200, blank=True, null=True)
|
||||||
|
|||||||
@@ -41,6 +41,22 @@
|
|||||||
</form>
|
</form>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h1>Workout Name Settings of {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Use this form to change how the workout is named in charts. Our recommendation is name, date, rower first name, rower last name, workout type
|
||||||
|
as a minimum.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
{{ workoutnametemplate_formset.management_form }}
|
||||||
|
<table width=100%>
|
||||||
|
{{ workoutnametemplate_formset.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input class="grid_2 alpha button" type="submit" value="Save">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
<h1>Change Favorite Charts of {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
<h1>Change Favorite Charts of {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,18 @@ landingpages2 = (
|
|||||||
('workout_delete', 'Remove Workout')
|
('workout_delete', 'Remove Workout')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
workout_name_element = (
|
||||||
|
('date', 'Date'),
|
||||||
|
('name', 'Name'),
|
||||||
|
('distance', 'Distance'),
|
||||||
|
('ownerfirst', 'Rower first name'),
|
||||||
|
('ownerlast', 'Rower last name'),
|
||||||
|
('duration', 'Duration'),
|
||||||
|
('boattype','Boat Type'),
|
||||||
|
('workouttype', 'Workout Type'),
|
||||||
|
('seatnumber','Seat Number')
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
workflowmiddlepanel = (
|
workflowmiddlepanel = (
|
||||||
('panel_statcharts.html', 'Static Charts'),
|
('panel_statcharts.html', 'Static Charts'),
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ from rowers.forms import (
|
|||||||
CourseConfirmForm, ResampleForm,
|
CourseConfirmForm, ResampleForm,
|
||||||
TeamUploadOptionsForm, WorkFlowLeftPanelForm, WorkFlowMiddlePanelForm,
|
TeamUploadOptionsForm, WorkFlowLeftPanelForm, WorkFlowMiddlePanelForm,
|
||||||
WorkFlowLeftPanelElement, WorkFlowMiddlePanelElement,
|
WorkFlowLeftPanelElement, WorkFlowMiddlePanelElement,
|
||||||
|
WorkoutNameTemplateElement,
|
||||||
LandingPageForm, PlannedSessionSelectForm, WorkoutSessionSelectForm,
|
LandingPageForm, PlannedSessionSelectForm, WorkoutSessionSelectForm,
|
||||||
PlannedSessionTeamForm, PlannedSessionTeamMemberForm,
|
PlannedSessionTeamForm, PlannedSessionTeamMemberForm,
|
||||||
VirtualRaceSelectForm, WorkoutRaceSelectForm, CourseSelectForm,
|
VirtualRaceSelectForm, WorkoutRaceSelectForm, CourseSelectForm,
|
||||||
|
|||||||
@@ -322,6 +322,28 @@ def rower_favoritecharts_view(request, userid=0):
|
|||||||
FavoriteChartFormSet = formset_factory(
|
FavoriteChartFormSet = formset_factory(
|
||||||
FavoriteForm, formset=BaseFavoriteFormSet, extra=1)
|
FavoriteForm, formset=BaseFavoriteFormSet, extra=1)
|
||||||
|
|
||||||
|
workoutnametemplate = r.workoutnametemplate
|
||||||
|
WorkoutNameTemplateFormSet = formset_factory(WorkoutNameTemplateElement, extra=1)
|
||||||
|
|
||||||
|
workoutnametemplate_data = [{'element': element} for element in r.workoutnametemplate]
|
||||||
|
workoutnametemplate_formset = WorkoutNameTemplateFormSet(initial=workoutnametemplate_data, prefix='workoutname')
|
||||||
|
|
||||||
|
if request.method == 'POST' and 'workoutname-TOTAL_FORMS' in request.POST:
|
||||||
|
workoutnametemplate_formset = WorkoutNameTemplateFormSet(request.POST, prefix='workoutname')
|
||||||
|
newworkoutnametemplate = []
|
||||||
|
if workoutnametemplate_formset.is_valid():
|
||||||
|
for form in workoutnametemplate_formset:
|
||||||
|
element = form.cleaned_data.get('element')
|
||||||
|
if element != 'None':
|
||||||
|
newworkoutnametemplate.append(element)
|
||||||
|
|
||||||
|
newworkoutnametemplate = [i for i in newworkoutnametemplate if i is not None]
|
||||||
|
r.workoutnametemplate = newworkoutnametemplate
|
||||||
|
try:
|
||||||
|
r.save()
|
||||||
|
except IntegrityError:
|
||||||
|
messages.error("Something went wrong")
|
||||||
|
|
||||||
if request.method == 'POST' and 'staticgrids' in request.POST: # pragma: no cover
|
if request.method == 'POST' and 'staticgrids' in request.POST: # pragma: no cover
|
||||||
staticchartform = StaticChartRowerForm(request.POST, instance=r)
|
staticchartform = StaticChartRowerForm(request.POST, instance=r)
|
||||||
if staticchartform.is_valid():
|
if staticchartform.is_valid():
|
||||||
@@ -400,6 +422,7 @@ def rower_favoritecharts_view(request, userid=0):
|
|||||||
'rower': r,
|
'rower': r,
|
||||||
'staticchartform': staticchartform,
|
'staticchartform': staticchartform,
|
||||||
'datasettingsform': datasettingsform,
|
'datasettingsform': datasettingsform,
|
||||||
|
'workoutnametemplate_formset': workoutnametemplate_formset,
|
||||||
}
|
}
|
||||||
|
|
||||||
return render(request, 'favoritecharts.html', context)
|
return render(request, 'favoritecharts.html', context)
|
||||||
|
|||||||
Reference in New Issue
Block a user