common_settings.py 3.27 KB
Newer Older
1 2 3 4
# -*- coding: utf-8 -*-
""" Common settings

"""
LE GAC Renaud's avatar
LE GAC Renaud committed
5
import datetime
6
import filters
7
import harvest_tools
8 9 10
import plugin_dbui as dbui

from callbacks import (INHIBIT_CASCADE_DELETE,
11 12
                       INHIBIT_CONTROLLER_INSERT,
                       INHIBIT_CONTROLLER_UPDATE,
13
                       INHIBIT_DUPLICATE_PUBLICATION,
14
                       INHIBIT_HARVESTER,
15 16 17 18 19
                       INHIBIT_PUBLICATION_DELETE_ON_OK,
                       INHIBIT_PUBLICATION_UPDATE_ON_OK)

from gluon.tools import PluginManager

LE GAC Renaud's avatar
LE GAC Renaud committed
20 21 22
from regex import (REG_COLLABORATION,
                   REG_CONF_DATES,
                   REG_DEFENSE,
23 24
                   REG_SUBMITTED,
                   REG_VALID_ORIGIN)
25

26
# ............................................................................
27
#
28
# Language
29
#
30 31 32 33 34 35

T.set_current_languages('en', 'en-gb', 'en-us')  # mother tongue
T.force('fr-fr')                                 # user language
T.lazy = False                                   # immediate translation

# ............................................................................
36
#
37
# Plugin dbui configuration
38 39
#

40 41 42 43 44 45 46
dbui.Dbui.define_paths(
    app_css = 'static/my.css',
    app_lg = 'static/limbra/locale/limbra-lang-fr.js',
    app_libmin = 'static/limbra-min.js',
    app_script = 'static/app.js')

# ............................................................................
47
#
48
# Constants
49
#
50

51 52
undef = T(dbui.UNDEF)
undef_id = dbui.UNDEF_ID
LE GAC Renaud's avatar
LE GAC Renaud committed
53
year = datetime.datetime.now().year
54

55 56 57
CONTROLLERS = ['articles',
               'notes',
               'preprints',
LE GAC Renaud's avatar
LE GAC Renaud committed
58
               'proceedings',
59 60 61 62
               'reports',
               'talks',
               'theses']

63 64
DIRS = ['ASC', 'DESC']

LE GAC Renaud's avatar
LE GAC Renaud committed
65 66
CAT_USUAL = [T('article'),
             T('book'),
67
             T('patent'),
LE GAC Renaud's avatar
LE GAC Renaud committed
68 69 70 71
             T('poster'),
             T('proceeding'),
             T('report'),
             T('talk'),
72 73 74
             T('thesis'),
             undef]
CAT_USUAL.sort()
75 76 77 78 79

MODE_DRY_RUN = T(harvest_tools.DRY_RUN)
MODE_CHANGE_STATUS = T('change status')
MODE_LOAD_IN_DB = T('load in the database')

80 81
ONE_HOUR = 3600000

82 83
STORES = ['cds.cern.ch', 'inspirehep.net']

84
# ............................................................................
85
#
86
#  Configure the user interface
87
#
88 89 90 91 92

dbui.Dbui.initialise_ui()
directSvc = dbui.Dbui.start_directSvc()

# common configuration for forms and grids
93
tables = ['application',
94
          'auth_group',
95 96 97
          'auth_membership',
          'auth_user',
          'authors_roles',
98 99 100 101 102 103
          'axes',
          'categories',
          'collaborations',
          'controllers',
          'countries',
          'harvesters',
104
          'graphs',
105 106
          'lists',
          'metrics',
LE GAC Renaud's avatar
LE GAC Renaud committed
107
          'my_authors',
108
          'organisation',
109 110 111 112 113 114 115 116 117
          'projects',
          'publications',
          'publishers',
          'renderers',
          'reports',
          'sections',
          'status',
          'teams']

118 119 120
# a user see the categories table but he/she can not modify it.
if session.role == USER:
    tables.remove('categories')
LE GAC Renaud's avatar
LE GAC Renaud committed
121

122
dbui.configure_forms(tables, plugins=['pFormToolTip'], width=350)
123 124 125 126 127

dbui.configure_grids(tables, plugins=['pGridRowEditorConfirmDelete',
                                      'pGridRowEditorContextMenu',
                                      'pGridRowEditorDblClick',
                                      'pGridToolbar'])