コード例 #1
0
    def handle_send(self, action):
        context = self.context.context
        data, errors = self.extractData()
        if errors:
            self.status = form.EditForm.formErrorsMessage
            return
        channel = data['channel']
        channel_paths = ['/'.join(channel.getPhysicalPath())]
        newsletter_path = "/".join(context.getPhysicalPath())
        newsletter_uid = IUUID(context)
        include_collector_items = data['include_collector_items']
        override_vars = self.get_override_vars()

        job = collective.singing.async.Job(_assemble_messages,
                                            channel_paths,
                                            newsletter_uid,
                                            newsletter_path,
                                            include_collector_items,
                                            override_vars)
        title = _(u"Send '${context}' through ${channel}.",
                  mapping=dict(
            context=context.Title().decode(context.plone_utils.getSiteEncoding()),
            channel=u'"%s"' % channel.title))
        job.title = title
        utils.get_queue().pending.append(job)

        self.status = _(u"Messages queued for delivery.")
コード例 #2
0
    def handle_send(self, action):
        context = self.context.context
        data, errors = self.extractData()
        if errors:
            self.status = form.EditForm.formErrorsMessage
            return
        channel = data["channel"]
        channel_paths = ["/".join(channel.getPhysicalPath())]
        newsletter_path = "/".join(context.getPhysicalPath())
        newsletter_uid = IUUID(context)
        include_collector_items = data["include_collector_items"]
        override_vars = self.get_override_vars()

        job = collective.singing.async.Job(
            _assemble_messages, channel_paths, newsletter_uid, newsletter_path, include_collector_items, override_vars
        )
        title = _(
            u"Send '${context}' through ${channel}.",
            mapping=dict(
                context=context.Title().decode(context.plone_utils.getSiteEncoding()), channel=u'"%s"' % channel.title
            ),
        )
        job.title = title
        utils.get_queue().pending.append(job)

        self.status = _(u"Messages queued for delivery.")
コード例 #3
0
def ChannelAndCollectorVocab(context):
    terms = []
    for channel in channel_lookup(only_sendable=True):
        # use path so we can store the value savely if needed
        path = '/'.join(channel.getPhysicalPath())
        terms.append(zope.schema.vocabulary.SimpleTerm(
            value=(path, None),
            token=channel.name,
            title=channel.title))
        if channel.collector is not None:
            for collector in channel.collector.get_optional_collectors():
                # the value needs to be collector.title as
                # that is what is stored in the subscription
                terms.append(zope.schema.vocabulary.SimpleTerm(
                    value=(path, collector.title),
                    token=channel.name + "/" + collector.title,
                    title=channel.title + " - " + collector.title
                ))

    return SimpleVocabulary(terms)
コード例 #4
0
def ChannelAndCollectorVocab(context):
    terms = []
    for channel in channel_lookup(only_sendable=True):
        # use path so we can store the value savely if needed
        path = '/'.join(channel.getPhysicalPath())
        terms.append(
            zope.schema.vocabulary.SimpleTerm(value=(path, None),
                                              token=channel.name,
                                              title=channel.title))
        if channel.collector is not None:
            for collector in channel.collector.get_optional_collectors():
                # the value needs to be collector.title as
                # that is what is stored in the subscription
                terms.append(
                    zope.schema.vocabulary.SimpleTerm(
                        value=(path, collector.title),
                        token=channel.name + "/" + collector.title,
                        title=channel.title + " - " + collector.title))

    return SimpleVocabulary(terms)