Private
Public Access
1
0

restricted allowable static images to 6

This commit is contained in:
Sander Roosendaal
2018-01-23 12:09:41 +01:00
parent 585b48cdf6
commit 983b3be86c
3 changed files with 38 additions and 25 deletions

View File

@@ -479,10 +479,6 @@ class Rower(models.Model):
runkeepertoken = models.CharField(default='',max_length=200,
blank=True,null=True)
# runkeepertokenexpirydate = models.DateTimeField(blank=True,null=True)
# runkeeperrefreshtoken = models.CharField(default='',max_length=200,
# blank=True,null=True)
# Plan
plans = (
('basic','basic'),
@@ -856,6 +852,7 @@ class GraphImage(models.Model):
def __str__(self):
return self.filename
# delete related file object when image is deleted
@receiver(models.signals.post_delete,sender=GraphImage)
def auto_delete_image_on_delete(sender,instance, **kwargs):

View File

@@ -280,11 +280,16 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
width = 1200
height = 600
i = GraphImage(workout=w,
creationdatetime=timezone.now(),
filename=fullpathimagename,
width=width,height=height)
i.save()
imgs = GraphImage.objects.filter(workout=w)
if len(imgs) < 7:
i = GraphImage(workout=w,
creationdatetime=timezone.now(),
filename=fullpathimagename,
width=width,height=height)
i.save()
else:
return 0,'You have reached the maximum number of static images for this workout. Delete an image first'
return i.id,job.id

View File

@@ -7112,13 +7112,17 @@ def instroke_chart(request,id=0,metric=''):
width = 1200
height = 600
i = GraphImage(workout=w,
creationdatetime=timezone.now(),
filename=fullpathimagename,
width=width,height=height)
i.save()
print i.id,'aap'
imgs = GraphImage.objects.filter(workout=w)
if len(imgs) < 7:
i = GraphImage(workout=w,
creationdatetime=timezone.now(),
filename=fullpathimagename,
width=width,height=height)
i.save()
else:
messages.error(request,'You have reached the maximum number of static images for this workout. Delete an image first')
r = getrower(request.user)
url = reverse(r.defaultlandingpage,
@@ -8855,10 +8859,13 @@ def workout_add_chart_view(request,id,plotnr=1):
r,w,f1,w.csvfilename,'timeplot',title,plotnr=plotnr,
imagename=imagename
)
try:
request.session['async_tasks'] += [(jobid,'make_plot')]
except KeyError:
request.session['async_tasks'] = [(jobid,'make_plot')]
if res == 0:
messages.error(request,jobid)
else:
try:
request.session['async_tasks'] += [(jobid,'make_plot')]
except KeyError:
request.session['async_tasks'] = [(jobid,'make_plot')]
try:
url = request.session['referer']
@@ -9739,10 +9746,13 @@ def workout_upload_view(request,
r = getrower(request.user)
if (make_plot):
res,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)
try:
request.session['async_tasks'] += [(jobid,'make_plot')]
except KeyError:
request.session['async_tasks'] = [(jobid,'make_plot')]
if res == 0:
messages.error(request,jobid)
else:
try:
request.session['async_tasks'] += [(jobid,'make_plot')]
except KeyError:
request.session['async_tasks'] = [(jobid,'make_plot')]
# upload to C2
if (upload_to_c2):
@@ -9988,7 +9998,8 @@ def team_workout_upload_view(request,message="",
r = getrower(request.user)
if (make_plot):
id = uploads.make_plot(r,w,f1,f2,plottype,t)
id,jobid = uploads.make_plot(r,w,f1,f2,plottype,t)