Exemple #1
0
    def _save_notification_settings(self):
        _ = self._
        form = self.request.form

        if self.request.request_method != 'POST':
            return
        theuser = self.request.user
        if not theuser:
            return

        # subscription for page change notification
        theuser.subscribed_pages = self._decode_pagelist('subscribed_pages')

        # subscription to various events
        available = events.get_subscribable_events()
        theuser.email_subscribed_events = []
        theuser.jabber_subscribed_events = []
        types = {
            'email': theuser.email_subscribed_events,
            'jabber': theuser.jabber_subscribed_events
        }
        for tp in types:
            for evt in available:
                fieldname = 'subscribe:%s:%s' % (tp, evt)
                if fieldname in form:
                    types[tp].append(evt)
        # save data
        theuser.save()

        return 'info', _("Notification settings saved!")
Exemple #2
0
    def _save_notification_settings(self):
        _ = self._
        form = self.request.form

        theuser = self.request.user
        if not theuser:
            return

        # subscription for page change notification
        theuser.subscribed_pages = self._decode_pagelist('subscribed_pages')

        # subscription to various events
        available = events.get_subscribable_events()
        theuser.email_subscribed_events = []
        theuser.jabber_subscribed_events = []
        types = {
            'email': theuser.email_subscribed_events,
            'jabber': theuser.jabber_subscribed_events
        }
        for tp in types:
            for evt in available:
                fieldname = 'subscribe:%s:%s' % (tp, evt)
                if fieldname in form:
                    types[tp].append(evt)
        # save data
        theuser.save()

        return 'info', _("Notification settings saved!")
Exemple #3
0
    def _save_notification_settings(self):
        _ = self._
        form = self.request.form

        theuser = self.request.user
        if not theuser:
            return

        # subscription for page change notification
        theuser.subscribed_pages = self._decode_pagelist("subscribed_pages")

        # subscription to various events
        available = events.get_subscribable_events()
        theuser.email_subscribed_events = []
        theuser.jabber_subscribed_events = []
        types = {"email": theuser.email_subscribed_events, "jabber": theuser.jabber_subscribed_events}
        for tp in types:
            for evt in available:
                fieldname = "subscribe:%s:%s" % (tp, evt)
                if fieldname in form:
                    types[tp].append(evt)
        # save data
        theuser.save()

        return "info", _("Notification settings saved!")
Exemple #4
0
    def _event_select(self):
        """ Create event subscription list. """
        _ = self._

        types = []
        if self.cfg.mail_enabled and self.request.user.email:
            types.append(('email', _("'''Email'''", wiki=True)))
        if self.cfg.jabber_enabled and self.request.user.jid:
            types.append(('jabber', _("'''Jabber'''", wiki=True)))

        table = html.TABLE()
        header = html.TR()
        table.append(header)
        for name, descr in types:
            header.append(html.TH().append(html.Raw(descr)))
        header.append(
            html.TH(align='left').append(
                html.Raw(_("'''Event type'''", wiki=True))))

        event_list = events.get_subscribable_events()
        super = self.request.user.isSuperUser()

        # Create a list of (value, name) tuples for display as radiobuttons
        # Only include super-user visible events if current user has these rights.
        # It's cosmetic - the check for super-user rights should be performed
        # in event handling code as well!
        allowed = []
        for key in event_list.keys():
            if not event_list[key]['superuser'] or super:
                allowed.append((key, event_list[key]['desc']))

        for evname, evdescr in allowed:
            tr = html.TR()
            table.append(tr)
            for notiftype, notifdescr in types:
                checked = evname in getattr(self.request.user,
                                            '%s_subscribed_events' % notiftype)
                tr.append(html.TD().append(
                    html.INPUT(type='checkbox',
                               checked=checked,
                               name='subscribe:%s:%s' % (notiftype, evname))))
            tr.append(html.TD().append(html.Raw(
                self.request.getText(evdescr))))

        return table
Exemple #5
0
    def _event_select(self):
        """ Create event subscription list. """
        _ = self._

        types = []
        if self.cfg.mail_enabled and self.request.user.email:
            types.append(('email', _("'''Email'''", wiki=True)))
        if self.cfg.jabber_enabled and self.request.user.jid:
            types.append(('jabber', _("'''Jabber'''", wiki=True)))

        table = html.TABLE()
        header = html.TR()
        table.append(header)
        for name, descr in types:
            header.append(html.TH().append(html.Raw(descr)))
        header.append(html.TH(align='left').append(html.Raw(_("'''Event type'''", wiki=True))))

        event_list = events.get_subscribable_events()
        super = self.request.user.isSuperUser()

        # Create a list of (value, name) tuples for display as radiobuttons
        # Only include super-user visible events if current user has these rights.
        # It's cosmetic - the check for super-user rights should be performed
        # in event handling code as well!
        allowed = []
        for key in event_list.keys():
            if not event_list[key]['superuser'] or super:
                allowed.append((key, event_list[key]['desc']))

        for evname, evdescr in allowed:
            tr = html.TR()
            table.append(tr)
            for notiftype, notifdescr in types:
                checked = evname in getattr(self.request.user,
                                            '%s_subscribed_events' % notiftype)
                tr.append(html.TD().append(html.INPUT(
                        type='checkbox',
                        checked=checked,
                        name='subscribe:%s:%s' % (notiftype, evname))))
            tr.append(html.TD().append(html.Raw(self.request.getText(evdescr))))

        return table
Exemple #6
0
def test_subscribable_events(request):
    """Test if there are any subscribable events. There should be some."""

    print "There should be at least a few subscribable events!"
    assert events.get_subscribable_events()
Exemple #7
0
def test_subscribable_events(request):
    """Test if there are any subscribable events. There should be some."""

    print "There should be at least a few subscribable events!"
    assert events.get_subscribable_events()