Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
3c67b3dae8
@ -1,4 +1,7 @@
|
||||
erpnext.updates = [
|
||||
["28th November 2012", [
|
||||
"Profile: Profile Settings (My Settings...) is now the Profile Form.",
|
||||
]],
|
||||
["27th November 2012", [
|
||||
"Communication: Made common communication thread and added it in Lead, Contact.",
|
||||
]],
|
||||
|
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,5 +0,0 @@
|
||||
<div class="layout-wrapper layout-wrapper-appframe">
|
||||
<div class="layout-appframe"></div>
|
||||
<div class="layout-main">
|
||||
</div>
|
||||
</div>
|
@ -1,188 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pscript['onload_profile-settings'] = function() {
|
||||
var wrapper = wn.pages['profile-settings'];
|
||||
pscript.myprofile = new MyProfile(wrapper)
|
||||
}
|
||||
|
||||
MyProfile = function(wrapper) {
|
||||
this.wrapper = wrapper;
|
||||
var me = this;
|
||||
|
||||
this.make = function() {
|
||||
this.wrapper.appframe = new wn.ui.AppFrame($(this.wrapper).find('.layout-appframe'), 'Profile Settings');
|
||||
this.wrapper.appframe.add_button('Update', this.update_profile);
|
||||
this.wrapper.appframe.buttons["Update"].addClass("btn-info");
|
||||
this.wrapper.appframe.add_button('Change Password', this.change_password);
|
||||
|
||||
$(this.wrapper).find('.layout-main').html("<h4>Personal</h4>\
|
||||
<div class='personal-settings' style='margin-left: 15px;'></div>\
|
||||
<hr>\
|
||||
<!--<h4>Email</h4>\
|
||||
<div class='email-settings' style='margin-left: 15px;'></div>\
|
||||
<hr>-->\
|
||||
<h4>Display</h4>\
|
||||
<div class='display-settings' style='margin-left: 15px;'>\
|
||||
<p>Change Background: <button class='btn btn-small change-background'>Upload</button></p>\
|
||||
<br><p>Change Theme: <select class='change-theme'></select></p>\
|
||||
</div>");
|
||||
|
||||
this.make_display();
|
||||
this.make_personal();
|
||||
}
|
||||
|
||||
this.make_display = function() {
|
||||
$(this.wrapper).find(".change-background")
|
||||
.click(me.change_background)
|
||||
|
||||
$(this.wrapper).find(".change-theme")
|
||||
.add_options(keys(erpnext.themes).sort())
|
||||
.change(function() {
|
||||
erpnext.set_theme($(this).val());
|
||||
}).val(wn.boot.profile.defaults.theme ?
|
||||
wn.boot.profile.defaults.theme[0] : "Default")
|
||||
.change(function() {
|
||||
wn.call({
|
||||
module: "home",
|
||||
page: "profile_settings",
|
||||
method: "set_user_theme",
|
||||
args: {theme: $(this).val() }
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
this.make_personal = function() {
|
||||
this.personal = $(this.wrapper).find('.personal-settings').html('<div \
|
||||
class="pull-left" style="width: 300px;">\
|
||||
<img style="max-width: 200px;" src='+wn.user_info(user).image+'><br><br>\
|
||||
<button class="btn btn-small">Change Image</button><br><br>\
|
||||
</div><div class="pull-left profile-form" style="width: 45%; margin-top: -11px;">\
|
||||
<div class="clear"></div>\
|
||||
</div>')
|
||||
|
||||
this.personal.find("button").click(this.change_image);
|
||||
this.make_form();
|
||||
this.load_details();
|
||||
}
|
||||
|
||||
this.load_details = function() {
|
||||
$c_page('home','profile_settings','get_user_details','',function(r, rt) {
|
||||
me.form.set_values(r.message);
|
||||
})
|
||||
}
|
||||
|
||||
//
|
||||
// form
|
||||
//
|
||||
this.make_form = function() {
|
||||
var div = this.personal.find(".profile-form").get(0);
|
||||
this.form = new wn.ui.FieldGroup({
|
||||
parent: div,
|
||||
fields: [
|
||||
{fieldname:'first_name', fieldtype:'Data',label:'First Name',reqd:1},
|
||||
{fieldname:'last_name', fieldtype:'Data',label:'Last Name'},
|
||||
{fieldname:'email_signature', fieldtype:'Small Text',label:'Email Signature',
|
||||
decription:'Will be appended to outgoing mail'},
|
||||
]
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.update_profile = function() {
|
||||
var v = me.form.get_values();
|
||||
if(v) {
|
||||
$(this).set_working();
|
||||
var btn = this;
|
||||
$c_page('home','profile_settings','set_user_details',v,function(r, rt) {
|
||||
$(btn).done_working();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.change_password = function() {
|
||||
var d = new wn.ui.Dialog({
|
||||
title:'Change Password',
|
||||
width: 400,
|
||||
fields: [
|
||||
{fieldname:'old_password', fieldtype:'Password', label:'Old Password', reqd:1 },
|
||||
{fieldname:'new_password', fieldtype:'Password', label:'New Password', reqd:1 },
|
||||
{fieldname:'new_password1', fieldtype:'Password', label:'Re-type New Password', reqd:1 },
|
||||
{fieldname:'change', fieldtype:'Button', label:'Change'}
|
||||
]
|
||||
})
|
||||
d.fields_dict.change.input.onclick = function() {
|
||||
var v = d.get_values();
|
||||
if(v) {
|
||||
if(v.new_password != v.new_password1) {
|
||||
msgprint('Passwords must match'); return;
|
||||
}
|
||||
this.set_working();
|
||||
$c_page('home','profile_settings','change_password',v,function(r,rt) {
|
||||
if(!r.message && r.exc) { msgprint(r.exc); return; }
|
||||
d.hide();
|
||||
})
|
||||
}
|
||||
}
|
||||
d.show();
|
||||
}
|
||||
|
||||
//
|
||||
// change image
|
||||
//
|
||||
|
||||
this.change_image = function() {
|
||||
var d = new wn.ui.Dialog({
|
||||
title: 'Set your Profile'
|
||||
});
|
||||
|
||||
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;
|
||||
me.personal.find("img").attr("src", 'files/' + fid);
|
||||
}
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
|
||||
this.change_background = function() {
|
||||
var d = new wn.ui.Dialog({
|
||||
title: 'Set Background Image'
|
||||
})
|
||||
|
||||
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();
|
||||
}
|
||||
this.make();
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import load_json, cint, nowdate
|
||||
|
||||
|
||||
def check_demo():
|
||||
demo_user = 'demo@erpnext.com'
|
||||
if webnotes.session['user']==demo_user:
|
||||
webnotes.msgprint("Can't change in demo", raise_exception=1)
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
def change_password(arg):
|
||||
"""
|
||||
Change password
|
||||
"""
|
||||
check_demo()
|
||||
arg = load_json(arg)
|
||||
|
||||
if not webnotes.conn.sql("""select * from `__Auth` where `user`=%s
|
||||
and password=password(%s)""",
|
||||
(webnotes.session["user"], arg["old_password"])):
|
||||
webnotes.msgprint('Old password is not correct', raise_exception=1)
|
||||
|
||||
webnotes.conn.sql("""update `__Auth` set password=password(%s)
|
||||
where `user`=%s""", (arg["new_password"], webnotes.session["user"]))
|
||||
|
||||
webnotes.msgprint('Password Updated');
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_user_details(arg=None):
|
||||
"""
|
||||
Returns user first name, last name and bio
|
||||
"""
|
||||
return webnotes.conn.sql("""select first_name, last_name, bio, email_signature
|
||||
from tabProfile where name=%s""", webnotes.user.name, as_dict=1)[0]
|
||||
|
||||
@webnotes.whitelist()
|
||||
def set_user_details(arg=None):
|
||||
"""
|
||||
updates user details given in argument
|
||||
"""
|
||||
check_demo()
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
p = Document('Profile', webnotes.user.name)
|
||||
arg_dict = load_json(arg)
|
||||
if not 'bio' in arg_dict: arg_dict['bio'] = None
|
||||
if not 'last_name' in arg_dict: arg_dict['last_name'] = None
|
||||
if not 'email_signature' in arg_dict: arg_dict['email_signature'] = None
|
||||
p.fields.update(arg_dict)
|
||||
p.save()
|
||||
webnotes.msgprint('Updated')
|
||||
|
||||
@webnotes.whitelist()
|
||||
def set_user_image():
|
||||
"""
|
||||
Set uploaded image as user image
|
||||
"""
|
||||
check_demo()
|
||||
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:
|
||||
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)
|
||||
|
||||
return fid
|
||||
|
||||
@webnotes.whitelist()
|
||||
def set_user_background():
|
||||
"""
|
||||
Set uploaded image as user image
|
||||
"""
|
||||
check_demo()
|
||||
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')
|
||||
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)
|
||||
|
||||
return fid
|
||||
|
||||
@webnotes.whitelist()
|
||||
def set_user_theme():
|
||||
webnotes.conn.set_default("theme", webnotes.form_dict.theme, webnotes.session.user)
|
@ -1,27 +0,0 @@
|
||||
# Page, profile-settings
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-04-18 10:19:10',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-04-13 12:08:59',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Home',
|
||||
'name': '__common__',
|
||||
'page_name': 'Profile Settings',
|
||||
'standard': 'Yes'
|
||||
},
|
||||
|
||||
# Page, profile-settings
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'profile-settings'
|
||||
}
|
||||
]
|
13
patches/november_2012/add_theme_to_profile.py
Normal file
13
patches/november_2012/add_theme_to_profile.py
Normal file
@ -0,0 +1,13 @@
|
||||
import webnotes
|
||||
|
||||
def execute():
|
||||
webnotes.clear_perms("Profile")
|
||||
webnotes.reload_doc("core", "doctype", "profile")
|
||||
|
||||
for name in webnotes.conn.sql("""select name from tabProfile"""):
|
||||
theme = webnotes.conn.get_default("theme", name[0])
|
||||
if theme:
|
||||
webnotes.conn.set_value("Profile", name[0], "theme", theme)
|
||||
|
||||
webnotes.conn.sql("""delete from `tabDefaultValue` where defkey='theme'""")
|
||||
webnotes.delete_doc("Page", "profile-settings")
|
@ -695,4 +695,8 @@ patch_list = [
|
||||
'patch_module': 'patches.november_2012',
|
||||
'patch_file': 'update_delivered_billed_percentage_for_pos',
|
||||
},
|
||||
{
|
||||
'patch_module': 'patches.november_2012',
|
||||
'patch_file': 'add_theme_to_profile',
|
||||
},
|
||||
]
|
@ -12,7 +12,6 @@
|
||||
],
|
||||
"public/js/all-app.js": [
|
||||
"app/public/js/modules.js",
|
||||
"app/public/js/themes.js",
|
||||
"app/public/js/toolbar.js",
|
||||
"app/public/js/feature_setup.js",
|
||||
"app/public/js/utils.js"
|
||||
|
@ -27,17 +27,9 @@ erpnext.startup.start = function() {
|
||||
console.log('Starting up...');
|
||||
$('#startup_div').html('Starting up...').toggle(true);
|
||||
|
||||
|
||||
erpnext.startup.set_globals();
|
||||
|
||||
if(user != 'Guest'){
|
||||
if(wn.boot.user_background) {
|
||||
erpnext.set_user_background(wn.boot.user_background);
|
||||
}
|
||||
if(wn.boot.profile.defaults.theme) {
|
||||
erpnext.set_theme(wn.boot.profile.defaults.theme[0]);
|
||||
}
|
||||
|
||||
erpnext.setup_mousetrap();
|
||||
|
||||
// always allow apps
|
||||
@ -143,11 +135,6 @@ erpnext.startup.set_periodic_updates = function() {
|
||||
wn.updates.id = setInterval(erpnext.update_messages, 60000);
|
||||
}
|
||||
|
||||
erpnext.set_user_background = function(src) {
|
||||
set_style(repl('#body_div { background: url("files/%(src)s") repeat fixed;}',
|
||||
{src:src}))
|
||||
}
|
||||
|
||||
// subject, sender, description
|
||||
erpnext.send_message = function(opts) {
|
||||
if(opts.btn) {
|
||||
|
@ -1,69 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// theme setter
|
||||
|
||||
erpnext.themes = {
|
||||
"Default": {
|
||||
sidebar: "#f2f2f2",
|
||||
titlebar: "#dfdfdf",
|
||||
toolbar: "#e9e9e9"
|
||||
},
|
||||
Desert: {
|
||||
sidebar: "#FFFDF7",
|
||||
titlebar: "#DAD4C2",
|
||||
toolbar: "#FAF6E9"
|
||||
},
|
||||
Tropic: {
|
||||
sidebar: "#FAFFF7",
|
||||
toolbar: "#EEFAE9",
|
||||
titlebar: "#D7ECD1"
|
||||
},
|
||||
Sky: {
|
||||
sidebar: "#F7FFFE",
|
||||
toolbar: "#E9F9FA",
|
||||
titlebar: "#D7F5F7"
|
||||
},
|
||||
Snow: {
|
||||
sidebar: "#fff",
|
||||
titlebar: "#fff",
|
||||
toolbar: "#fff"
|
||||
},
|
||||
Sunny: {
|
||||
sidebar: "#FFFFEF",
|
||||
titlebar: "#FFFDCA",
|
||||
toolbar: "lightYellow"
|
||||
},
|
||||
Floral: {
|
||||
sidebar: "#FFF7F7",
|
||||
titlebar: "#F7CBCB",
|
||||
toolbar: "#FAE9EA"
|
||||
},
|
||||
Ocean: {
|
||||
sidebar: "#F2FFFE",
|
||||
titlebar: "#8ACFC7",
|
||||
toolbar: "#C3F3EE"
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.set_theme = function(theme) {
|
||||
wn.dom.set_style(repl(".layout-wrapper-background { \
|
||||
background-color: %(sidebar)s !important; }\
|
||||
.appframe-toolbar { \
|
||||
background-color: %(toolbar)s !important; }\
|
||||
.appframe-titlebar { \
|
||||
background-color: %(titlebar)s !important; }", erpnext.themes[theme]));
|
||||
}
|
@ -22,7 +22,7 @@ erpnext.toolbar.setup = function() {
|
||||
erpnext.toolbar.add_modules();
|
||||
|
||||
// profile
|
||||
$('#toolbar-user').append('<li><a href="#!profile-settings">My Settings...</a></li>');
|
||||
$('#toolbar-user').append('<li><a href="#Form/Profile/'+user+'">My Settings...</a></li>');
|
||||
|
||||
$('.navbar .pull-right').append('\
|
||||
<li><a href="#!messages" title="Unread Messages"><span class="navbar-new-comments"></span></a></li>');
|
||||
|
@ -83,8 +83,6 @@ def boot_session(bootinfo):
|
||||
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 ''
|
||||
|
||||
# load subscription info
|
||||
import conf
|
||||
for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']:
|
||||
|
Loading…
Reference in New Issue
Block a user