|
1 # |
|
2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net> |
|
3 # All Rights Reserved. |
|
4 # |
|
5 # This software is subject to the provisions of the Zope Public License, |
|
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
10 # FOR A PARTICULAR PURPOSE. |
|
11 # |
|
12 |
|
13 __docformat__ = 'restructuredtext' |
|
14 |
|
15 |
|
16 # import standard library |
|
17 |
|
18 # import interfaces |
|
19 from pyams_skin.interfaces import IUserSkinnable |
|
20 from pyams_skin.layer import IPyAMSLayer |
|
21 from pyams_utils.interfaces import MANAGE_SKIN_PERMISSION |
|
22 from pyams_zmi.interfaces.menu import IPropertiesMenu |
|
23 from pyams_zmi.layer import IAdminLayer |
|
24 |
|
25 # import packages |
|
26 from pyams_form.form import AJAXEditForm |
|
27 from pyams_pagelet.pagelet import pagelet_config |
|
28 from pyams_skin.viewlet.menu import MenuItem, MenuDivider |
|
29 from pyams_viewlet.viewlet import viewlet_config |
|
30 from pyams_zmi.form import AdminDialogEditForm |
|
31 from pyramid.view import view_config |
|
32 from z3c.form import field |
|
33 |
|
34 from pyams_zmi import _ |
|
35 |
|
36 |
|
37 # |
|
38 # User skinnable properties configuration |
|
39 # |
|
40 |
|
41 @viewlet_config(name='user-skin-properties.divider', context=IUserSkinnable, layer=IAdminLayer, manager=IPropertiesMenu, |
|
42 permission=MANAGE_SKIN_PERMISSION, weight=199) |
|
43 class UserSkinnablePropertiesMenuDivider(MenuDivider): |
|
44 """User skin properties menu divider""" |
|
45 |
|
46 |
|
47 @viewlet_config(name='user-skin-properties.menu', context=IUserSkinnable, layer=IAdminLayer, manager=IPropertiesMenu, |
|
48 permission=MANAGE_SKIN_PERMISSION, weight=200) |
|
49 class UserSkinnablePropertiesMenuItem(MenuItem): |
|
50 """User skin properties menu""" |
|
51 |
|
52 label = _("Graphic theme...") |
|
53 icon_class = 'fa-paint-brush' |
|
54 url = 'user-skin-properties.html' |
|
55 modal_target = True |
|
56 |
|
57 |
|
58 @pagelet_config(name='user-skin-properties.html', context=IUserSkinnable, layer=IPyAMSLayer, |
|
59 permission=MANAGE_SKIN_PERMISSION) |
|
60 class UserSkinnablePropertiesEditForm(AdminDialogEditForm): |
|
61 """User skin properties edit form""" |
|
62 |
|
63 legend = _("Graphic theme elements") |
|
64 label_css_class = 'control-label col-md-4' |
|
65 input_css_class = 'col-md-8' |
|
66 |
|
67 @property |
|
68 def fields(self): |
|
69 fields = field.Fields(IUserSkinnable) |
|
70 if not self.context.can_inherit_skin: |
|
71 fields = fields.omit('inherit_skin') |
|
72 return fields |
|
73 |
|
74 ajax_handler = 'user-skin-properties.json' |
|
75 edit_permission = MANAGE_SKIN_PERMISSION |
|
76 |
|
77 |
|
78 @view_config(name='user-skin-properties.json', context=IUserSkinnable, request_type=IPyAMSLayer, |
|
79 permission=MANAGE_SKIN_PERMISSION, renderer='json', xhr=True) |
|
80 class UserSkinnablePropertiesAJAXEditForm(AJAXEditForm, UserSkinnablePropertiesEditForm): |
|
81 """User skin properties edit form, JSON renderer""" |