|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
from bika.lims import senaiteMessageFactory as _ |
|
4
|
|
|
from plone.app.users.browser.account import AccountPanelSchemaAdapter |
|
5
|
|
|
from plone.app.users.browser.personalpreferences import \ |
|
6
|
|
|
PersonalPreferencesPanel as Base |
|
7
|
|
|
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile |
|
8
|
|
|
from z3c.form.form import BaseForm |
|
9
|
|
|
from zope.interface import Interface |
|
10
|
|
|
from zope.schema import Choice |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class IPersonalPreferences(Interface): |
|
14
|
|
|
"""Personal Preferences Schema |
|
15
|
|
|
|
|
16
|
|
|
NOTE: Fields need equivalents in user properties! |
|
17
|
|
|
""" |
|
18
|
|
|
|
|
19
|
|
|
timezone = Choice( |
|
20
|
|
|
title=_(u"label_timezone", default=u"Time zone"), |
|
21
|
|
|
description=_(u"help_timezone", default=u"Your time zone"), |
|
22
|
|
|
vocabulary="plone.app.vocabularies.AvailableTimezones", |
|
23
|
|
|
# vocabulary='plone.app.vocabularies.Timezones', |
|
24
|
|
|
required=False, |
|
25
|
|
|
) |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
class PersonalPreferencesPanelAdapter(AccountPanelSchemaAdapter): |
|
29
|
|
|
"""Data manager that gets and sets any property mentioned |
|
30
|
|
|
in the schema to the property sheet |
|
31
|
|
|
""" |
|
32
|
|
|
schema = IPersonalPreferences |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
class PersonalPreferencesPanel(Base): |
|
36
|
|
|
template = ViewPageTemplateFile("templates/account-panel.pt") |
|
37
|
|
|
schema = IPersonalPreferences |
|
38
|
|
|
|
|
39
|
|
|
def updateWidgets(self): |
|
40
|
|
|
# bypass the method of the base class, because it modifies schema |
|
41
|
|
|
# widgets that we removed |
|
42
|
|
|
BaseForm.updateWidgets(self) |
|
43
|
|
|
|