Commit 1e73ab60 authored by Vincent Le gallic's avatar Vincent Le gallic

Changement du protocole d'envoie des photos

parent 7f16244e
......@@ -1149,20 +1149,14 @@ def update_photo(request, idbde=None):
# On envoie la photo au serveur NK
photodata = photo.read()
photob64 = base64.b64encode(photodata)
size = len(photob64)
format = photo.name.rsplit('.',1)[-1]
sock.write(json.dumps(["update_photo", [idbde, size, format]]))
middleanswer = full_read(sock)
if _is_success_code(middleanswer["retcode"]):
sock.write(photob64)
finalanswer = full_read(sock)
if _is_success_code(finalanswer["retcode"]):
_add_success(request, settings.SUCCMSG_PHOTO_UPDATED)
return HttpResponseRedirect('/note/comptes/%s/' % idbde)
else:
_add_error(request, finalanswer["errmsg"])
sock.write(json.dumps(["update_photo", [idbde, photob64, format]]))
answer = full_read(sock)
if _is_success_code(answer["retcode"]):
_add_success(request, settings.SUCCMSG_PHOTO_UPDATED)
return HttpResponseRedirect('/note/comptes/%s/' % idbde)
else:
_add_error(request, middleanswer["errmsg"])
_add_error(request, answer["errmsg"])
else:
form = PhotoForm(label_suffix=" :")
variables["idbde"] = idbde
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment