Private
Public Access
1
0

Merge branch 'release/v5.05'

This commit is contained in:
Sander Roosendaal
2017-11-10 14:17:18 +01:00
8 changed files with 56 additions and 24 deletions

View File

@@ -847,11 +847,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
return (w.id, message)
def handle_nonpainsled(f2, fileformat, summary=''):
oarlength = 2.89
inboard = 0.88
hasrecognized = False
def parsenonpainsled(fileformat,f2,summary):
# handle RowPro:
if (fileformat == 'rp'):
row = RowProParser(f2)
@@ -936,6 +932,20 @@ def handle_nonpainsled(f2, fileformat, summary=''):
summary = s.summarytext
except:
pass
hasrecognized = True
return row,hasrecognized,summary
def handle_nonpainsled(f2, fileformat, summary=''):
oarlength = 2.89
inboard = 0.88
hasrecognized = False
try:
row,hasrecognized,summary = parsenonpainsled(fileformat,f2,summary)
except:
pass
# Handle c2log
if (fileformat == 'c2log' or fileformat == 'rowprolog'):

View File

@@ -7,7 +7,12 @@ from rowers.tasks import (
handle_sendemail_unrecognized,
handle_sendemail_unrecognizedowner
)
from django_mailbox.models import Message, MessageAttachment
from django_mailbox.models import Message, MessageAttachment,Mailbox
workoutmailbox = Mailbox.objects.get(name='workouts')
failedmailbox = Mailbox.objects.get(name='Failed')
from rowers.models import User, Rower, RowerForm
from django.core.mail import EmailMessage
@@ -148,7 +153,7 @@ def make_new_workout_from_email(rower, datafile, name, cntr=0,testing=False):
dosummary = (fileformat != 'fit')
if name == '':
name = 'imported through email'
name = 'Workout from Background Queue'
id, message = dataprep.save_workout_database(
datafilename, rower,

View File

@@ -9,7 +9,7 @@ import time
from time import strftime
from django.core.management.base import BaseCommand
from django_mailbox.models import Message, MessageAttachment
from django_mailbox.models import Message, MessageAttachment,Mailbox
from django.core.urlresolvers import reverse
from django.conf import settings
@@ -21,6 +21,9 @@ from rowingdata import rowingdata as rrdata
import rowers.uploads as uploads
from rowers.mailprocessing import make_new_workout_from_email, send_confirm
workoutmailbox = Mailbox.objects.get(name='workouts')
failedmailbox = Mailbox.objects.get(name='Failed')
# If you find a solution that does not need the two paths, please comment!
sys.path.append('$path_to_root_of_project$')
sys.path.append('$path_to_root_of_project$/$project_name$')
@@ -104,7 +107,11 @@ class Command(BaseCommand):
"""Run the Email processing command """
def handle(self, *args, **options):
attachments = MessageAttachment.objects.all()
messages = Message.objects.filter(mailbox_id = workoutmailbox.id)
message_ids = [m.id for m in messages]
attachments = MessageAttachment.objects.filter(
message_id__in=message_ids
)
if 'testing' in options:
testing = options['testing']
else:
@@ -114,10 +121,14 @@ class Command(BaseCommand):
extension = attachment.document.name[-3:].lower()
try:
message = Message.objects.get(id=attachment.message_id)
#if message.text:
# body = "\n".join(message.text.splitlines())
#else:
body = message.get_body()
if message.encoded:
# if message.text:
body = "\n".join(message.text.splitlines())
else:
body = message.get_body()
uploadoptions = uploads.upload_options(body)
from_address = message.from_address[0].lower()
@@ -162,6 +173,9 @@ class Command(BaseCommand):
attachment.delete()
except WindowsError:
pass
except:
message.mailbox = failedmailbox
message.save()
if message.attachments.exists() is False:
# no attachments, so can be deleted

View File

@@ -209,11 +209,14 @@
},
success: function(result) {
console.log('got something back');
console.log(result);
console.log(result);
if (result.result == 1) {
window.location.href = result.url;
}
}
window.location.href = result.url;
} else {
console.log(result," reloading");
location.reload();
};
}
});
return false;
});

BIN
rowers/testdata/emails/noname vendored Normal file

Binary file not shown.

View File

@@ -48,12 +48,6 @@ class DjangoTestCase(TestCase, MockTestCase):
# Create your tests here.
class EmailProcessTest(TestCase):
def test_emailprocessing(self):
out = StringIO()
call_command('processemail', stdout=out)
self.assertIn('Successfully processed email attachments',out.getvalue())
class C2Objects(DjangoTestCase):
def test_strokedata(self):
with open('rowers/testdata/c2stroketestdata.txt','r') as infile:
@@ -336,11 +330,16 @@ class EmailTests(TestCase):
nu = datetime.datetime.now()
workoutsbox = Mailbox.objects.create(name='workouts')
workoutsbox.save()
failbox = Mailbox.objects.create(name='Failed')
failbox.save()
for filename in os.listdir('rowers/testdata/emails'):
m = Message(mailbox=workoutsbox,
from_header = u.email,
subject = filename)
subject = filename,
body="""
chart time
""")
m.save()
a2 = 'media/mailbox_attachments/'+filename
copyfile('rowers/testdata/emails/'+filename,a2)

View File

@@ -8495,6 +8495,7 @@ def workout_upload_view(request,
except KeyError:
upload_to_tp = False
response = {}
if request.method == 'POST':
form = DocumentsForm(request.POST,request.FILES)
optionsform = UploadOptionsForm(request.POST)

BIN
static/img/praha.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB