Commit e6cf2b7f authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Migrate to plugi_dbui 0.4.14.0 (open tab a startup, login, ...)

parent e313f6a5
""" Main Controller to run the application with the admin privileges.
""" Main Controller to run the application with some privileges.
"""
@auth.requires_login()
def index():
if db.auth_user[auth.user_id]:
id_group = db.auth_membership(user_id=auth.user_id).group_id
session.role = db.auth_group(id=id_group).role
# login procedure is active
if session.auth:
roles = session.auth.user_groups.values()
if roles:
session.role = roles[0]
else:
return 'The user role is not defined'
# no login procedure
else:
return 'No users !!!!'
session.role = ADMIN
return LOAD('plugin_dbui', 'index', vars=request.vars)
from gluon.tools import Auth
# -*- coding: utf-8 -*-
""" access
setup the connection to the databases
"""
DB_MYSQL = 'mysql://GesProd:Prod_CPPM@maretude.in2p3.fr/GesProd'
MIGRATE = False
......@@ -10,54 +14,8 @@ ID_USER, USER, DEF_USER = 2, 'user', 'liaisons, team leaders,...'
# connect to the database
#
try:
db = DAL(DB_MYSQL, migrate=MIGRATE, pool_size=10)
db = DAL(DB_MYSQL, migrate_enabled=MIGRATE, pool_size=10)
except:
raise HTTP(500, T("Can't access the MySQL database !!!"))
#db = DAL('sqlite://storage.sqlite', migrate=MIGRATE)
#
# User logging
# Approval is required for newly registered users
#
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables(migrate=MIGRATE)
auth.settings.create_user_groups = False
auth.settings.registration_requires_approval = True
auth.settings.registration_requires_verification = False
auth.settings.remember_me_form = False
auth.settings.reset_password_requires_verification = True
# after registration go to the login page
auth.settings.register_next = URL('user', args='login')
# create user and admin groups
if not db(db.auth_group.id).count():
db.auth_group.insert(id=ID_ADMIN, role=ADMIN, description=T(DEF_ADMIN))
db.auth_group.insert(id=ID_USER, role=USER, description=T(DEF_USER))
# Newly registeres user goes in the user group
auth.settings.everybody_group_id = ID_USER
# The first user is auto approved and get all priviledge (admin)
if not db(db.auth_user.id).count():
auth.settings.everybody_group_id = ID_ADMIN
auth.settings.registration_requires_approval = False
# activate the mailer
#mail = auth.settings.mailer
#mail.settings.server = 'marsmtp.in2p3.fr'
#mail.settings.sender = 'legac@cppm.in2p3.fr'
#mail.settings.login = None
#mail.settings.tls = False
# tune authentification fields for the extJS interface
db.auth_user.registration_key.readable = True
db.auth_user.registration_key.writable = True
db.auth_membership.user_id.label = 'User'
db.auth_membership.group_id.label = 'Group'
db.auth_membership.user_id.requires = \
IS_IN_DB(db, 'auth_user.last_name')
# db = DAL('sqlite://storage.sqlite', migrate_enabled=MIGRATE)
# -*- coding: utf-8 -*-
""" authentication
user identification and role
"""
from gluon.tools import Auth
#
# User logging
# Approval is required for newly registered users
#
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables(migrate=MIGRATE)
auth.settings.create_user_groups = False
auth.settings.mailer = None
auth.settings.registration_requires_approval = True
auth.settings.registration_requires_verification = False
auth.settings.remember_me_form = False
auth.settings.reset_password_requires_verification = True
# go to the login page after change password, logout and registration
auth.settings.change_password_next = URL('user', args='login')
auth.settings.logout_next = URL('user', args='login')
auth.settings.register_next = URL('user', args='login')
# create user and admin groups
if not db(db.auth_group.id).count():
db.auth_group.insert(id=ID_ADMIN, role=ADMIN, description=T(DEF_ADMIN))
db.auth_group.insert(id=ID_USER, role=USER, description=T(DEF_USER))
# Newly registered users go in the user group
auth.settings.everybody_group_id = ID_USER
# The first user is auto approved and get all privilege (admin)
if not db(db.auth_user.id).count():
auth.settings.everybody_group_id = ID_ADMIN
auth.settings.registration_requires_approval = False
# tune authentication fields for the extJS interface
db.auth_user.registration_key.readable = True
db.auth_user.registration_key.writable = True
db.auth_membership.user_id.label = 'User'
db.auth_membership.group_id.label = 'Group'
db.auth_membership.user_id.requires = \
IS_IN_DB(db, 'auth_user.last_name')
......@@ -28,7 +28,8 @@ main_tables = ['publications']
#
# CAS node
#
if session.role == ADMIN:
casNode = None
if session.auth and session.role == ADMIN:
hidden_tables = list(db.tables)
for el in ('auth_user', 'auth_group', 'auth_membership'):
......@@ -41,6 +42,7 @@ if session.role == ADMIN:
#
# configuration tables node
#
confNode = None
if session.role == ADMIN:
hidden_tables = set(db.tables).difference(configuration_tools_tables)
......@@ -52,6 +54,7 @@ if session.role == ADMIN:
# core tables node
#
gridNode = None
if session.role in (ADMIN, USER):
if session.role == ADMIN:
......@@ -101,6 +104,7 @@ reportNode.sort_children()
#
# wizard node
#
wizardNode = None
if session.role in (ADMIN, USER):
authorLeaf = dbui.to_panelWithUrlSelector(virtdb.authors_selector,
baseUrl=URL('wizards', 'extract_authors'))
......@@ -145,17 +149,14 @@ if session.role in (ADMIN, USER):
# the list of node depends on the user role
#
viewportModifier = dbui.ViewportModifier()
viewportModifier.append_plugins('pViewportLogin')
if session.role == ADMIN:
viewportModifier.add_node(helpNode, casNode, wizardNode, confNode, gridNode, reportNode)
viewportModifier.configure(logged=True)
if session.auth:
viewportModifier.append_plugins('pViewportLogin')
viewportModifier.configure(logged=False)
elif session.role == USER:
viewportModifier.add_node(helpNode, wizardNode, gridNode, reportNode)
if session.role in (ADMIN, USER):
viewportModifier.configure(logged=True)
else:
viewportModifier.add_node(helpNode, reportNode)
viewportModifier.configure(logged=False)
\ No newline at end of file
viewportModifier.add_node(helpNode, casNode, wizardNode, confNode, gridNode, reportNode)
viewportModifier.default_node(T('Tables'), T('publications'))
--------------------------------- CHANGELOG ----------------------------------
HEAD
- Migrate to plugin_dbui 0.4.14.0
- Proceeding harvester logs publishers, volume and pages.
- Improved algorithm to determine conference location.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment