Private
Public Access
1
0

background processed email now create Django_Mailbox message object

This commit is contained in:
Sander Roosendaal
2017-11-07 11:15:35 +01:00
parent 212f6b323c
commit 4f9539835f
2 changed files with 20 additions and 6 deletions

View File

@@ -305,6 +305,7 @@ def handle_zip_file(emailfrom, subject, file,**kwargs):
if debug:
print message
email = EmailMessage(subject, message,
emailfrom,
['workouts@rowsandall.com'])

View File

@@ -143,6 +143,8 @@ from rq.registry import StartedJobRegistry
from rq import Queue,cancel_job
from django.core.cache import cache
from django_mailbox.models import Message,Mailbox,MessageAttachment
# Utility to get stroke data in a JSON response
class JSONResponse(HttpResponse):
@@ -8548,12 +8550,23 @@ def workout_upload_view(request,
notes=''
)
else:
job = myqueue(
queuehigh,
handle_zip_file,
r.user.email,
t,
f2)
workoutsbox = Mailbox.objects.filter(name='workouts')[0]
msg = Message(mailbox=workoutsbox,
from_header=r.user.email,
subject = t)
msg.save()
f3 = 'media/mailbox_attachments/'+f2[6:]
copyfile(f2,f3)
f3 = f3[6:]
a = MessageAttachment(message=msg,document=f3)
a.save()
os.remove(f2)
# job = myqueue(
# queuehigh,
# handle_zip_file,
# r.user.email,
# t,
# f2)
messages.info(
request,