mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 12:49:10 +00:00
data import and upload issues
This commit is contained in:
@@ -108,44 +108,42 @@ MyProfile = function(wrapper) {
|
||||
this.change_image = function() {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Set your Profile'
|
||||
})
|
||||
me.uploader = new Uploader(d.body, {
|
||||
modulename:'home.page.profile_settings.profile_settings',
|
||||
method: 'set_user_image'
|
||||
},
|
||||
pscript.user_image_upload, 1)
|
||||
});
|
||||
|
||||
wn.upload.make({
|
||||
parent: d.body,
|
||||
args: {
|
||||
method: 'home.page.profile_settings.profile_settings.set_user_image'
|
||||
},
|
||||
callback: function(fid) {
|
||||
if(fid) {
|
||||
d.hide();
|
||||
wn.boot.user_info[user].image = 'files/' + fid;
|
||||
pscript.myprofile.img.src = 'files/' + fid;
|
||||
}
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
pscript.open_dialog = d;
|
||||
}
|
||||
|
||||
this.change_background = function() {
|
||||
var d = new wn.widgets.Dialog({
|
||||
title: 'Set Background Image'
|
||||
})
|
||||
me.uploader = new Uploader(d.body, {
|
||||
modulename:'home.page.profile_settings.profile_settings',
|
||||
method: 'set_user_background'
|
||||
},
|
||||
pscript.background_change, 1)
|
||||
|
||||
wn.upload.make({
|
||||
parent: d.body,
|
||||
args: {
|
||||
method: 'home.page.profile_settings.profile_settings.set_user_background'
|
||||
},
|
||||
callback: function(fid) {
|
||||
if(fid) {
|
||||
d.hide();
|
||||
erpnext.set_user_background(fid);
|
||||
}
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
pscript.open_dialog = d;
|
||||
}
|
||||
this.make();
|
||||
}
|
||||
|
||||
pscript.background_change = function(fid) {
|
||||
msgprint('File Uploaded');
|
||||
if(fid) {
|
||||
erpnext.set_user_background(fid);
|
||||
pscript.open_dialog.hide();
|
||||
}
|
||||
}
|
||||
|
||||
pscript.user_image_upload = function(fid) {
|
||||
msgprint('File Uploaded');
|
||||
if(fid) {
|
||||
pscript.open_dialog.hide();
|
||||
wn.boot.user_info[user].image = 'files/' + fid;
|
||||
pscript.myprofile.img.src = 'files/' + fid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,14 +64,16 @@ def set_user_details(arg=None):
|
||||
webnotes.msgprint('Updated')
|
||||
|
||||
@webnotes.whitelist()
|
||||
def set_user_image(fid, fname):
|
||||
def set_user_image():
|
||||
"""
|
||||
Set uploaded image as user image
|
||||
"""
|
||||
check_demo()
|
||||
from webnotes.utils.file_manager import add_file_list, remove_file
|
||||
from webnotes.utils.file_manager import add_file_list, remove_file, save_uploaded
|
||||
user = webnotes.session['user']
|
||||
|
||||
|
||||
fid, fname = save_uploaded()
|
||||
|
||||
# remove old file
|
||||
old_image = webnotes.conn.get_value('Profile', user, 'user_image')
|
||||
if old_image:
|
||||
@@ -80,15 +82,19 @@ def set_user_image(fid, fname):
|
||||
# add new file
|
||||
add_file_list('Profile', user, fname, fid)
|
||||
webnotes.conn.set_value('Profile', user, 'user_image', fid)
|
||||
|
||||
return fid
|
||||
|
||||
@webnotes.whitelist()
|
||||
def set_user_background(fid, fname):
|
||||
def set_user_background():
|
||||
"""
|
||||
Set uploaded image as user image
|
||||
"""
|
||||
check_demo()
|
||||
from webnotes.utils.file_manager import add_file_list, remove_file
|
||||
from webnotes.utils.file_manager import add_file_list, remove_file, save_uploaded
|
||||
user = webnotes.session['user']
|
||||
|
||||
fid, fname = save_uploaded()
|
||||
|
||||
# remove old file
|
||||
old_image = webnotes.conn.get_value('Profile', user, 'background_image')
|
||||
@@ -98,3 +104,5 @@ def set_user_background(fid, fname):
|
||||
# add new file
|
||||
add_file_list('Profile', user, fname, fid)
|
||||
webnotes.conn.set_value('Profile', user, 'background_image', fid)
|
||||
|
||||
return fid
|
||||
|
||||
Reference in New Issue
Block a user