Commit 5aa227f2 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add constants to handle migrate flag and roles.

Consolidate the authenfication procedure, namely when starting from scratch.
parent 94a5955e
......@@ -5,7 +5,11 @@
@auth.requires_login()
def index():
id_group = db.auth_membership(user_id=auth.user_id).group_id
session.role = db.auth_group(id=id_group).role
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
else:
return 'No users !!!!'
return LOAD('plugin_dbui', 'index', vars=request.vars)
......@@ -11,6 +11,7 @@
'ACTI': 'ACTI',
'ACTN': 'ACTN',
'Address of the invenio store where the search is performed.': 'Addresse du site invenio où les recherches sont effectuées.',
'administrators, librairians,...': 'administrateurs, documentalistes,...',
'Affiliation': 'Affiliation',
'Agencies': 'Agencies',
'All fields of the form have to be defined !!!': 'Tous les champs doivent ếtre définis !!!',
......@@ -177,6 +178,7 @@
'Level 3': 'Niveau 3',
'Level 4': 'Niveau 4',
'levels': 'niveaux',
'liaisons, team leaders,...': 'correspondants, chefs de groupe,...',
'licence': 'license',
'Lignes': 'Lignes',
'List': 'Liste',
......@@ -271,6 +273,7 @@
'Registration identifier': 'Registration identifier',
'Registration is pending approval': 'Registration is pending approval',
'Registration key': 'Registration key',
'Registration successful': 'Registration successful',
'Reject': 'Rejeter',
'Reject article is not published': "Rejeter l'article n'est pas publié",
'Reject no authors': "Rejeter pas d'auteurs",
......
from gluon.tools import Auth
DB_MYSQL = 'mysql://GesProd:Prod_CPPM@maretude.in2p3.fr/GesProd'
MIGRATE = False
ID_ADMIN, ADMIN, DEF_ADMIN = 100, 'admin', 'administrators, librairians,...'
ID_USER, USER, DEF_USER = 200, 'user', 'liaisons, team leaders,...'
#
# Main database
#
try:
db = DAL(DB_MYSQL, migrate=False, pool_size=10)
except:
raise HTTP(500, T("Can't access the MySQL database !!!"))
#try:
# db = DAL(DB_MYSQL, migrate=False, pool_size=10)
#except:
# raise HTTP(500, T("Can't access the MySQL database !!!"))
#db = DAL('sqlite://storage.sqlite', migrate=True)
db = DAL('sqlite://storage.sqlite', migrate=MIGRATE)
#
# Logging
# Force the migrate flag to true when the database is empty
# in order to allow the creation of the tables
#
if not db.tables():
MIGRATE = True
#
# User logging
# Approval is required for newly registered users
#
auth = Auth(db, hmac_key=Auth.get_or_create_key())
auth.define_tables(migrate=False)
auth.settings.registration_requires_verification = False
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:25'
#mail.settings.sender = 'legac@cppm.in2p3.fr'
#mail.settings.login = None
# tune authentification fields for the extJS interface
db.auth_user.registration_key.readable = True
......
......@@ -120,7 +120,7 @@ fieldsModifier.configure_field('publication_date',
fieldsModifier.configure_field('year',
maxValue=datetime.now().year)
if session.role == 'user':
if session.role == USER:
fieldsModifier.configure_field('id_status', hidden=True)
#
......
......@@ -28,7 +28,7 @@ main_tables = ['publications']
#
# CAS node
#
if session.role == 'admin':
if session.role == ADMIN:
hidden_tables = list(db.tables)
for el in ('auth_user', 'auth_group', 'auth_membership'):
......@@ -41,7 +41,7 @@ if session.role == 'admin':
#
# configuration tables node
#
if session.role == 'admin':
if session.role == ADMIN:
hidden_tables = set(db.tables).difference(configuration_tools_tables)
confNode = dbui.Node(T('Configuration'))
......@@ -52,13 +52,13 @@ if session.role == 'admin':
# core tables node
#
if session.role in ('admin', 'user'):
if session.role in (ADMIN, USER):
if session.role == 'admin':
if session.role == ADMIN:
hidden_tables = list(auth_tables)
hidden_tables.extend(configuration_tools_tables)
elif session.role == 'user':
elif session.role == USER:
hidden_tables = set(db.tables).difference(main_tables)
gridNode = dbui.Node(T('Tables'))
......@@ -76,7 +76,7 @@ helpNode = dbui.Node(T('Help'))
helpNode.add_child(T('about'), aboutLeaf)
helpNode.add_child(T('versions'), versionLeaf)
if session.role == 'admin':
if session.role == ADMIN:
helpNode.add_child(T('database schema'), schemaLeaf)
helpNode.sort_children()
......@@ -100,7 +100,7 @@ reportNode.sort_children()
#
# wizard node
#
if session.role in ('admin', 'user'):
if session.role in (ADMIN, USER):
authorLeaf = dbui.to_panelWithUrlSelector(virtdb.authors_selector,
baseUrl=URL('wizards', 'extract_authors'))
......@@ -132,7 +132,7 @@ if session.role in ('admin', 'user'):
wizardNode.add_child(T('run a harvester'), harvesterLeaf)
wizardNode.add_child(T('run all harvesters'), runAllLeaf)
if session.role == 'admin':
if session.role == ADMIN:
wizardNode.add_child(T('check and validate'), checkLeaf)
wizardNode.sort_children()
......@@ -144,11 +144,11 @@ if session.role in ('admin', 'user'):
viewportModifier = dbui.ViewportModifier()
viewportModifier.append_plugins('pViewportLogin')
if session.role == 'admin':
if session.role == ADMIN:
viewportModifier.add_node(helpNode, casNode, wizardNode, confNode, gridNode, reportNode)
viewportModifier.configure(logged=True)
elif session.role == 'user':
elif session.role == USER:
viewportModifier.add_node(helpNode, wizardNode, gridNode, reportNode)
viewportModifier.configure(logged=True)
......
--------------------------------- CHANGELOG ----------------------------------
HEAD
- Bug fixed and polish the user interface
- Bug fixed and polish the user interface.
- Add constant to deal with migrate flag and roles.
- Consolidate the authentification procedure.
0.8.1 (Dec 2012)
- Migrate to plugin_dbui 0.4.10.1.
- New node CAS to manage user and their group.
......@@ -11,8 +13,8 @@ HEAD
- Modify the metrics table by adding conditions and by removing tablename
- Add About and licence stuff.
- Simplify the interface using the teams/project relation ship.
- Polish the user role.
- Polish the user role.
0.7.0 (Nov 2012)
- Migrate to plugin_dbui 0.4.9.7.
- Deploy the new class Selector.
......@@ -24,38 +26,38 @@ HEAD
- Add a wizard to run all harvesters in one go.
- Add a wizard to run a free harvester.
- Add the mode dry run for all harvester wizards.
0.6.0 (Oct 2012)
- Redesign the metric to use the axes approach.
- Remove obsolete code for lists and metrics reporting.
- Polish the user interface.
0.5.1 (Sept 2012)
- Consolidation and bugs fixed
- Myseed map the CPPM organisation
- Add a toolbox via the controller scripts
- Add a model of the MySQL database version 0.4.0.
It was use to migrate to the current version.
0.5.0 (Sept 2012)
- Bugs fixed
- Harvesters can run on INSPIREHEP store.
- New database schema with improved teams/projects axes.
- Improved version of the tools to generates list.
- Improved version of the class Record.
0.4.0 (July 2012)
- Review the logic of the harvester and the error messaging.
- Review the logic of the harvester and the error messaging.
Harvester can be parameterised for a team, a project or both.
- Review the interface to enter an MARC XML record. It can be associated
for a team a project or both. It does not required the parameterisation
for a team a project or both. It does not required the parameterisation
of an harvester.
- Add an helper tools to extract the list of authors from a string containing
author names and their affiliation.
- Increase the number of character allowed for the authors field.
- Redesign the tool to generate the list. It can be fully configure using
the table lists and sections.
0.3.2 (July 2012)
- Rename the table degrees as levels in order to run with MySQL.
- Add authentication procedure using tools provided by web2py.
......@@ -65,11 +67,11 @@ HEAD
- Dedicated page to show software versions and database schema.
- Login via the viewport.
- Review default values in filter and selector.
0.2.1 (Jun 2012)
- Minor release
- ToolTip for all type of form
- Improve the French translation
0.2.0 (Jun 2012)
- First production release.
\ No newline at end of file
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