Merge branch 'release/v5.73'
This commit is contained in:
+24
-5
@@ -72,14 +72,33 @@ def must_be_csv(value):
|
|||||||
|
|
||||||
def handle_uploaded_image(i):
|
def handle_uploaded_image(i):
|
||||||
import StringIO
|
import StringIO
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps, ExifTags
|
||||||
import os
|
import os
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
image_str = ""
|
image_str = ""
|
||||||
for c in i.chunks():
|
for chunk in i.chunks():
|
||||||
image_str += c
|
image_str += chunk
|
||||||
|
|
||||||
imagefile = StringIO.StringIO(image_str)
|
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"):
|
if image.mode not in ("L", "RGB"):
|
||||||
image = image.convert("RGB")
|
image = image.convert("RGB")
|
||||||
@@ -90,11 +109,11 @@ def handle_uploaded_image(i):
|
|||||||
image = image.resize((basewidth,hsize), Image.ANTIALIAS)
|
image = image.resize((basewidth,hsize), Image.ANTIALIAS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
filename = hashlib.md5(imagefile.getvalue()).hexdigest()+'.jpg'
|
filename = hashlib.md5(imagefile.getvalue()).hexdigest()+'.jpg'
|
||||||
|
|
||||||
filename2 = os.path.join('static/plots/',filename)
|
filename2 = os.path.join('static/plots/',filename)
|
||||||
image.save(filename2,'JPEG')
|
image.save(filename2,'JPEG')
|
||||||
|
|
||||||
return filename,filename2
|
return filename,filename2
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
E408191@CZ27LT9RCGN72.1800:1516641451
|
|
||||||
@@ -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({
|
$('#id_drop-files').bind({
|
||||||
|
|||||||
+1
-1
@@ -8898,7 +8898,7 @@ def workout_uploadimage_view(request,id):
|
|||||||
url = reverse(r.defaultlandingpage,
|
url = reverse(r.defaultlandingpage,
|
||||||
kwargs = {'id':id})
|
kwargs = {'id':id})
|
||||||
if is_ajax:
|
if is_ajax:
|
||||||
return JSONResponse({'result':1,'url':0})
|
return JSONResponse({'result':1,'url':url})
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user