bug fixes
This commit is contained in:
@@ -15,6 +15,7 @@ from rowingdata import rowingdata as rrdata
|
||||
|
||||
from rowingdata import rower as rrower
|
||||
|
||||
import yaml
|
||||
import shutil
|
||||
from shutil import copyfile
|
||||
|
||||
@@ -1469,7 +1470,8 @@ def new_workout_from_file(r, f2,
|
||||
title='Workout',
|
||||
boattype='1x',
|
||||
makeprivate=False,
|
||||
notes=''):
|
||||
notes='',
|
||||
uploadoptions={'boattype':'1x','workouttype':'rower'}):
|
||||
message = ""
|
||||
impeller = False
|
||||
try:
|
||||
@@ -1483,12 +1485,14 @@ def new_workout_from_file(r, f2,
|
||||
oarlength = 2.89
|
||||
inboard = 0.88
|
||||
if len(fileformat) == 3 and fileformat[0] == 'zip':
|
||||
uploadoptions['fromuploadform'] = True
|
||||
bodyyaml = yaml.safe_dump(uploadoptions,default_flow_style=False)
|
||||
f_to_be_deleted = f2
|
||||
impeller = False
|
||||
workoutsbox = Mailbox.objects.filter(name='workouts')[0]
|
||||
msg = Message(mailbox=workoutsbox,
|
||||
from_header=r.user.email,
|
||||
subject = title)
|
||||
subject = title,body=bodyyaml)
|
||||
msg.save()
|
||||
f3 = 'media/mailbox_attachments/'+f2[6:]
|
||||
copyfile(f2,f3)
|
||||
|
||||
@@ -83,6 +83,8 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
users = User.objects.filter(username=uploadoptions['username'])
|
||||
if len(users)==1:
|
||||
therower = users[0].rower
|
||||
elif uploadoptions['username'] == '':
|
||||
therower = rower
|
||||
else:
|
||||
return 0
|
||||
else:
|
||||
@@ -94,7 +96,6 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
uploadoptions['file'] = 'media/'+filename
|
||||
uploadoptions['title'] = title
|
||||
|
||||
|
||||
url = settings.UPLOAD_SERVICE_URL
|
||||
if not testing:
|
||||
response = requests.post(url,data=uploadoptions)
|
||||
@@ -239,7 +240,6 @@ class Command(BaseCommand):
|
||||
attachment.delete()
|
||||
for rower in rowers:
|
||||
if 'zip' in extension:
|
||||
try:
|
||||
zip_file = zipfile.ZipFile(attachment.document)
|
||||
for id,filename in enumerate(zip_file.namelist()):
|
||||
datafile = zip_file.extract(
|
||||
@@ -248,15 +248,11 @@ class Command(BaseCommand):
|
||||
title = name+' ('+str(id+1)+')'
|
||||
else:
|
||||
title = name
|
||||
|
||||
workoutid = processattachment(
|
||||
rower, datafile, title, uploadoptions,
|
||||
testing=testing
|
||||
)
|
||||
print(workoutid)
|
||||
except:
|
||||
print("Bad ZIP file")
|
||||
print(attachment.document.name)
|
||||
|
||||
else:
|
||||
# move attachment and make workout
|
||||
if testing:
|
||||
|
||||
@@ -509,7 +509,7 @@ def make_private(w,options):
|
||||
|
||||
def do_sync(w,options):
|
||||
try:
|
||||
if options['stravaid'] != 0:
|
||||
if options['stravaid'] != 0 and options['stravaid'] != '':
|
||||
w.uploadedtostrava = options['stravaid']
|
||||
options['upload_to_Strava'] = False
|
||||
w.save()
|
||||
|
||||
@@ -52,7 +52,9 @@ def strokedatajson(request,id):
|
||||
POST: Add Stroke data to workout
|
||||
GET: Get stroke data of workout
|
||||
"""
|
||||
row = get_workout_permitted(request.user,id)
|
||||
row = get_object_or_404(Workout,pk=id)
|
||||
if row.user != request.user.rower:
|
||||
raise PermissionDenied("You have no access to this workout")
|
||||
|
||||
try:
|
||||
id = int(id)
|
||||
|
||||
@@ -82,7 +82,7 @@ def workout_strava_upload_view(request,id=0):
|
||||
return HttpResponseRedirect("/rowers/me/stravaauthorize/")
|
||||
else:
|
||||
# ready to upload. Hurray
|
||||
w = get_workout_permitted(request.user,id)
|
||||
w = get_workout_by_opaqueid(request,id)
|
||||
r = w.user
|
||||
|
||||
try:
|
||||
|
||||
@@ -4406,7 +4406,6 @@ def workout_upload_api(request):
|
||||
except (KeyError,JSONDecodeError):
|
||||
post_data = request.POST
|
||||
|
||||
|
||||
# only allow local host
|
||||
hostt = request.get_host().split(':')
|
||||
if hostt[0] not in ['localhost','127.0.0.1','dev.rowsandall.com','rowsandall.com']:
|
||||
@@ -4491,6 +4490,7 @@ def workout_upload_api(request):
|
||||
makeprivate=makeprivate,
|
||||
title = t,
|
||||
notes=notes,
|
||||
uploadoptions=post_data,
|
||||
)
|
||||
|
||||
if id == 0:
|
||||
|
||||
Reference in New Issue
Block a user