diff --git a/erpnext/home/page/activity/activity.js b/erpnext/home/page/activity/activity.js
index b14f1f87bad..d72c7aeab49 100644
--- a/erpnext/home/page/activity/activity.js
+++ b/erpnext/home/page/activity/activity.js
@@ -14,7 +14,7 @@ erpnext.ActivityFeed = Class.extend({
init: function(row, data) {
this.scrub_data(data);
this.add_date_separator(row, data);
- $(row).append(repl('%(feed_type)s\
%(link)s %(subject)s %(by)s', data));
},
diff --git a/erpnext/home/page/profile_settings/profile_settings.js b/erpnext/home/page/profile_settings/profile_settings.js
index 9dac7f6f1d5..8ce94f84390 100644
--- a/erpnext/home/page/profile_settings/profile_settings.js
+++ b/erpnext/home/page/profile_settings/profile_settings.js
@@ -26,13 +26,15 @@ MyProfile = function(wrapper) {
this.make = function() {
this.head = new PageHeader(this.wrapper, 'My Profile Settings');
- this.head.add_button('Change Password', this.change_password)
+ this.head.add_button('Change Password', this.change_password);
+ this.head.add_button('Change Background', this.change_background);
+
this.tab = make_table($a(this.wrapper, 'div', '', {marginTop:'19px'}),
1, 2, '90%', ['50%', '50%'], {padding:'11px'})
this.img = $a($td(this.tab, 0, 0), 'img');
set_user_img(this.img, user);
- $btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image)
+ $btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image);
this.make_form();
this.load_details();
@@ -105,32 +107,42 @@ MyProfile = function(wrapper) {
//
this.change_image = function() {
- if(!me.change_dialog) {
-
- var d = new Dialog(400,200,'Set Your Profile Image');
- d.make_body([
- ['HTML','wrapper']
- ]);
-
- var w = d.widgets['wrapper'];
- 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();
+ 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)
+ 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)
+ d.show();
+ pscript.open_dialog = d;
}
this.make();
}
+pscript.background_change = function(fid) {
+ //erpnext.set_background_image(fid);
+ pscript.open_dialog.hide();
+}
+
pscript.user_image_upload = function(fid) {
msgprint('File Uploaded');
-
if(fid) {
- pscript.myprofile.change_dialog.hide();
+ pscript.open_dialog.hide();
set_user_img(pscript.myprofile.img, user, null, fid);
}
}
diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py
index f614c75ff41..fb633fdb192 100644
--- a/erpnext/home/page/profile_settings/profile_settings.py
+++ b/erpnext/home/page/profile_settings/profile_settings.py
@@ -63,6 +63,31 @@ def set_user_image(fid, fname):
"""
Set uploaded image as user image
"""
- 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)
+ from webnotes.utils.file_manager import add_file_list, remove_file
+ user = webnotes.session['user']
+
+ # remove old file
+ old_image = webnotes.conn.get_value('Profile', user, 'user_image')
+ if old_image:
+ remove_file('Profile', user, old_image)
+
+ # add new file
+ add_file_list('Profile', user, fname, fid)
+ webnotes.conn.set_value('Profile', user, 'user_image', fid)
+
+@webnotes.whitelist()
+def set_user_background(fid, fname):
+ """
+ Set uploaded image as user image
+ """
+ from webnotes.utils.file_manager import add_file_list, remove_file
+ user = webnotes.session['user']
+
+ # remove old file
+ old_image = webnotes.conn.get_value('Profile', user, 'background_image')
+ if old_image:
+ remove_file('Profile', user, old_image)
+
+ # add new file
+ add_file_list('Profile', user, fname, fid)
+ webnotes.conn.set_value('Profile', user, 'background_image', fid)
diff --git a/erpnext/patches/jan_mar_2012/navupdate.py b/erpnext/patches/jan_mar_2012/navupdate.py
index 18338dd1ed5..29939e5aa71 100644
--- a/erpnext/patches/jan_mar_2012/navupdate.py
+++ b/erpnext/patches/jan_mar_2012/navupdate.py
@@ -35,6 +35,7 @@ def execute():
reload_doc('setup', 'page', 'modules_setup')
reload_doc('utilities', 'page', 'users')
reload_doc('home', 'page', 'activity')
+ reload_doc('core', 'doctype', 'profile')
webnotes.conn.set_value('Control Panel', 'Control Panel', 'home_page',
'desktop')
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index 79fd60312ac..dca9e0c6f60 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -93,6 +93,8 @@ def boot_session(bootinfo):
# if no company, show a dialog box to create a new company
bootinfo['setup_complete'] = webnotes.conn.sql("""select name from
tabCompany limit 1""") and 'Yes' or 'No'
+
+ bootinfo['user_background'] = webnotes.conn.get_value("Profile", webnotes.session['user'], 'background_image') or ''
def get_letter_heads():
"""load letter heads with startup"""
diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js
index aef298cbd2b..ad8289e9d5d 100644
--- a/erpnext/startup/startup.js
+++ b/erpnext/startup/startup.js
@@ -50,6 +50,9 @@ erpnext.startup.start = function() {
if(wn.boot.custom_css) {
set_style(wn.boot.custom_css);
}
+ if(wn.boot.user_background) {
+ erpnext.set_user_background(wn.boot.user_background);
+ }
if(user == 'Guest'){
if(wn.boot.website_settings.title_prefix) {
@@ -132,6 +135,10 @@ erpnext.startup.set_periodic_updates = function() {
wn.updates.id = setInterval(update_messages, 60000);
}
+erpnext.set_user_background = function(src) {
+ set_style(repl('body { background: url("files/%(src)s") repeat !important;}', {src:src}))
+}
+
// =======================================
// start
diff --git a/erpnext/website/doctype/style_settings/custom_template.css b/erpnext/website/doctype/style_settings/custom_template.css
index e6eeeb34fac..8eb3d6396f5 100644
--- a/erpnext/website/doctype/style_settings/custom_template.css
+++ b/erpnext/website/doctype/style_settings/custom_template.css
@@ -1,6 +1,6 @@
body {
{% if doc.background_image %}
- background: url("files/{{ doc.background_image }}") repeat !important;
+ background: url("files/{{ doc.background_image }}") repeat;
{% elif doc.background_color %}
background-color: #{{ doc.background_color }};
{% endif %}
diff --git a/js/all-app.js b/js/all-app.js
index 09e92a504f8..e5e796783e3 100644
--- a/js/all-app.js
+++ b/js/all-app.js
@@ -129,13 +129,13 @@ return output.join('');};str_format.cache={};str_format.parse=function(fmt){var
else if((match=/^\x25{2}/.exec(_fmt))!==null){parse_tree.push('%');}
else if((match=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt))!==null){if(match[2]){arg_names|=1;var field_list=[],replacement_field=match[2],field_match=[];if((field_match=/^([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);while((replacement_field=replacement_field.substring(field_match[0].length))!==''){if((field_match=/^\.([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);}
else if((field_match=/^\[(\d+)\]/.exec(replacement_field))!==null){field_list.push(field_match[1]);}
-else{}}}
-else{}
+else{throw('[sprintf] huh?');}}}
+else{throw('[sprintf] huh?');}
match[2]=field_list;}
else{arg_names|=2;}
if(arg_names===3){throw('[sprintf] mixing positional and named placeholders is not (yet) supported');}
parse_tree.push(match);}
-else{}
+else{throw('[sprintf] huh?');}
_fmt=_fmt.substring(match[0].length);}
return parse_tree;};return str_format;})();var vsprintf=function(fmt,argv){argv.unshift(fmt);return sprintf.apply(null,argv);};
/*
@@ -280,7 +280,9 @@ var lstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var first_char=s.su
return s;}
var rstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var last_char=s.substr(s.length-1);while(in_list(chars,last_char)){var s=s.substr(0,this.length-1);last_char=s.substr(this.length-1);}
return s;}
-function repl(s,dict){return sprintf(s,dict);}
+function repl_all(s,s1,s2){var idx=s.indexOf(s1);while(idx!=-1){s=s.replace(s1,s2);idx=s.indexOf(s1);}
+return s;}
+function repl(s,dict){if(s==null)return'';for(key in dict)s=repl_all(s,'%('+key+')s',dict[key]);return s;}
function keys(obj){var mykeys=[];for(key in obj)mykeys[mykeys.length]=key;return mykeys;}
function values(obj){var myvalues=[];for(key in obj)myvalues[myvalues.length]=obj[key];return myvalues;}
function in_list(list,item){for(var i=0;i