Project

General

Profile

Download (1.94 KB) Statistics
| Branch: | Tag: | Revision:

root / extra / auquotidien.py @ 5c851a65

1 6b5f9a36 Frédéric Péters
from qommon.publisher import get_publisher_class, get_request
2
from qommon.misc import get_cfg
3 901b9cc8 Frédéric Péters
4 7f8fbe7e Frédéric Péters
import modules.admin
5
import modules.backoffice
6 3be7cfa9 Frédéric Péters
import modules.links_ui
7
import modules.announces_ui
8 9c8e4e26 Frédéric Péters
import modules.events_ui
9 958b2b8f Frédéric Péters
import modules.forms_ui
10 c43d0b77 Frédéric Péters
import modules.payments_ui
11 03c6494d Frédéric Péters
import modules.strongbox_ui
12 b7a2808c Frédéric Péters
import modules.formpage
13 c2ffbce0 Frédéric Péters
import modules.template
14 901b9cc8 Frédéric Péters
import modules.root
15 32470887 Frédéric Péters
import modules.form
16 c43d0b77 Frédéric Péters
import modules.payments
17
import modules.connectors
18 920f68b7 Frédéric Péters
19 b1c812cb Frédéric Péters
get_publisher_class().register_translation_domain('auquotidien')
20 de7546e8 Frédéric Péters
get_publisher_class().default_configuration_path = 'au-quotidien-wcs-settings.xml'
21 920f68b7 Frédéric Péters
22 6b5f9a36 Frédéric Péters
def check_visibility(target):
23
    user = get_request().user
24
    if not user:
25
        return False
26
    admin_role = get_cfg('aq-permissions', {}).get(target.strip('/'), None)
27 ca53b88d Frédéric Péters
    if not admin_role:
28
        return False
29 6b5f9a36 Frédéric Péters
    if not (user.is_admin or admin_role in (user.roles or [])):
30
        return False
31
    return True
32
33 a63d2be4 Frédéric Péters
rdb = get_publisher_class().backoffice_directory_class
34 6b5f9a36 Frédéric Péters
35 958b2b8f Frédéric Péters
rdb.register_menu_item('forms', None)
36
rdb.register_directory('forms', modules.forms_ui.FormsDirectory())
37
rdb.register_menu_item('forms/', _('Forms'))
38
39 6b5f9a36 Frédéric Péters
rdb.register_menu_item('pending', _('Pending Forms'))
40
41 a63d2be4 Frédéric Péters
rdb.register_directory('announces', modules.announces_ui.AnnouncesDirectory())
42 6b5f9a36 Frédéric Péters
rdb.register_menu_item('announces/', _('Announces'), check_visibility)
43 a63d2be4 Frédéric Péters
44 2d881796 Frédéric Péters
rdb.register_directory('links', modules.links_ui.LinksDirectory())
45 6b5f9a36 Frédéric Péters
rdb.register_menu_item('links/', _('Links'), check_visibility)
46 2d881796 Frédéric Péters
47 9c8e4e26 Frédéric Péters
rdb.register_directory('events', modules.events_ui.EventsDirectory())
48 6b5f9a36 Frédéric Péters
rdb.register_menu_item('events/', _('Events'), check_visibility)
49 9c8e4e26 Frédéric Péters
50 c43d0b77 Frédéric Péters
rdb.register_directory('payments', modules.payments_ui.PaymentsDirectory())
51
rdb.register_menu_item('payments/', _('Payments'), check_visibility)
52
53 03c6494d Frédéric Péters
rdb.register_directory('strongbox', modules.strongbox_ui.StrongboxDirectory())
54
rdb.register_menu_item('strongbox/', _('Strong Box'), check_visibility)
55
56 32470887 Frédéric Péters
import wcs.fields
57
wcs.fields.FileField.widget_class = modules.form.FileWithPreviewAndStrongboxWidget