').insertAfter('.help');
+ if(wn.boot.max_users) {
+ $sub_info.append(repl('\
+
\
+ Max Users: %(max_users)s \
+ ', { max_users: wn.boot.max_users }));
+ }
+ if(wn.boot.expires_on) {
+ $sub_info.append(repl('\
+
\
+ Expires On: %(expires_on)s \
+ ', { expires_on: dateutil.str_to_user(wn.boot.expires_on) }));
+ }
+ }
},
render: function(data) {
if(data.file_list) {
@@ -207,6 +222,17 @@ $.extend(wn.pages.users, {
},
add_user: function() {
var me = wn.pages.users;
+ var active_users = $('.user-card:not(.disabled)');
+ if(wn.boot.max_users && (active_users.length >= wn.boot.max_users)) {
+ msgprint(repl("Alas!
\
+ You already have
%(active_users)s active users, \
+ which is the maximum number that you are currently allowed to add.
\
+ So, to add more users, you can:
\
+ 1.
Upgrade to the unlimited users plan, or
\
+ 2.
Disable one or more of your existing users and try again",
+ {active_users: active_users.length}));
+ return;
+ }
var d = new wn.widgets.Dialog({
title: 'Add User',
width: 400,
diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py
index 6735dc065b5..819f7bb1da5 100644
--- a/erpnext/utilities/page/users/users.py
+++ b/erpnext/utilities/page/users/users.py
@@ -103,9 +103,24 @@ def add_user(args):
@webnotes.whitelist()
def add_profile(args):
from webnotes.utils import validate_email_add, now
- email = args['user']
-
+ email = args['user']
sql = webnotes.conn.sql
+
+ # validate max number of users exceeded or not
+ import conf
+ if hasattr(conf, 'max_users'):
+ active_users = sql("""select count(*) from tabProfile
+ where ifnull(enabled, 0)=1 and docstatus<2
+ and name not in ('Administrator', 'Guest')""")[0][0]
+ if active_users >= conf.max_users:
+ # same message as in users.js
+ webnotes.msgprint("""Alas!
\
+ You already have
%(active_users)s active users, \
+ which is the maximum number that you are currently allowed to add.
\
+ So, to add more users, you can:
\
+ 1.
Upgrade to the unlimited users plan, or
\
+ 2.
Disable one or more of your existing users and try again""" \
+ % {'active_users': active_users}, raise_exception=1)
if not email:
email = webnotes.form_dict.get('user')
diff --git a/index.cgi b/index.cgi
index 31da310c7a6..bf84c5f6b30 100755
--- a/index.cgi
+++ b/index.cgi
@@ -50,8 +50,8 @@ def init():
return True
except webnotes.AuthenticationError, e:
return True
- except webnotes.UnknownDomainError, e:
- print "Location: " + (conf.redirect_404)
+ #except webnotes.UnknownDomainError, e:
+ # print "Location: " + (conf.redirect_404)
except webnotes.SessionStopped, e:
if 'cmd' in webnotes.form_dict:
webnotes.handler.print_json()
diff --git a/js/all-app.js b/js/all-app.js
index bec42206470..647a888e495 100644
--- a/js/all-app.js
+++ b/js/all-app.js
@@ -2216,11 +2216,18 @@ wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand'
*/
var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'}
wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){if(inList(user_roles,'System Manager'))is_system_manager=1;}
-erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
+erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
if(user=='Guest'){if(wn.boot.custom_css){set_style(wn.boot.custom_css);}
if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}}else{wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
if(user_roles.indexOf('Accounts Manager')!=-1){wn.boot.profile.allow_modules.push('Dashboard');}
-erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup();}}
+erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup.show();}
+if(wn.boot.expires_on){var today=dateutil.str_to_obj(dateutil.get_today());var expires_on=dateutil.str_to_obj(wn.boot.expires_on);var diff=dateutil.get_diff(expires_on,today);if(0<=diff&&diff<=15){var expiry_string=diff==0?"today":repl("in %(diff)s day(s)",{diff:diff});$('header').append(repl('
\
+ Ahem! Your ERPNext subscription will expire %(expiry_string)s. \
+ Please renew your subscription to continue using ERPNext \
+ (and remove this annoying banner). \
+
',{expiry_string:expiry_string}));}else if(diff<0){$('header').append(repl('
\
+ Ahem! This ERPNext subscription has expired and should be deleted. \
+
',{expiry_string:expiry_string}));}}}
erpnext.set_about();$('#startup_div').toggle(false);}
show_chart_browser=function(nm,chart_type){var call_back=function(){if(nm=='Sales Browser'){var sb_obj=new SalesBrowser();sb_obj.set_val(chart_type);}
else if(nm=='Accounts Browser')
diff --git a/js/all-web.js b/js/all-web.js
index 6ec421e218a..503f088e935 100644
--- a/js/all-web.js
+++ b/js/all-web.js
@@ -824,11 +824,18 @@ wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand'
*/
var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'}
wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){if(inList(user_roles,'System Manager'))is_system_manager=1;}
-erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
+erpnext.startup.start=function(){console.log('Starting up...');$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
if(user=='Guest'){if(wn.boot.custom_css){set_style(wn.boot.custom_css);}
if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}}else{wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
if(user_roles.indexOf('Accounts Manager')!=-1){wn.boot.profile.allow_modules.push('Dashboard');}
-erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup();}}
+erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup.show();}
+if(wn.boot.expires_on){var today=dateutil.str_to_obj(dateutil.get_today());var expires_on=dateutil.str_to_obj(wn.boot.expires_on);var diff=dateutil.get_diff(expires_on,today);if(0<=diff&&diff<=15){var expiry_string=diff==0?"today":repl("in %(diff)s day(s)",{diff:diff});$('header').append(repl('
\
+ Ahem! Your ERPNext subscription will expire %(expiry_string)s. \
+ Please renew your subscription to continue using ERPNext \
+ (and remove this annoying banner). \
+
',{expiry_string:expiry_string}));}else if(diff<0){$('header').append(repl('
\
+ Ahem! This ERPNext subscription has expired and should be deleted. \
+
',{expiry_string:expiry_string}));}}}
erpnext.set_about();$('#startup_div').toggle(false);}
show_chart_browser=function(nm,chart_type){var call_back=function(){if(nm=='Sales Browser'){var sb_obj=new SalesBrowser();sb_obj.set_val(chart_type);}
else if(nm=='Accounts Browser')