Merge branch 'release/v5.73'
This commit is contained in:
+25
-6
@@ -72,15 +72,34 @@ 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
|
||||
imagefile = StringIO.StringIO(image_str)
|
||||
image = Image.open(imagefile)
|
||||
for chunk in i.chunks():
|
||||
image_str += chunk
|
||||
|
||||
imagefile = StringIO.StringIO(image_str)
|
||||
|
||||
|
||||
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")
|
||||
|
||||
@@ -89,12 +108,12 @@ def handle_uploaded_image(i):
|
||||
hsize = int((float(image.size[1])*float(wpercent)))
|
||||
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 +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({
|
||||
|
||||
+1
-1
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user