Private
Public Access
1
0

Merge branch 'release/v5.73'

This commit is contained in:
Sander Roosendaal
2018-01-23 21:26:38 +01:00
5 changed files with 62 additions and 8 deletions
+24 -5
View File
@@ -72,14 +72,33 @@ def must_be_csv(value):
def handle_uploaded_image(i):
import StringIO
from PIL import Image, ImageOps
from PIL import Image, ImageOps, ExifTags
import os
from django.core.files import File
image_str = ""
for c in i.chunks():
image_str += c
for chunk in i.chunks():
image_str += chunk
imagefile = StringIO.StringIO(image_str)
image = Image.open(imagefile)
image = Image.open(i)
try:
for orientation in ExifTags.TAGS.keys():
if ExifTags.TAGS[orientation]=='Orientation':
break
exif=dict(image._getexif().items())
if exif[orientation] == 3:
image=image.rotate(180, expand=True)
elif exif[orientation] == 6:
image=image.rotate(270, expand=True)
elif exif[orientation] == 8:
image=image.rotate(90, expand=True)
except (AttributeError, KeyError, IndexError):
# cases: image don't have getexif
pass
if image.mode not in ("L", "RGB"):
image = image.convert("RGB")
@@ -90,11 +109,11 @@ def handle_uploaded_image(i):
image = image.resize((basewidth,hsize), Image.ANTIALIAS)
filename = hashlib.md5(imagefile.getvalue()).hexdigest()+'.jpg'
filename2 = os.path.join('static/plots/',filename)
image.save(filename2,'JPEG')
return filename,filename2
-1
View File
@@ -1 +0,0 @@
E408191@CZ27LT9RCGN72.1800:1516641451
+36
View File
@@ -162,6 +162,42 @@
});
});
frm.submit(function() {
console.log("Form submission");
$(data.values()).each(function(value) {
console.log(value);
});
$("#id_drop-files").replaceWith(
'<div id="id_waiting"><img src="/static/img/ajax_loader_blue_350.gif" width="120" height="100">'
);
$.ajax({
data: data,
type: $(this).attr('method'),
url: '/rowers/workout/{{ workout.id }}/image',
contentType: false,
processData: false,
error: function(result) {
$("#id_waiting").replaceWith(
'<div id="id_failed" class="grid_12 alpha message">Your upload failed</div>'
);
setTimeout(function() {
location.reload();
},1000);
},
success: function(result) {
console.log('got something back');
console.log(result);
if (result.result == 1) {
window.location.href = result.url;
} else {
console.log(result," reloading");
location.reload();
};
}
});
return false;
});
$('#id_drop-files').bind({
+1 -1
View File
@@ -8898,7 +8898,7 @@ def workout_uploadimage_view(request,id):
url = reverse(r.defaultlandingpage,
kwargs = {'id':id})
if is_ajax:
return JSONResponse({'result':1,'url':0})
return JSONResponse({'result':1,'url':url})
else:
return HttpResponseRedirect(url)
else:
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB