zip file now with enumerated workout title
This commit is contained in:
@@ -93,6 +93,15 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
return workoutid
|
||||
|
||||
class Command(BaseCommand):
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--testing',
|
||||
action='store_true',
|
||||
dest='testing',
|
||||
default=False,
|
||||
help="Run in testing mode, don't send emails",
|
||||
)
|
||||
|
||||
"""Run the Email processing command """
|
||||
def handle(self, *args, **options):
|
||||
attachments = MessageAttachment.objects.all()
|
||||
@@ -119,9 +128,9 @@ class Command(BaseCommand):
|
||||
for rower in rowers:
|
||||
if extension == 'zip':
|
||||
zip_file = zipfile.ZipFile(attachment.document)
|
||||
for filename in zip_file.namelist():
|
||||
for id,filename in enumerate(zip_file.namelist()):
|
||||
datafile = zip_file.extract(filename, path='media/')
|
||||
title = os.path.basename(datafile)
|
||||
title = name+' ('+str(id)+')'
|
||||
workoutid = processattachment(
|
||||
rower, datafile, title, uploadoptions,
|
||||
testing=testing
|
||||
|
||||
Reference in New Issue
Block a user