Private
Public Access
1
0

Merge branch 'feature/automaticchart' into develop

This commit is contained in:
Sander Roosendaal
2020-11-02 22:16:40 +01:00
4 changed files with 27 additions and 2 deletions
+13 -1
View File
@@ -764,6 +764,14 @@ class Rower(models.Model):
(365,'a year')
)
plotchoices = (
('timeplot','Time Plot'),
('distanceplot','Distance Plot'),
('pieplot','Heart Rate Pie Chart'),
('hrpieplot','Power Pie Chart'),
('None','None'),
)
user = models.OneToOneField(User,on_delete=models.CASCADE)
#billing details
@@ -969,6 +977,10 @@ class Rower(models.Model):
slowpaceotw = models.DurationField(default=otwpaceslow,verbose_name='Slowest OTW Pace')
fastpaceotw = models.DurationField(default=otwpacefast,verbose_name='Fastest OTW Pace')
staticchartonupload = models.CharField(default='None',choices=plotchoices,
max_length=100,
verbose_name='Generate a static chart automatically on upload')
# Auto Join
autojoin = models.BooleanField(default=False,verbose_name='Auto Join Workout Segments')
@@ -3790,7 +3802,7 @@ class AccountRowerForm(ModelForm):
class StaticChartRowerForm(ModelForm):
class Meta:
model = Rower
fields = ['staticgrids','slowpaceerg','fastpaceerg','slowpaceotw','fastpaceotw']
fields = ['staticgrids','slowpaceerg','fastpaceerg','slowpaceotw','fastpaceotw','staticchartonupload']
def __init__(self, *args, **kwargs):
super(StaticChartRowerForm, self).__init__(*args, **kwargs)
+3
View File
@@ -440,6 +440,7 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
'timeplot':1,
'distanceplot':2,
'pieplot':3,
'None':0,
}
axis = r.staticgrids
@@ -451,6 +452,8 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
if plotnr == 0:
plotnr = plotnrs[plottype]
if plotnr == 0:
return 0,0
if w.workouttype in otwtypes:
plotnr = plotnr+3
+1
View File
@@ -245,6 +245,7 @@ def rower_favoritecharts_view(request,userid=0):
r.fastpaceerg = staticchartform.cleaned_data.get('fastpaceerg')
r.slowpaceotw = staticchartform.cleaned_data.get('slowpaceotw')
r.fastpaceotw = staticchartform.cleaned_data.get('fastpaceotw')
r.staticchartonupload = staticchartform.cleaned_data.get('staticchartonupload')
r.save()
if request.method == 'POST' and 'form-TOTAL_FORMS' in request.POST:
+9
View File
@@ -4793,6 +4793,9 @@ def workout_upload_api(request):
if make_plot:
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
elif r.staticchartonupload != 'None':
plottype = r.staticchartonupload
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
uploads.do_sync(w,post_data,quick=True)
@@ -5101,6 +5104,9 @@ def workout_upload_view(request,
request.session['async_tasks'] += [(jobid,'make_plot')]
except KeyError:
request.session['async_tasks'] = [(jobid,'make_plot')]
elif r.staticchartonupload != None:
plottype = r.staticchartonupload
res, jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
# upload to C2
if (upload_to_c2):
@@ -5505,6 +5511,9 @@ def team_workout_upload_view(request,message="",
r = getrower(request.user)
if (make_plot):
id,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
elif r.staticchartonupload:
plottype = r.staticchartonupload
id,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)