Added method is_setup_okay to confirm if a db is setup properly
This commit is contained in:
parent
913d7b51ae
commit
d958262761
@ -13,6 +13,8 @@ sql = webnotes.conn.sql
|
|||||||
get_value = webnotes.conn.get_value
|
get_value = webnotes.conn.get_value
|
||||||
in_transaction = webnotes.conn.in_transaction
|
in_transaction = webnotes.conn.in_transaction
|
||||||
convert_to_lists = webnotes.conn.convert_to_lists
|
convert_to_lists = webnotes.conn.convert_to_lists
|
||||||
|
|
||||||
|
from server_tools.gateway_utils import update_client_control, get_total_users
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -36,10 +38,10 @@ class DocType:
|
|||||||
#-----------------------
|
#-----------------------
|
||||||
def set_account_details(self, args):
|
def set_account_details(self, args):
|
||||||
args = eval(args)
|
args = eval(args)
|
||||||
|
#webnotes.logger.error("args in set_account_details of setup_control: " + str(args))
|
||||||
self.set_cp_defaults(args['company_name'], args['industry'], args['time_zone'], args['country'], args['account_name'])
|
self.set_cp_defaults(args['company'], args['industry'], args['time_zone'], args['country'], args['account_name'])
|
||||||
self.create_profile(args['user'], args['first_name'], args['last_name'])
|
self.create_profile(args['user'], args['first_name'], args['last_name'])
|
||||||
self.update_client_control()
|
update_client_control(args['total_users'])
|
||||||
|
|
||||||
|
|
||||||
# Account Setup
|
# Account Setup
|
||||||
@ -163,19 +165,38 @@ class DocType:
|
|||||||
d = addchild(pr,'userroles', 'UserRole', 1)
|
d = addchild(pr,'userroles', 'UserRole', 1)
|
||||||
d.role = r
|
d.role = r
|
||||||
d.save(1)
|
d.save(1)
|
||||||
|
|
||||||
# Update WN ERP Client Control
|
|
||||||
# -----------------------------
|
|
||||||
def update_client_control(self):
|
|
||||||
cl = Document('WN ERP Client Control','WN ERP Client Control')
|
|
||||||
cl.account_start_date = nowdate()
|
|
||||||
cl.total_users = 1
|
|
||||||
cl.is_trial_account = 1
|
|
||||||
cl.save()
|
|
||||||
|
|
||||||
# Sync DB
|
# Sync DB
|
||||||
# -------
|
# -------
|
||||||
def sync_db(arg=''):
|
def sync_db(arg=''):
|
||||||
import webnotes.model.db_schema
|
import webnotes.model.db_schema
|
||||||
sql("delete from `tabDocType Update Register`")
|
sql("delete from `tabDocType Update Register`")
|
||||||
webnotes.model.db_schema.sync_all()
|
webnotes.model.db_schema.sync_all()
|
||||||
|
|
||||||
|
|
||||||
|
def is_setup_okay(self, args):
|
||||||
|
"""
|
||||||
|
Validates if setup has been performed after database allocation
|
||||||
|
"""
|
||||||
|
|
||||||
|
args = eval(args)
|
||||||
|
#webnotes.logger.error("args in set_account_details of setup_control: " + str(args))
|
||||||
|
|
||||||
|
cp_defaults = webnotes.conn.get_value('Control Panel', None, 'account_id')
|
||||||
|
|
||||||
|
user_profile = webnotes.conn.get_value('Profile', args['user'], 'name')
|
||||||
|
|
||||||
|
from webnotes.utils import cint
|
||||||
|
|
||||||
|
total_users = get_total_users()
|
||||||
|
|
||||||
|
#webnotes.logger.error("setup_control.is_setup_okay: " + cp_defaults + " " + user_profile + " " + str(total_users))
|
||||||
|
|
||||||
|
#webnotes.logger.error("setup_control.is_setup_okay: Passed Values:" + args['account_name'] + " " + args['user'] + " " + str(args['total_users']))
|
||||||
|
|
||||||
|
|
||||||
|
if (cp_defaults==args['account_name']) and user_profile and \
|
||||||
|
(total_users==cint(args['total_users'])):
|
||||||
|
return 'True'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user