1
0
forked from ScoDoc/ScoDoc

Fix: change photo

This commit is contained in:
Emmanuel Viennet 2021-07-26 16:23:07 +03:00
parent 4aa073beb3
commit 2b967ba34e
2 changed files with 4 additions and 4 deletions

View File

@ -43,6 +43,7 @@ Les images sont servies par ScoDoc, via la méthode getphotofile?etudid=xxx
"""
import io
import os
import time
import datetime
@ -51,7 +52,6 @@ import six.moves.urllib.request, six.moves.urllib.error, six.moves.urllib.parse
import traceback
from PIL import Image as PILImage
from io import StringIO
import glob
from flask import request
@ -238,7 +238,7 @@ def photo_pathname(context, etud, size="orig"):
def store_photo(context, etud, data, REQUEST=None):
"""Store image for this etud.
If there is an existing photo, it is erased and replaced.
data is a string with image raw data.
data is a bytes string with image raw data.
Update database to store filename.
@ -296,7 +296,7 @@ def save_image(context, etudid, data):
Save image in JPEG in 2 sizes (original and h90).
Returns filename (relative to PHOTO_DIR), without extension
"""
data_file = StringIO()
data_file = io.BytesIO()
data_file.write(data)
data_file.seek(0)
img = PILImage.open(data_file)

View File

@ -791,7 +791,7 @@ def formChangePhoto(context, etudid=None, REQUEST=None):
elif tf[0] == -1:
return REQUEST.RESPONSE.redirect(dest_url)
else:
data = tf[2]["photofile"][0].read()
data = tf[2]["photofile"].read()
status, diag = sco_photos.store_photo(context, etud, data, REQUEST=REQUEST)
if status != 0:
return REQUEST.RESPONSE.redirect(dest_url)