src/pyams_utils/zmi/timezone.py
changeset 1 3f89629b9e54
child 50 f4e90f45ebb3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_utils/zmi/timezone.py	Thu Feb 19 00:46:48 2015 +0100
@@ -0,0 +1,53 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces.timezone import IServerTimezone
+
+# import packages
+from pyams_form.form import AJAXEditForm
+from pyams_pagelet.pagelet import pagelet_config
+from pyams_zmi.form import AdminDialogEditForm
+from pyramid.view import view_config
+from z3c.form import field
+
+from pyams_utils import _
+
+
+@pagelet_config(name='properties.html', context=IServerTimezone, layer=IPyAMSLayer,
+                permission='system.view')
+class ServerTimezonePropertiesEditForm(AdminDialogEditForm):
+    """Server timezone properties edit form"""
+
+    legend = _("Update server timezone properties")
+    fields = field.Fields(IServerTimezone)
+    ajax_handler = 'properties.json'
+
+    @property
+    def title(self):
+        return self.context.__name__
+
+    def updateWidgets(self, prefix=None):
+        super(ServerTimezonePropertiesEditForm, self).updateWidgets()
+        self.widgets['timezone'].addClass('select2')
+
+
+@view_config(name='properties.json', context=IServerTimezone, request_type=IPyAMSLayer,
+             permission='system.manage', renderer='json', xhr=True)
+class ServerTimezonePropertiesAJAXEditForm(AJAXEditForm, ServerTimezonePropertiesEditForm):
+    """Server timezone properties edit form, AJAX renderer"""