source: products/quintagroup.mailer/branches/devel/quintagroup/mailer/browser/personalpreferences.py @ 3537

Last change on this file since 3537 was 3537, checked in by vmaksymiv, 7 years ago

pep fixes

File size: 1.6 KB
Line 
1from plone.app.users.browser.personalpreferences import UserDataPanel
2from plone.app.users.browser.personalpreferences import UserDataPanelAdapter
3from plone.app.users.userdataschema import IUserDataSchema
4from Products.CMFDefault.formlib.widgets import FileUploadWidget
5
6from zope import schema
7from zope.formlib import form
8from Products.CMFPlone import PloneMessageFactory as _
9
10from quintagroup.mailer.config import GROUP_ID
11
12
13class IQGMailerUserDataSchema(IUserDataSchema):
14    alertssubscribed = schema.Bool(title=_(u'label_alertssubscribed_status',
15        default=u'alertssubscribed'), description=u'', required=False)
16
17
18class QGMailerUserDataPanel(UserDataPanel):
19    def __init__(self, context, request):
20        """ Load the UserDataSchema at view time.
21        """
22        super(QGMailerUserDataPanel, self).__init__(context, request)
23        self.form_fields = form.FormFields(IQGMailerUserDataSchema)
24        self.form_fields['portrait'].custom_widget = FileUploadWidget
25
26
27class QGMailerUserDataConfiglet(QGMailerUserDataPanel):
28    """ """
29
30
31class QGMailerUserDataAdapter(UserDataPanelAdapter):
32
33    def get_alertssubscribed(self):
34        return self._getProperty('alertssubscribed')
35
36    def set_alertssubscribed(self, value):
37        group = self.context.acl_users.getGroup(GROUP_ID)
38        member_id = self._getProperty('id')
39        print member_id
40        if value:
41            group.addMember(member_id)
42        else:
43            group.removeMember(member_id)
44        return self.context.setMemberProperties({'alertssubscribed': value})
45
46    alertssubscribed = property(get_alertssubscribed, set_alertssubscribed)
Note: See TracBrowser for help on using the repository browser.