adding grid user settings
This commit is contained in:
@@ -697,6 +697,14 @@ class Rower(models.Model):
|
|||||||
('Workout','Workout'),
|
('Workout','Workout'),
|
||||||
('Yoga','Yoga'),
|
('Yoga','Yoga'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gridtypes = (
|
||||||
|
('none',None),
|
||||||
|
('both','both'),
|
||||||
|
('x','x'),
|
||||||
|
('y','y'),
|
||||||
|
)
|
||||||
|
|
||||||
user = models.OneToOneField(User,on_delete=models.CASCADE)
|
user = models.OneToOneField(User,on_delete=models.CASCADE)
|
||||||
|
|
||||||
#billing details
|
#billing details
|
||||||
@@ -880,6 +888,10 @@ class Rower(models.Model):
|
|||||||
showfavoritechartnotes = models.BooleanField(default=True,
|
showfavoritechartnotes = models.BooleanField(default=True,
|
||||||
verbose_name='Show Notes for Favorite Charts')
|
verbose_name='Show Notes for Favorite Charts')
|
||||||
|
|
||||||
|
# Static chart settings
|
||||||
|
staticgrids = models.CharField(default=None,choices=gridtypes,null=True,max_length=50,
|
||||||
|
verbose_name='Chart Grid')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.first_name+' '+self.user.last_name
|
return self.user.first_name+' '+self.user.last_name
|
||||||
|
|
||||||
@@ -3438,7 +3450,15 @@ class AccountRowerForm(ModelForm):
|
|||||||
if 'coach' not in self.instance.rowerplan:
|
if 'coach' not in self.instance.rowerplan:
|
||||||
self.fields.pop('offercoaching')
|
self.fields.pop('offercoaching')
|
||||||
|
|
||||||
|
# Form to set static chart settings
|
||||||
|
class StaticChartRowerForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Rower
|
||||||
|
fields = ['staticgrids']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(StaticChartRowerForm, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['staticgrids'].required = False
|
||||||
|
|
||||||
|
|
||||||
class UserForm(ModelForm):
|
class UserForm(ModelForm):
|
||||||
|
|||||||
@@ -1902,34 +1902,34 @@ def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename,
|
|||||||
row.df = df
|
row.df = df
|
||||||
nr_rows = len(row.df)
|
nr_rows = len(row.df)
|
||||||
if (plotnr == 1):
|
if (plotnr == 1):
|
||||||
fig1 = row.get_timeplot_erg(t)
|
fig1 = row.get_timeplot_erg(t,**kwargs)
|
||||||
elif (plotnr == 2):
|
elif (plotnr == 2):
|
||||||
fig1 = row.get_metersplot_erg(t)
|
fig1 = row.get_metersplot_erg(t,**kwargs)
|
||||||
elif (plotnr == 3):
|
elif (plotnr == 3):
|
||||||
t += ' - Heart Rate Distribution'
|
t += ' - Heart Rate Distribution'
|
||||||
fig1 = row.get_piechart(t)
|
fig1 = row.get_piechart(t,**kwargs)
|
||||||
elif (plotnr == 4):
|
elif (plotnr == 4):
|
||||||
if haspower:
|
if haspower:
|
||||||
fig1 = row.get_timeplot_otwempower(t)
|
fig1 = row.get_timeplot_otwempower(t,**kwargs)
|
||||||
else:
|
else:
|
||||||
fig1 = row.get_timeplot_otw(t)
|
fig1 = row.get_timeplot_otw(t,**kwargs)
|
||||||
elif (plotnr == 5):
|
elif (plotnr == 5):
|
||||||
if haspower:
|
if haspower:
|
||||||
fig1 = row.get_metersplot_otwempower(t)
|
fig1 = row.get_metersplot_otwempower(t,**kwargs)
|
||||||
else:
|
else:
|
||||||
fig1 = row.get_metersplot_otw(t)
|
fig1 = row.get_metersplot_otw(t,**kwargs)
|
||||||
elif (plotnr == 6):
|
elif (plotnr == 6):
|
||||||
t += ' - Heart Rate Distribution'
|
t += ' - Heart Rate Distribution'
|
||||||
fig1 = row.get_piechart(t)
|
fig1 = row.get_piechart(t,**kwargs)
|
||||||
elif (plotnr == 7) or (plotnr == 10):
|
elif (plotnr == 7) or (plotnr == 10):
|
||||||
fig1 = row.get_metersplot_erg2(t)
|
fig1 = row.get_metersplot_erg2(t,**kwargs)
|
||||||
elif (plotnr == 8) or (plotnr == 11):
|
elif (plotnr == 8) or (plotnr == 11):
|
||||||
fig1 = row.get_timeplot_erg2(t)
|
fig1 = row.get_timeplot_erg2(t,**kwargs)
|
||||||
elif (plotnr == 9) or (plotnr == 12):
|
elif (plotnr == 9) or (plotnr == 12):
|
||||||
fig1 = row.get_time_otwpower(t)
|
fig1 = row.get_time_otwpower(t,**kwargs)
|
||||||
elif (plotnr == 13) or (plotnr == 16):
|
elif (plotnr == 13) or (plotnr == 16):
|
||||||
t += ' - Power Distribution'
|
t += ' - Power Distribution'
|
||||||
fig1 = row.get_power_piechart(t)
|
fig1 = row.get_power_piechart(t,**kwargs)
|
||||||
|
|
||||||
if fig1 is None:
|
if fig1 is None:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -1,8 +1,21 @@
|
|||||||
{% extends "newbase.html" %}
|
{% extends "newbase.html" %}
|
||||||
|
|
||||||
{% block title %}Change Favorite Charts{% endblock %}
|
{% block title %}Change Charts Settings {% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
<h1>Static Charts Settings of {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<table with=100%>
|
||||||
|
{{ staticchartform.as_table }}
|
||||||
|
</table>
|
||||||
|
<input type="submit" value="Save" class="button"/>
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
@@ -10,7 +23,7 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
<div class="fav-form-header">
|
<div class="fav-form-header">
|
||||||
<p><input type="submit" value="Update Favorites" class="button green small"/></p>
|
<p><input type="submit" value="Update Favorites" class="button"/></p>
|
||||||
</div>
|
</div>
|
||||||
{{ favorites_formset.management_form }}
|
{{ favorites_formset.management_form }}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li id="manage-favs">
|
<li id="manage-favs">
|
||||||
<a href="/rowers/me/favoritecharts/">
|
<a href="/rowers/me/favoritecharts/">
|
||||||
<i class="fas fa-chart-area fa-fw"></i> Favorite Charts
|
<i class="fas fa-chart-area fa-fw"></i> Charts Settings
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li id="manage-workflow">
|
<li id="manage-workflow">
|
||||||
|
|||||||
@@ -441,6 +441,13 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
|
|||||||
'pieplot':3,
|
'pieplot':3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
axis = r.staticgrids
|
||||||
|
if axis == None:
|
||||||
|
gridtrue = False
|
||||||
|
axis = 'both'
|
||||||
|
else:
|
||||||
|
gridtrue = True
|
||||||
|
|
||||||
if plotnr == 0:
|
if plotnr == 0:
|
||||||
plotnr = plotnrs[plottype]
|
plotnr = plotnrs[plottype]
|
||||||
|
|
||||||
@@ -450,7 +457,7 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
|
|||||||
|
|
||||||
job = myqueue(queuehigh,handle_makeplot,f1,f2,
|
job = myqueue(queuehigh,handle_makeplot,f1,f2,
|
||||||
title,hrpwrdata,
|
title,hrpwrdata,
|
||||||
plotnr,imagename)
|
plotnr,imagename,gridtrue=gridtrue,axis=axis)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
width,height = Image.open(fullpathimagename).size
|
width,height = Image.open(fullpathimagename).size
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ from rowers.models import (
|
|||||||
VirtualRaceForm,VirtualRaceResultForm,RowerImportExportForm,
|
VirtualRaceForm,VirtualRaceResultForm,RowerImportExportForm,
|
||||||
IndoorVirtualRaceResultForm,IndoorVirtualRaceResult,
|
IndoorVirtualRaceResultForm,IndoorVirtualRaceResult,
|
||||||
IndoorVirtualRaceForm,PlannedSessionCommentForm,
|
IndoorVirtualRaceForm,PlannedSessionCommentForm,
|
||||||
Alert, Condition
|
Alert, Condition, StaticChartRowerForm
|
||||||
)
|
)
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
||||||
|
|||||||
@@ -220,6 +220,9 @@ def rower_favoritecharts_view(request,userid=0):
|
|||||||
message = ''
|
message = ''
|
||||||
successmessage = ''
|
successmessage = ''
|
||||||
r = getrequestrower(request,userid=userid,notpermanent=True)
|
r = getrequestrower(request,userid=userid,notpermanent=True)
|
||||||
|
|
||||||
|
staticchartform = StaticChartRowerForm(instance=r)
|
||||||
|
|
||||||
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,
|
||||||
@@ -234,8 +237,13 @@ def rower_favoritecharts_view(request,userid=0):
|
|||||||
if aantal==0:
|
if aantal==0:
|
||||||
FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet,extra=1)
|
FavoriteChartFormSet = formset_factory(FavoriteForm,formset=BaseFavoriteFormSet,extra=1)
|
||||||
|
|
||||||
|
if request.method == 'POST' and 'staticgrids' in request.POST:
|
||||||
|
staticchartform = StaticChartRowerForm(request.POST,instance=r)
|
||||||
|
if staticchartform.is_valid():
|
||||||
|
r.staticgrids = staticchartform.cleaned_data.get('staticgrids')
|
||||||
|
r.save()
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST' and 'form-TOTAL_FORMS' in request.POST:
|
||||||
favorites_formset = FavoriteChartFormSet(request.POST)
|
favorites_formset = FavoriteChartFormSet(request.POST)
|
||||||
if favorites_formset.is_valid():
|
if favorites_formset.is_valid():
|
||||||
new_instances = []
|
new_instances = []
|
||||||
@@ -275,6 +283,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,
|
||||||
|
'staticchartform':staticchartform,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user