Example #1
0
def update_groups():
  pass

from gluon.tools import Auth
auth = Auth(ns.db, hmac_key=Auth.get_or_create_key(), controller='auth_temp')

auth.settings.table_user_name = 'employee'
auth.settings.create_user_groups = False
auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = False
auth.settings.login_onvalidation = login_validation
auth.settings.change_password_onvalidation = change_pw_validation
auth.log_event=log_event
auth.update_groups=update_groups

auth.define_tables(username=True, migrate=False, fake_migrate=False)


def index():
  
  company_name = ns.valid.get_own_customer().custname
  customer_count_1 = len(ns.db((ns.db.customer.deleted==0)&(ns.db.customer.custtype!=ns.valid.get_groups_id("custtype", "own"))).select().as_list())
  customer_count_2 = ns.db.executesql(
    "select count(*) as rc from customer where deleted=0 and id not in(select customer.id from customer \
    inner join groups on customer.custtype=groups.id and groups.groupvalue='own')",as_dict = True)[0]["rc"]
  table = TABLE(TR(TD("Database company name: "+company_name)),
        TR(TD("Customer count 1: "+str(customer_count_1))),
        TR(TD("Customer count 2: "+str(customer_count_2))),
        TR(TD("Secret page: ",A(SPAN("Login"), _href=URL("secret_page"), _title=T("Login...")))))