moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,5 @@
<div class="layout-wrapper layout-wrapper-appframe">
<div class="layout-appframe"></div>
<div class="layout-main">
</div>
</div>

View File

@@ -0,0 +1,149 @@
// 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('Change Password', this.change_password);
this.wrapper.appframe.add_button('Change Background', this.change_background);
this.tab = make_table($a($(this.wrapper).find('.layout-main').get(0), 'div', '', {marginTop:'19px'}),
1, 2, '90%', ['50%', '50%'], {padding:'11px'})
this.img = $a($td(this.tab, 0, 0), 'img', '', {width: '120px', maxHeight:'200px'});
this.img.src = wn.user_info(user).image;
$btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', 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 = $a($td(this.tab, 0, 1), 'div');
this.form = new wn.widgets.FieldGroup()
this.form.make_fields(div, [
{fieldname:'first_name', fieldtype:'Data',label:'First Name',reqd:1},
{fieldname:'last_name', fieldtype:'Data',label:'Last Name'},
{fieldname:'bio', fieldtype:'Text',label:'Bio'},
{fieldname:'update', fieldtype:'Button',label:'Update'}
]);
this.form.fields_dict.update.input.onclick = 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();
})
}
}
}
//
// change password
//
this.change_password = function() {
var d = new wn.widgets.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.make();
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.widgets.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;
pscript.myprofile.img.src = 'files/' + fid;
}
}
});
d.show();
}
this.change_background = function() {
var d = new wn.widgets.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();
}

View File

@@ -0,0 +1,112 @@
# 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@webnotestech.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 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
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

View File

@@ -0,0 +1,27 @@
# 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'
}
]