def _edit_status_description(self, old, new): if not old: return _("added description %r") % new elif not new: return _("removed description, used to be %r") % old else: return _("changed description from %(old)r to %(new)r") % {"old": old, "new": new}
def bind_create(self, ctx): return annotate.MethodBinding( name='create', typeValue=annotate.Method(arguments=[ annotate.Argument('name', EmailAddress(label=_('List address'))), ], label=_('Create')), action=_('Create a New List'))
def bind_unsubscribe(self, ctx): return annotate.MethodBinding( name="requestUnsubscribe", typeValue=annotate.Method( arguments=[ annotate.Argument("ctx", annotate.Context()), annotate.Argument("address", EmailAddress(label=_("Address"))), ], label=_("Request Unsubscription"), ), action=_("Unsubscribe"), )
def bind_subscribe(self, ctx): return annotate.MethodBinding( name="subscribe", typeValue=annotate.Method( arguments=[ annotate.Argument("ctx", annotate.Context()), annotate.Argument("address", EmailAddress(label=_("Address"))), ], label=_("Subscribe Without Confirmation"), ), action=_("Add subscriber to list"), )
def status(kw, old): keys = kw.keys() keys.sort() for k in keys: # TODO can't do _('foo %s bar') % _('quux'), # so we flatten things manually oldVal = old.get(k, None) if oldVal is not None: oldVal = flat.ten.flatten(self.stringifyToLabel(oldVal), ctx) newVal = kw.get(k, None) if newVal is not None: newVal = flat.ten.flatten(self.stringifyToLabel(newVal), ctx) reporter = getattr(self, "_edit_status_%s" % k.replace("-", "_"), None) assert reporter is not None, "key was %r" % k.replace("-", "_") if reporter is None: reporter = lambda old, new: _("changed %(key)s from %(old)s to %(new)s") % { "key": k, "old": old, "new": new, } yield reporter(oldVal, newVal)
def destroy(self, ctx): u = url.URL.fromContext(ctx) request = inevow.IRequest(ctx) request.setComponent(iformless.IRedirectAfterPost, u.curdir()) d = self.original.destroy() d.addCallback(common.statusPrefix, _("Destroyed list %s") % self.original.listname) return d
def requestUnsubscribe(self, ctx, address): common.rememberEmail(ctx, address) data = self.getRequestData(ctx) data["address"] = address message = ( """ A request to unsubscribe the address %(address)s from the mailing list %(listname)s was received on %(date)s by the web application at %(uri)s from the web client %(clientIP)s. """ % data ) d = self.original.requestUnsubscribe(address, message) d.addCallback(common.statusPrefix, _("Unsubscription confirmation request sent to %s") % address) return d
def bind_edit(self, ctx): return annotate.MethodBinding( name="edit", typeValue=annotate.Method( arguments=[ annotate.Argument("ctx", annotate.Context()), annotate.Argument( "subscription", annotate.Radio( choices=["free", "moderated"], stringify=self.stringifyToLabel, label=_("Subscription"), required=True, requiredFailMessage="Please choose something", ), ), annotate.Argument( "posting", annotate.Radio( choices=["free", "auto", "moderated"], stringify=self.stringifyToLabel, label=_("Posting"), required=True, requiredFailMessage="Please choose something", ), ), annotate.Argument( "mail-on-subscription-changes", annotate.Boolean(label=_("Notify owners on subscription changes")), ), annotate.Argument( "mail-on-forced-unsubscribe", annotate.Boolean(label=_("Notify owners on forced unsubscribe")) ), annotate.Argument("description", annotate.String(null="", label=_("Description"))), ], label=_("Edit"), ), action=_("Edit"), )
def create(self, name): d = self.original.create(name, [self.original.getCommandAddress(name, 'ignore')]) d.addCallback(common.statusPrefix, _('Created list %s') % name) d.addErrback(self._createFailed, name) return d
def _createFailed(self, reason, name): reason.trap(eocinterface.EocFailed) raise annotate.ValidateError({'name': reason.getErrorMessage()}, formErrorMessage=_('Eoc failed'), partialForm={'name': name})
def _edit_status_posting(self, old, new): return _("changed posting from %(old)s to %(new)s") % {"old": old, "new": new}
def _edit_status_mail_on_subscription_changes(self, old, new): return _("changed whether to notify owners on " "subscription from %(old)s to %(new)s") % { "old": old, "new": new, }
def subscribe(self, ctx, address): common.rememberEmail(ctx, address) d = self.original.subscribe(address) d.addCallback(common.statusPrefix, _("Subscribed %s") % address) return d
def _edit_status_mail_on_forced_unsubscribe(self, old, new): return _("changed whether to notify owners on forced " "unsubscription from %(old)s to %(new)s") % { "old": old, "new": new, }
def __edit(self, cfg, ctx, **kw): old = {} ( old["subscription"], old["posting"], old["mail-on-subscription-changes"], old["mail-on-forced-unsubscribe"], old["description"], ) = cfg for k, v in kw.items(): oldVal = old.get(k, None) if oldVal is not None and oldVal == v: # not changed del kw[k] if not kw: return _("Settings not changed.") def status(kw, old): keys = kw.keys() keys.sort() for k in keys: # TODO can't do _('foo %s bar') % _('quux'), # so we flatten things manually oldVal = old.get(k, None) if oldVal is not None: oldVal = flat.ten.flatten(self.stringifyToLabel(oldVal), ctx) newVal = kw.get(k, None) if newVal is not None: newVal = flat.ten.flatten(self.stringifyToLabel(newVal), ctx) reporter = getattr(self, "_edit_status_%s" % k.replace("-", "_"), None) assert reporter is not None, "key was %r" % k.replace("-", "_") if reporter is None: reporter = lambda old, new: _("changed %(key)s from %(old)s to %(new)s") % { "key": k, "old": old, "new": new, } yield reporter(oldVal, newVal) def commaify(iterable): """Put add commas to sequence to separate multiple rounds.""" iterable = iter(iterable) try: first = iterable.next() except StopIteration: return yield first for item in iterable: yield ", " yield item d = self.original.edit(**kw) d.addCallback(common.statusPrefix, _("Edited settings: "), commaify(status(kw, old))) return d
def __init__(self, **kw): self.list = kw.pop("list") self.title = _("Mailing List %s") % self.list.listname super(WebMailingList, self).__init__(**kw)
def _edit_status_subscription(self, old, new): return _("changed subscription from %(old)s to %(new)s") % {"old": old, "new": new}
def bind_destroy(self, ctx): return annotate.MethodBinding( name="destroy", typeValue=annotate.Method(arguments=[annotate.Argument("ctx", annotate.Context())], label=_("Destroy")), action=_("Destroy"), )