|
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_i18n.interfaces import INegotiator |
|
20 from pyams_skin.layer import IPyAMSLayer |
|
21 |
|
22 # import packages |
|
23 from pyams_form.form import AJAXEditForm |
|
24 from pyams_pagelet.pagelet import pagelet_config |
|
25 from pyams_zmi.form import AdminDialogEditForm |
|
26 from pyramid.view import view_config |
|
27 from z3c.form import field |
|
28 |
|
29 from pyams_i18n import _ |
|
30 |
|
31 |
|
32 @pagelet_config(name='properties.html', context=INegotiator, layer=IPyAMSLayer, permission='system.view') |
|
33 class NegotiatorPropertiesEditForm(AdminDialogEditForm): |
|
34 """Negotiator properties edit form""" |
|
35 |
|
36 legend = _("Update languages negotiator properties") |
|
37 fields = field.Fields(INegotiator) |
|
38 ajax_handler = 'properties.json' |
|
39 |
|
40 @property |
|
41 def title(self): |
|
42 return self.context.__name__ |
|
43 |
|
44 def updateWidgets(self, prefix=None): |
|
45 super(NegotiatorPropertiesEditForm, self).updateWidgets() |
|
46 self.widgets['server_language'].addClass('select2') |
|
47 self.widgets['policy'].addClass('select2') |
|
48 |
|
49 |
|
50 @view_config(name='properties.json', context=INegotiator, request_type=IPyAMSLayer, |
|
51 permission='system.manage', renderer='json', xhr=True) |
|
52 class NegotiatorPropertiesAJAXEditForm(AJAXEditForm, NegotiatorPropertiesEditForm): |
|
53 """Negotiator properties edit form, AJAX renderer""" |