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

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

registered 'user-information', 'personal-information' views

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', default=u'alertssubscribed'), description=u'', required=False)
15
16
17class QGMailerUserDataPanel(UserDataPanel):
18    def __init__(self, context, request):
19        """ Load the UserDataSchema at view time.
20        """
21        super(QGMailerUserDataPanel, self).__init__(context, request)
22        self.form_fields = form.FormFields(IQGMailerUserDataSchema)
23        self.form_fields['portrait'].custom_widget = FileUploadWidget
24
25
26class QGMailerUserDataConfiglet(QGMailerUserDataPanel):
27    """ """
28
29
30class QGMailerUserDataAdapter(UserDataPanelAdapter):
31
32    def get_alertssubscribed(self):
33        return self._getProperty('alertssubscribed')
34
35    def set_alertssubscribed(self, value):
36        group = self.context.acl_users.getGroup(GROUP_ID)
37        member_id = self._getProperty('id')
38        print member_id
39        if value:
40            group.addMember(member_id)
41        else:
42            group.removeMember(member_id)
43        return self.context.setMemberProperties({'alertssubscribed': value})
44
45    alertssubscribed = property(get_alertssubscribed, set_alertssubscribed)
Note: See TracBrowser for help on using the repository browser.