Project

General

Profile

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

root / extra / auquotidien.py @ dc027d89

1
from quixote import get_publisher
2

    
3
from qommon.publisher import get_publisher_class, get_request
4
from qommon.misc import get_cfg
5

    
6
import modules.admin
7
import modules.backoffice
8
import modules.links_ui
9
import modules.announces_ui
10
import modules.categories_admin
11
import modules.events_ui
12
import modules.payments_ui
13
import modules.strongbox_ui
14
import modules.formpage
15
import modules.template
16
import modules.root
17
import modules.form
18
import modules.payments
19
import modules.connectors
20
import modules.abelium_domino_ui
21
import modules.abelium_domino_vars
22
import modules.abelium_domino_synchro
23

    
24
get_publisher_class().register_translation_domain('auquotidien')
25
get_publisher_class().default_configuration_path = 'au-quotidien-wcs-settings.xml'
26
get_publisher_class().backoffice_feed_url = {
27
    'fr': 'http://www.au-quotidien.com/fr/backoffice.atom'
28
}
29

    
30

    
31
def check_visibility(target):
32
    user = get_request().user
33
    if not user:
34
        return False
35
    target = target.strip('/')
36
    if target == 'management':
37
        target = 'forms'
38
    if target == 'strongbox':
39
        if not get_publisher().has_site_option(target):
40
            # strongbox disabled in site-options.cfg
41
            return False
42
        if not get_cfg('misc', {}).get('aq-strongbox'):
43
            # strongbox disabled in settings panel
44
            return False
45
    admin_role = get_cfg('aq-permissions', {}).get(target, None)
46
    if not admin_role:
47
        return False
48
    if not (user.is_admin or admin_role in (user.roles or [])):
49
        return False
50
    return True
51

    
52
rdb = get_publisher_class().backoffice_directory_class
53

    
54
rdb.items = []
55

    
56
rdb.register_directory('announces', modules.announces_ui.AnnouncesDirectory())
57
rdb.register_menu_item('announces/', _('Announces'), check_visibility)
58

    
59
rdb.register_directory('links', modules.links_ui.LinksDirectory())
60
rdb.register_menu_item('links/', _('Links'), check_visibility)
61

    
62
rdb.register_directory('events', modules.events_ui.EventsDirectory())
63
rdb.register_menu_item('events/', _('Events'), check_visibility)
64

    
65
rdb.register_directory('payments', modules.payments_ui.PaymentsDirectory())
66
rdb.register_menu_item('payments/', _('Payments'), check_visibility)
67

    
68
rdb.register_directory('strongbox', modules.strongbox_ui.StrongboxDirectory())
69
rdb.register_menu_item('strongbox/', _('Strongbox'), check_visibility)
70

    
71
rdb.register_directory('panel', modules.admin.PanelDirectory())
72
rdb.register_menu_item('panel/', _('Control Panel'))
73

    
74
rdb.register_directory('categories', modules.categories_admin.CategoriesDirectory())
75

    
76
import wcs.fields
77
wcs.fields.FileField.widget_class = modules.form.FileWithPreviewAndStrongboxWidget
78

    
79
import wcs.admin.settings
80
wcs.admin.settings.SettingsDirectory.domino = modules.abelium_domino_ui.AbeliumDominoDirectory()
81
wcs.admin.settings.SettingsDirectory._q_exports.append('domino')
82

    
83

    
    (1-1/1)