Merge branch 'latest' of github.com:webnotes/erpnext into latest
This commit is contained in:
commit
8c36f47ea6
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
*.comp.js
|
*.comp.js
|
||||||
.DS_Store
|
.DS_Store
|
||||||
server_tools
|
server_tools
|
||||||
|
services
|
||||||
user_files
|
user_files
|
||||||
patch.log
|
patch.log
|
||||||
lib
|
lib
|
||||||
|
|||||||
@ -70,7 +70,6 @@ pscript.myc_add_user = function() {
|
|||||||
label: 'Add',
|
label: 'Add',
|
||||||
fieldname: 'add'
|
fieldname: 'add'
|
||||||
}];
|
}];
|
||||||
}
|
|
||||||
|
|
||||||
fields.push();
|
fields.push();
|
||||||
|
|
||||||
|
|||||||
@ -8,16 +8,12 @@ def change_password(arg):
|
|||||||
"""
|
"""
|
||||||
arg = load_json(arg)
|
arg = load_json(arg)
|
||||||
|
|
||||||
if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
|
if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
|
||||||
import server_tools.gateway_utils
|
webnotes.msgprint('Old password is not correct', raise_exception=1)
|
||||||
webnotes.msgprint(server_tools.gateway_utils.change_password(arg['old_password'], arg['new_password'])['message'])
|
|
||||||
else:
|
|
||||||
if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
|
|
||||||
webnotes.msgprint('Old password is not correct', raise_exception=1)
|
|
||||||
|
|
||||||
from webnotes.utils import nowdate
|
from webnotes.utils import nowdate
|
||||||
webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
|
webnotes.conn.sql("update tabProfile set password=password(%s), modified=%s where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
|
||||||
webnotes.msgprint('Password Updated');
|
webnotes.msgprint('Password Updated');
|
||||||
|
|
||||||
def get_user_details(arg=None):
|
def get_user_details(arg=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
22
erpnext/patches/jan_mar_2012/subdomain_login_patch.py
Normal file
22
erpnext/patches/jan_mar_2012/subdomain_login_patch.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import webnotes
|
||||||
|
from webnotes.model.doc import Document
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
add_default_home_page()
|
||||||
|
cleanup()
|
||||||
|
|
||||||
|
def cleanup():
|
||||||
|
from webnotes.model import delete_doc
|
||||||
|
delete_doc("DocType", "SSO Control")
|
||||||
|
delete_doc("DocType", "WN ERP Cient Control")
|
||||||
|
|
||||||
|
def add_default_home_page():
|
||||||
|
if not webnotes.conn.sql("""select name from `tabDefault Home Page`
|
||||||
|
where role='Guest' and home_page='Login Page'"""):
|
||||||
|
d = Document('Default Home Page')
|
||||||
|
d.parent = 'Control Panel'
|
||||||
|
d.parenttype = 'Control Panel'
|
||||||
|
d.parentfield = 'default_home_pages'
|
||||||
|
d.role = 'Guest'
|
||||||
|
d.home_page = 'Login Page'
|
||||||
|
d.save(1)
|
||||||
@ -20,7 +20,7 @@ def on_login_post_session(login_manager):
|
|||||||
update login_from and delete parallel sessions
|
update login_from and delete parallel sessions
|
||||||
"""
|
"""
|
||||||
# Clear previous sessions i.e. logout previous log-in attempts
|
# Clear previous sessions i.e. logout previous log-in attempts
|
||||||
exception_list = ['demo@webnotestech.com', 'Administrator']
|
exception_list = ['demo@webnotestech.com', 'Administrator', 'Guest']
|
||||||
if webnotes.session['user'] not in exception_list:
|
if webnotes.session['user'] not in exception_list:
|
||||||
sid_list = webnotes.conn.sql("""
|
sid_list = webnotes.conn.sql("""
|
||||||
DELETE FROM `tabSessions`
|
DELETE FROM `tabSessions`
|
||||||
|
|||||||
@ -55,14 +55,6 @@ pscript.startup_make_sidebar = function() {
|
|||||||
// menu
|
// menu
|
||||||
var ml = r.message;
|
var ml = r.message;
|
||||||
|
|
||||||
// login-file
|
|
||||||
if(r.login_url){
|
|
||||||
login_file = 'http://' + r.login_url;
|
|
||||||
}
|
|
||||||
else if(pscript.is_erpnext_saas) {
|
|
||||||
login_file = 'https://www.erpnext.com';
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear
|
// clear
|
||||||
page_body.left_sidebar.innerHTML = '';
|
page_body.left_sidebar.innerHTML = '';
|
||||||
|
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
# Please edit this list and import only required elements
|
|
||||||
import webnotes
|
|
||||||
|
|
||||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
|
||||||
from webnotes.model import db_exists
|
|
||||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
|
||||||
from webnotes.model.doclist import getlist, copy_doclist
|
|
||||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
|
||||||
from webnotes import session, form, is_testing, msgprint, errprint
|
|
||||||
|
|
||||||
set = webnotes.conn.set
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
get_value = webnotes.conn.get_value
|
|
||||||
in_transaction = webnotes.conn.in_transaction
|
|
||||||
convert_to_lists = webnotes.conn.convert_to_lists
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
|
||||||
def __init__(self, d, dl):
|
|
||||||
self.doc, self.doclist = d, dl
|
|
||||||
|
|
||||||
def logout_sso(self):
|
|
||||||
import webnotes
|
|
||||||
import webnotes.utils.webservice
|
|
||||||
|
|
||||||
if session['data'].get('login_from'):
|
|
||||||
sso = webnotes.utils.webservice.FrameworkServer(session['data'].get('login_from'), '/', '__system@webnotestech.com', 'password')
|
|
||||||
sso.runserverobj('SSO Control', 'SSO Control', 'logout_user', session['user'])
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
# DocType, SSO Control
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2010-08-08 17:09:24',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2010-12-20 19:44:29',
|
|
||||||
'modified_by': 'umair@iwebnotes.com',
|
|
||||||
'owner': 'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocType
|
|
||||||
{
|
|
||||||
'colour': 'White:FFF',
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'issingle': 1,
|
|
||||||
'module': 'Utilities',
|
|
||||||
'name': '__common__',
|
|
||||||
'section_style': 'Simple',
|
|
||||||
'server_code_error': ' ',
|
|
||||||
'version': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocType, SSO Control
|
|
||||||
{
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'name': 'SSO Control'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@ -1,141 +0,0 @@
|
|||||||
# Please edit this list and import only required elements
|
|
||||||
import webnotes
|
|
||||||
|
|
||||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
|
||||||
from webnotes.model import db_exists
|
|
||||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
|
||||||
from webnotes.model.doclist import getlist, copy_doclist
|
|
||||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
|
||||||
from webnotes import session, form, is_testing, msgprint, errprint
|
|
||||||
|
|
||||||
set = webnotes.conn.set
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
get_value = webnotes.conn.get_value
|
|
||||||
in_transaction = webnotes.conn.in_transaction
|
|
||||||
convert_to_lists = webnotes.conn.convert_to_lists
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
|
||||||
def __init__(self, doc, doclist):
|
|
||||||
self.doc, self.doclist = doc, doclist
|
|
||||||
|
|
||||||
|
|
||||||
# Check End of Trial Period
|
|
||||||
# -------------------------
|
|
||||||
def trial_payment_reminders(self):
|
|
||||||
if cint(self.doc.is_trial_account)==1:
|
|
||||||
# Trial Period Expiry
|
|
||||||
trial_end_date = add_days(self.doc.account_start_date, 30)
|
|
||||||
days = date_diff(trial_end_date, nowdate())
|
|
||||||
# check if trial period has expired
|
|
||||||
if days < 10 and days >= 0 and has_common(['System Manager'],webnotes.user.get_roles()):
|
|
||||||
return "Your Trial Period expires on '%s'. Please buy credits online using Manage Account." % (formatdate(trial_end_date))
|
|
||||||
|
|
||||||
# trial period has already expired
|
|
||||||
elif days < 0 and days >= -6:
|
|
||||||
extended_days = 7 + days
|
|
||||||
return "Your Trial Period has expired on %s. However, your account will be live for %s days. Please contact your System Manager to buy credits." % (formatdate(trial_end_date),cstr(extended_days))
|
|
||||||
elif not has_common(['Administrator'],webnotes.user.get_roles()) and days < -6:
|
|
||||||
return "Stopped"
|
|
||||||
|
|
||||||
# Account is not a trial account
|
|
||||||
else:
|
|
||||||
return self.account_expiry_reminder()
|
|
||||||
|
|
||||||
|
|
||||||
# Account Expiry Reminder
|
|
||||||
# -----------------------
|
|
||||||
def account_expiry_reminder(self):
|
|
||||||
import webnotes.utils
|
|
||||||
from datetime import datetime
|
|
||||||
# Payment Reminder in case of not enough balance
|
|
||||||
cr_reqd = cint(self.doc.total_users)
|
|
||||||
days_left = cint(self.calc_days())
|
|
||||||
# check if account balance is sufficient
|
|
||||||
if cint(self.doc.credit_balance)<(cr_reqd):
|
|
||||||
|
|
||||||
# Difference between last payment date and current date
|
|
||||||
if self.doc.last_deduction_date: last_payment = date_diff(nowdate(),self.doc.last_deduction_date)
|
|
||||||
else: last_payment = -1
|
|
||||||
|
|
||||||
# 7 days extension
|
|
||||||
remaining_days = days_left - 24
|
|
||||||
if last_payment > 30 or last_payment == -1:
|
|
||||||
if remaining_days < 8 and remaining_days >= 1:
|
|
||||||
return "Your account will be de-activated in " + cstr(remaining_days) + " days. Please contact your System Manager to buy credits."
|
|
||||||
elif remaining_days==0:
|
|
||||||
return "Your account will be disabled from tomorrow. Please contact your System Manager to buy credits."
|
|
||||||
elif not has_common(['Administrator'],webnotes.user.get_roles()):
|
|
||||||
return "Stopped"
|
|
||||||
|
|
||||||
# check if user account is extended for seven days
|
|
||||||
if cint(self.doc.is_trial_account)==0:
|
|
||||||
if days_left < 10 and days_left >= 0:
|
|
||||||
return "You have only %s Credits in your account. Buy credits before %s." % (cint(self.doc.credit_balance),formatdate(self.next_bill_sdate))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Calculate days between current date and billing cycle end date
|
|
||||||
# --------------------------------------------------------------
|
|
||||||
def calc_days(self):
|
|
||||||
if self.doc.billing_cycle_date:
|
|
||||||
next_bill_month = cint(nowdate().split('-')[1])
|
|
||||||
if cint(nowdate().split('-')[2]) > cint(self.doc.billing_cycle_date.split('-')[2]):
|
|
||||||
next_bill_month = cint(nowdate().split('-')[1]) + 1
|
|
||||||
next_bill_year = nowdate().split('-')[0]
|
|
||||||
if next_bill_month > 12:
|
|
||||||
next_bill_month = next_bill_month % 12
|
|
||||||
next_bill_year += 1
|
|
||||||
self.next_bill_sdate = cstr(next_bill_year)+'-'+cstr(next_bill_month)+'-'+(self.calc_next_day(next_bill_year,next_bill_month))
|
|
||||||
#msgprint("next_bill_month :::" + self.next_bill_sdate)
|
|
||||||
return date_diff(self.next_bill_sdate, nowdate())
|
|
||||||
|
|
||||||
|
|
||||||
# Calculate next billing date day
|
|
||||||
# --------------------------------
|
|
||||||
def calc_next_day(self, next_year, next_month):
|
|
||||||
bill_cycle_day = cstr(self.doc.billing_cycle_date).split('-')[2]
|
|
||||||
if cint(next_month) == 2 and next_year%4==0 and (next_year%100!=0 or next_year%400==0) and cint(bill_cycle_day) > 28:
|
|
||||||
bill_cycle_day = '28'
|
|
||||||
elif cint(bill_cycle_day) == 31 and cint(next_month) in (4,6,9,11):
|
|
||||||
bill_cycle_day = '30'
|
|
||||||
return bill_cycle_day
|
|
||||||
|
|
||||||
|
|
||||||
# Update acc credits and balance (making payment from gateway)
|
|
||||||
# -------------------------------------------------------------
|
|
||||||
def update_acc_bal(self,args):
|
|
||||||
args = eval(args)
|
|
||||||
self.doc.credit_balance = cint(self.doc.credit_balance) + cint(args.get('net_cr'))
|
|
||||||
self.doc.total_users = cint(self.doc.total_users) + cint(args.get('total_users'))
|
|
||||||
if cint(self.doc.is_trial_account) == 1:
|
|
||||||
if not self.doc.account_start_date:
|
|
||||||
self.doc.account_start_date = nowdate()
|
|
||||||
self.doc.is_trial_account = 0
|
|
||||||
self.doc.billing_cycle_date = nowdate()
|
|
||||||
self.doc.last_deduction_date = nowdate()
|
|
||||||
self.doc.save()
|
|
||||||
|
|
||||||
|
|
||||||
# Check Credit Balance
|
|
||||||
# ---------------------
|
|
||||||
def check_credit_balance(self):
|
|
||||||
if cint(self.doc.is_trial_account) == 0:
|
|
||||||
if cint(self.doc.credit_balance) < 1:
|
|
||||||
msgprint("You do not have enough credits to add new user. Please buy credits.")
|
|
||||||
raise Exception
|
|
||||||
else:
|
|
||||||
self.doc.credit_balance = cint(self.doc.credit_balance) - 1
|
|
||||||
msgprint("Your one credit is consumed. Balance Credits : %s" % (self.doc.credit_balance))
|
|
||||||
self.doc.total_users = cint(self.doc.total_users) + 1
|
|
||||||
self.doc.save()
|
|
||||||
|
|
||||||
|
|
||||||
# Monthly Deduction
|
|
||||||
# ------------------
|
|
||||||
def monthly_deduction(self, cr_ded):
|
|
||||||
self.doc.credit_balance = cint(self.doc.credit_balance) - cint(cr_ded)
|
|
||||||
self.doc.last_deduction_date = nowdate()
|
|
||||||
self.doc.save()
|
|
||||||
@ -1,124 +0,0 @@
|
|||||||
# DocType, WN ERP Client Control
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2010-08-08 17:09:30',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2010-09-20 14:06:57',
|
|
||||||
'modified_by': 'Administrator',
|
|
||||||
'owner': 'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocType
|
|
||||||
{
|
|
||||||
'colour': 'White:FFF',
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'issingle': 1,
|
|
||||||
'istable': 0,
|
|
||||||
'module': 'Utilities',
|
|
||||||
'name': '__common__',
|
|
||||||
'read_only': 1,
|
|
||||||
'section_style': 'Simple',
|
|
||||||
'server_code_error': ' ',
|
|
||||||
'show_in_menu': 1,
|
|
||||||
'version': 137
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': 'WN ERP Client Control',
|
|
||||||
'parentfield': 'fields',
|
|
||||||
'parenttype': 'DocType',
|
|
||||||
'permlevel': 0
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all DocPerm
|
|
||||||
{
|
|
||||||
'doctype': 'DocPerm',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': 'WN ERP Client Control',
|
|
||||||
'parentfield': 'permissions',
|
|
||||||
'parenttype': 'DocType',
|
|
||||||
'read': 1,
|
|
||||||
'role': 'System Manager'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocType, WN ERP Client Control
|
|
||||||
{
|
|
||||||
'doctype': 'DocType',
|
|
||||||
'name': 'WN ERP Client Control'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'create': 1,
|
|
||||||
'doctype': 'DocPerm',
|
|
||||||
'idx': 1,
|
|
||||||
'permlevel': 0,
|
|
||||||
'write': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocPerm
|
|
||||||
{
|
|
||||||
'doctype': 'DocPerm',
|
|
||||||
'idx': 2,
|
|
||||||
'permlevel': 1
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'fieldname': 'account_start_date',
|
|
||||||
'fieldtype': 'Date',
|
|
||||||
'idx': 1,
|
|
||||||
'label': 'Account Start Date'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'fieldname': 'billing_cycle_date',
|
|
||||||
'fieldtype': 'Date',
|
|
||||||
'idx': 2,
|
|
||||||
'label': 'Billing Cycle Date'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'fieldname': 'total_users',
|
|
||||||
'fieldtype': 'Int',
|
|
||||||
'idx': 3,
|
|
||||||
'label': 'Total Users'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'fieldname': 'credit_balance',
|
|
||||||
'fieldtype': 'Int',
|
|
||||||
'idx': 4,
|
|
||||||
'label': 'Credit Balance'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'fieldname': 'is_trial_account',
|
|
||||||
'fieldtype': 'Check',
|
|
||||||
'idx': 5,
|
|
||||||
'label': 'Is Trial Account'
|
|
||||||
},
|
|
||||||
|
|
||||||
# DocField
|
|
||||||
{
|
|
||||||
'doctype': 'DocField',
|
|
||||||
'fieldname': 'last_deduction_date',
|
|
||||||
'fieldtype': 'Date',
|
|
||||||
'idx': 6,
|
|
||||||
'label': 'Last Credit Deduction Date'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
Loading…
x
Reference in New Issue
Block a user