From c111803a4af55f8cd1c9fbbc4eb22ecc3eeead0e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 21 Dec 2011 14:55:14 +0530 Subject: [PATCH] Fixed image attachment in profile settings --- .../page/profile_settings/profile_settings.js | 7 +++++- .../page/profile_settings/profile_settings.py | 22 ++++-------------- index.html | 2 +- versions-master.db | Bin 730112 -> 730112 bytes 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/erpnext/home/page/profile_settings/profile_settings.js b/erpnext/home/page/profile_settings/profile_settings.js index 425626b162..bcb39b364a 100644 --- a/erpnext/home/page/profile_settings/profile_settings.js +++ b/erpnext/home/page/profile_settings/profile_settings.js @@ -97,7 +97,12 @@ MyProfile = function(wrapper) { ]); var w = d.widgets['wrapper']; - me.uploader = new Uploader(w, {cmd:'home.page.profile_settings.profile_settings.set_user_image'}, pscript.user_image_upload, 1) + me.uploader = new Uploader(w, + { + modulename:'home.page.profile_settings.profile_settings', + method: 'set_user_image' + }, + pscript.user_image_upload, 1) me.change_dialog = d; } me.change_dialog.show(); diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py index d1e091cad4..ffa0e7f33a 100644 --- a/erpnext/home/page/profile_settings/profile_settings.py +++ b/erpnext/home/page/profile_settings/profile_settings.py @@ -36,24 +36,10 @@ def set_user_details(arg=None): p.save() webnotes.msgprint('Updated') -def set_user_image(arg=None): +def set_user_image(fid, fname): """ Set uploaded image as user image """ - from webnotes.utils.upload_handler import UploadHandler - - uh = UploadHandler() - if not uh.file_name: - # do nothing - no file found - return - else: - # save the file - from webnotes.utils.file_manager import FileAttachments - - fa = FileAttachments('Profile', webnotes.session['user']) - fa.delete_all() - fa.add(uh.file_name, uh.content) - fa.save() - - uh.set_callback('window.parent.upload_callback("%s", "%s")' \ - % (webnotes.form_dict['uploader_id'], fa.get_fid(0))) + from webnotes.utils.file_manager import add_file_list, remove_all + remove_all('Profile', webnotes.session['user']) + add_file_list('Profile', webnotes.session['user'], fname, fid) diff --git a/index.html b/index.html index 72b5ec2566..a085f8cfec 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ ERPNext -