Merge tag 'zipfix2' into develop
zipfix2
This commit is contained in:
@@ -20,6 +20,7 @@ from rowingdata import summarydata,get_file_type
|
|||||||
from scipy.signal import savgol_filter
|
from scipy.signal import savgol_filter
|
||||||
|
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import os
|
||||||
|
|
||||||
def send_confirm(u,name,link):
|
def send_confirm(u,name,link):
|
||||||
fullemail = u.email
|
fullemail = u.email
|
||||||
@@ -98,6 +99,52 @@ def processattachments():
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def processattachments_debug():
|
||||||
|
res = []
|
||||||
|
attachments = MessageAttachment.objects.all()
|
||||||
|
for a in attachments:
|
||||||
|
donotdelete = 1
|
||||||
|
m = Message.objects.get(id=a.message_id)
|
||||||
|
from_address = m.from_address[0]
|
||||||
|
name = m.subject
|
||||||
|
|
||||||
|
# get a list of users
|
||||||
|
theusers = User.objects.filter(email=from_address)
|
||||||
|
print theusers
|
||||||
|
for u in theusers:
|
||||||
|
try:
|
||||||
|
rr = Rower.objects.get(user=u.id)
|
||||||
|
doorgaan = 1
|
||||||
|
except:
|
||||||
|
doorgaan = 0
|
||||||
|
if doorgaan:
|
||||||
|
# move attachment and make workout
|
||||||
|
print a.document
|
||||||
|
print name
|
||||||
|
wid = [make_new_workout_from_email(rr,a.document,name)]
|
||||||
|
res += wid
|
||||||
|
print wid
|
||||||
|
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
||||||
|
dd = send_confirm(u,name,link)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# remove attachment
|
||||||
|
if donotdelete == 0:
|
||||||
|
a.delete()
|
||||||
|
|
||||||
|
if m.attachments.exists()==False:
|
||||||
|
# no attachments, so can be deleted
|
||||||
|
m.delete()
|
||||||
|
|
||||||
|
mm = Message.objects.all()
|
||||||
|
for m in mm:
|
||||||
|
if m.attachments.exists()==False:
|
||||||
|
m.delete()
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
def make_new_workout_from_email(rr,f2,name,cntr=0):
|
def make_new_workout_from_email(rr,f2,name,cntr=0):
|
||||||
workouttype = 'rower'
|
workouttype = 'rower'
|
||||||
f2 = f2.name
|
f2 = f2.name
|
||||||
@@ -105,10 +152,10 @@ def make_new_workout_from_email(rr,f2,name,cntr=0):
|
|||||||
|
|
||||||
if len(fileformat)==3 and fileformat[0]=='zip':
|
if len(fileformat)==3 and fileformat[0]=='zip':
|
||||||
f_to_be_deleted = f2
|
f_to_be_deleted = f2
|
||||||
with zipfile.ZipFile(f2) as z:
|
with zipfile.ZipFile('media/'+f2) as z:
|
||||||
f2 = z.extract(z.namelist()[0],path='media/')
|
f2 = z.extract(z.namelist()[0],path='media/')[6:]
|
||||||
fileformat = fileformat[2]
|
fileformat = fileformat[2]
|
||||||
os.remove(f_to_be_deleted)
|
print f2
|
||||||
|
|
||||||
if fileformat == 'unknown':
|
if fileformat == 'unknown':
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|||||||
Reference in New Issue
Block a user