Merge branch 'feature/favoritechartstack' into develop
This commit is contained in:
@@ -267,6 +267,28 @@ class WorkoutNameTemplateField(models.TextField):
|
|||||||
return self.get_deb_prep_value(value)
|
return self.get_deb_prep_value(value)
|
||||||
|
|
||||||
|
|
||||||
|
class WorkoutChartStackFavoriteField(models.TextField):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(WorkoutChartStackFavoriteField, 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
|
||||||
|
|
||||||
@@ -1177,6 +1199,10 @@ class Rower(models.Model):
|
|||||||
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'])
|
workoutnametemplate = WorkoutNameTemplateField(default=['date','name','distance','ownerfirst','ownerlast','duration','boattype','workouttype'])
|
||||||
|
chartstacktemplate_x = models.CharField(default='time',verbose_name='X-Axis for Chart Stacked View',max_length=200,
|
||||||
|
choices=(('time', 'Time'),('distance', 'Distance')),)
|
||||||
|
chartstacktemplate_y = WorkoutChartStackFavoriteField(default=['pace','power','hr','spm'],
|
||||||
|
verbose_name='Y-Axis for Chart Stacked View',)
|
||||||
|
|
||||||
# Access tokens
|
# Access tokens
|
||||||
training_plan_code = models.CharField(default='', max_length=200, blank=True, null=True)
|
training_plan_code = models.CharField(default='', max_length=200, blank=True, null=True)
|
||||||
|
|||||||
@@ -41,6 +41,19 @@
|
|||||||
</form>
|
</form>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Use this form to change the default axes for the stacked workout chart.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<table with=100%>
|
||||||
|
{{ stackedchartform.as_table }}
|
||||||
|
</table>
|
||||||
|
<input type="submit" value="Save" class="button"/>
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
|
||||||
<h1>Workout Name Settings of {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
<h1>Workout Name Settings of {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -47,6 +47,13 @@
|
|||||||
<input name="chartform" type="submit"
|
<input name="chartform" type="submit"
|
||||||
value="Update Chart">
|
value="Update Chart">
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<input name="save" value="Update Chart and Save Preferred Metrics"
|
||||||
|
type="submit">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
(This saves your preferred X and Y axes for all workouts.)
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -250,6 +250,27 @@ def rower_favoritecharts_view(request, userid=0):
|
|||||||
staticchartform = StaticChartRowerForm(instance=r)
|
staticchartform = StaticChartRowerForm(instance=r)
|
||||||
datasettingsform = DataRowerForm(instance=r)
|
datasettingsform = DataRowerForm(instance=r)
|
||||||
|
|
||||||
|
xparam = 'time'
|
||||||
|
yparam1 = 'pace'
|
||||||
|
yparam2 = 'power'
|
||||||
|
yparam3 = 'hr'
|
||||||
|
yparam4 = 'spm'
|
||||||
|
|
||||||
|
xparam = r.chartstacktemplate_x
|
||||||
|
yparam1 = r.chartstacktemplate_y[0]
|
||||||
|
yparam2 = r.chartstacktemplate_y[1]
|
||||||
|
yparam3 = r.chartstacktemplate_y[2]
|
||||||
|
yparam4 = r.chartstacktemplate_y[3]
|
||||||
|
|
||||||
|
initial = {
|
||||||
|
'xaxis': xparam,
|
||||||
|
'yaxis1': yparam1,
|
||||||
|
'yaxis2': yparam2,
|
||||||
|
'yaxis3': yparam3,
|
||||||
|
'yaxis4': yparam4,
|
||||||
|
}
|
||||||
|
stackedchartform = StravaChartForm(request, initial=initial)
|
||||||
|
|
||||||
favorites = FavoriteChart.objects.filter(user=r).order_by('id')
|
favorites = FavoriteChart.objects.filter(user=r).order_by('id')
|
||||||
aantal = len(favorites)
|
aantal = len(favorites)
|
||||||
favorites_data = [{'yparam1': f.yparam1,
|
favorites_data = [{'yparam1': f.yparam1,
|
||||||
@@ -272,6 +293,17 @@ def rower_favoritecharts_view(request, userid=0):
|
|||||||
workoutnametemplate_data = [{'element': element} for element in r.workoutnametemplate]
|
workoutnametemplate_data = [{'element': element} for element in r.workoutnametemplate]
|
||||||
workoutnametemplate_formset = WorkoutNameTemplateFormSet(initial=workoutnametemplate_data, prefix='workoutname')
|
workoutnametemplate_formset = WorkoutNameTemplateFormSet(initial=workoutnametemplate_data, prefix='workoutname')
|
||||||
|
|
||||||
|
if request.method == 'POST' and 'yaxis4' in request.POST:
|
||||||
|
stackedchartform = StravaChartForm(request, request.POST)
|
||||||
|
if stackedchartform.is_valid():
|
||||||
|
r.chartstacktemplate_x = stackedchartform.cleaned_data.get('xaxis')
|
||||||
|
r.chartstacktemplate_y = [stackedchartform.cleaned_data.get('yaxis1'),
|
||||||
|
stackedchartform.cleaned_data.get('yaxis2'),
|
||||||
|
stackedchartform.cleaned_data.get('yaxis3'),
|
||||||
|
stackedchartform.cleaned_data.get('yaxis4')]
|
||||||
|
r.save()
|
||||||
|
messages.info(request, "We have updated your stacked chart settings")
|
||||||
|
|
||||||
if request.method == 'POST' and 'workoutname-TOTAL_FORMS' in request.POST:
|
if request.method == 'POST' and 'workoutname-TOTAL_FORMS' in request.POST:
|
||||||
if 'defaults_workoutname' in request.POST:
|
if 'defaults_workoutname' in request.POST:
|
||||||
r.workoutnametemplate = ['date','name','distance','ownerfirst','ownerlast','duration','boattype','workouttype']
|
r.workoutnametemplate = ['date','name','distance','ownerfirst','ownerlast','duration','boattype','workouttype']
|
||||||
@@ -371,6 +403,7 @@ def rower_favoritecharts_view(request, userid=0):
|
|||||||
'favorites_formset': favorites_formset,
|
'favorites_formset': favorites_formset,
|
||||||
'teams': get_my_teams(request.user),
|
'teams': get_my_teams(request.user),
|
||||||
'rower': r,
|
'rower': r,
|
||||||
|
'stackedchartform': stackedchartform,
|
||||||
'staticchartform': staticchartform,
|
'staticchartform': staticchartform,
|
||||||
'datasettingsform': datasettingsform,
|
'datasettingsform': datasettingsform,
|
||||||
'workoutnametemplate_formset': workoutnametemplate_formset,
|
'workoutnametemplate_formset': workoutnametemplate_formset,
|
||||||
|
|||||||
@@ -4240,6 +4240,12 @@ def workout_flexchart_stacked_view(request, *args, **kwargs):
|
|||||||
yparam3 = 'hr'
|
yparam3 = 'hr'
|
||||||
yparam4 = 'spm'
|
yparam4 = 'spm'
|
||||||
|
|
||||||
|
xparam = r.chartstacktemplate_x
|
||||||
|
yparam1 = r.chartstacktemplate_y[0]
|
||||||
|
yparam2 = r.chartstacktemplate_y[1]
|
||||||
|
yparam3 = r.chartstacktemplate_y[2]
|
||||||
|
yparam4 = r.chartstacktemplate_y[3]
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
flexaxesform = StravaChartForm(request, request.POST)
|
flexaxesform = StravaChartForm(request, request.POST)
|
||||||
if flexaxesform.is_valid():
|
if flexaxesform.is_valid():
|
||||||
@@ -4250,6 +4256,11 @@ def workout_flexchart_stacked_view(request, *args, **kwargs):
|
|||||||
yparam3 = cd['yaxis3']
|
yparam3 = cd['yaxis3']
|
||||||
yparam4 = cd['yaxis4']
|
yparam4 = cd['yaxis4']
|
||||||
|
|
||||||
|
if 'save' in request.POST:
|
||||||
|
r.chartstacktemplate_x = xparam
|
||||||
|
r.chartstacktemplate_y = [yparam1, yparam2, yparam3, yparam4]
|
||||||
|
r.save()
|
||||||
|
|
||||||
(
|
(
|
||||||
script, div
|
script, div
|
||||||
) = interactive_flexchart_stacked(
|
) = interactive_flexchart_stacked(
|
||||||
|
|||||||
Reference in New Issue
Block a user