src/pyams_thesaurus/__init__.py
changeset 19 6cb6acc05cc3
parent 17 cbb60bf47bf3
child 36 84a4e78a6567
equal deleted inserted replaced
18:23ac4c21b235 19:6cb6acc05cc3
    14 
    14 
    15 
    15 
    16 from pyramid.i18n import TranslationStringFactory
    16 from pyramid.i18n import TranslationStringFactory
    17 _ = TranslationStringFactory('pyams_thesaurus')
    17 _ = TranslationStringFactory('pyams_thesaurus')
    18 
    18 
       
    19 from pyams_thesaurus.interfaces import ADMIN_THESAURUS_PERMISSION, MANAGE_THESAURUS_CONTENT_PERMISSION, \
       
    20     MANAGE_THESAURUS_EXTRACT_PERMISSION
    19 from pyams_utils.interfaces import VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION
    21 from pyams_utils.interfaces import VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION
    20 
    22 
    21 
    23 
    22 def includeme(config):
    24 def includeme(config):
    23     """Pyramid include"""
    25     """Pyramid include"""
    24 
    26 
    25     from .include import include_package
    27     from .include import include_package
    26     include_package(config)
    28     include_package(config)
    27 
    29 
    28     # register custom permissions
    30     # register custom permissions
    29     config.register_permission({'id': 'thesaurus.admin',
    31     config.register_permission({'id': ADMIN_THESAURUS_PERMISSION,
    30                                 'title': _("Manage thesaurus properties")})
    32                                 'title': _("Manage thesaurus properties")})
    31     config.register_permission({'id': 'thesaurus.manage',
    33     config.register_permission({'id': MANAGE_THESAURUS_CONTENT_PERMISSION,
    32                                 'title': _("Manage thesaurus content")})
    34                                 'title': _("Manage thesaurus content")})
    33     config.register_permission({'id': 'thesaurus.extract.manage',
    35     config.register_permission({'id': MANAGE_THESAURUS_EXTRACT_PERMISSION,
    34                                 'title': _("Manage thesaurus extract")})
    36                                 'title': _("Manage thesaurus extract")})
    35 
    37 
    36     # register custom roles
    38     # register custom roles
    37     config.register_role({'id': 'thesaurus.Admin',
    39     config.register_role({'id': 'thesaurus.Admin',
    38                           'title': _("Thesaurus administrator (role)"),
    40                           'title': _("Thesaurus administrator (role)"),
    39                           'permissions': {'thesaurus.admin', 'thesaurus.manage', 'thesaurus.extract.manage',
    41                           'permissions': {ADMIN_THESAURUS_PERMISSION, MANAGE_THESAURUS_CONTENT_PERMISSION,
       
    42                                           MANAGE_THESAURUS_EXTRACT_PERMISSION,
    40                                           VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
    43                                           VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
    41                           'managers': {'system:admin', 'role:system.Manager'}})
    44                           'managers': {'system:admin', 'role:system.Manager'}})
    42     config.register_role({'id': 'thesaurus.Manager',
    45     config.register_role({'id': 'thesaurus.Manager',
    43                           'title': _("Thesaurus content manager (role)"),
    46                           'title': _("Thesaurus content manager (role)"),
    44                           'permissions': {'thesaurus.manage', 'thesaurus.extract.manage',
    47                           'permissions': {MANAGE_THESAURUS_CONTENT_PERMISSION, MANAGE_THESAURUS_EXTRACT_PERMISSION,
    45                                           VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
    48                                           VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
    46                           'managers': {'system:admin', 'role:system.Manager', 'role:thesaurus.Admin'}})
    49                           'managers': {'system:admin', 'role:system.Manager', 'role:thesaurus.Admin'}})
    47     config.register_role({'id': 'thesaurus.ExtractManager',
    50     config.register_role({'id': 'thesaurus.ExtractManager',
    48                           'title': _("Thesaurus extract manager (role)"),
    51                           'title': _("Thesaurus extract manager (role)"),
    49                           'permissions': {'thesaurus.extract.manage',
    52                           'permissions': {MANAGE_THESAURUS_EXTRACT_PERMISSION,
    50                                           VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
    53                                           VIEW_PERMISSION, VIEW_SYSTEM_PERMISSION},
    51                           'managers': {'system:admin', 'role:system.Manager', 'role:thesaurus.Admin'}})
    54                           'managers': {'system:admin', 'role:system.Manager', 'role:thesaurus.Admin'}})