Project

General

Profile

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

root / extra / auquotidien.py @ ca1830a1

1
from qommon.publisher import get_publisher_class, get_request
2
from qommon.misc import get_cfg
3

    
4
import modules.admin
5
import modules.backoffice
6
import modules.links_ui
7
import modules.announces_ui
8
import modules.events_ui
9
import modules.forms_ui
10
import modules.payments_ui
11
import modules.strongbox_ui
12
import modules.formpage
13
import modules.template
14
import modules.root
15
import modules.form
16
import modules.payments
17
import modules.connectors
18

    
19
get_publisher_class().register_translation_domain('auquotidien')
20
get_publisher_class().default_configuration_path = 'au-quotidien-wcs-settings.xml'
21

    
22
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
    if not admin_role:
28
        return False
29
    if not (user.is_admin or admin_role in (user.roles or [])):
30
        return False
31
    return True
32

    
33
rdb = get_publisher_class().backoffice_directory_class
34

    
35
rdb.register_menu_item('forms', None)
36
rdb.register_directory('forms', modules.forms_ui.FormsDirectory())
37
rdb.register_menu_item('forms/', _('Forms'))
38

    
39
rdb.register_menu_item('pending', _('Pending Forms'))
40

    
41
rdb.register_directory('announces', modules.announces_ui.AnnouncesDirectory())
42
rdb.register_menu_item('announces/', _('Announces'), check_visibility)
43

    
44
rdb.register_directory('links', modules.links_ui.LinksDirectory())
45
rdb.register_menu_item('links/', _('Links'), check_visibility)
46

    
47
rdb.register_directory('events', modules.events_ui.EventsDirectory())
48
rdb.register_menu_item('events/', _('Events'), check_visibility)
49

    
50
rdb.register_directory('payments', modules.payments_ui.PaymentsDirectory())
51
rdb.register_menu_item('payments/', _('Payments'), check_visibility)
52

    
53
rdb.register_directory('strongbox', modules.strongbox_ui.StrongboxDirectory())
54
rdb.register_menu_item('strongbox/', _('Strong Box'), check_visibility)
55

    
56
import wcs.fields
57
wcs.fields.FileField.widget_class = modules.form.FileWithPreviewAndStrongboxWidget
    (1-1/1)