コード例 #1
0
    def __call__(self, context):
        terms = (
            SimpleTerm(u"plain", title=_(u"text/plain", )),
            SimpleTerm(u"html", title=_(u"text/html", )),
        )

        return SimpleVocabulary(terms)
コード例 #2
0
class MailEditForm(EditForm):
    """
    An edit form for the mail action
    """
    form_fields = form.FormFields(IMailAction)
    form_fields['model'].custom_widget = ModelWidget
    label = _(u"Edit Mail Action")
    description = _(u"A mail action can mail different recipient.")
    form_name = _(u"Configure element")
コード例 #3
0
    def __call__(self, context):
        terms = (
            SimpleTerm(
                u"plain",
                title=_(u"text/plain", )),
            SimpleTerm(
                u"html",
                title=_(u"text/html", )),
            )

        return SimpleVocabulary(terms)
コード例 #4
0
class MailAddForm(AddForm):
    """
    An add form for the mail action
    """
    form_fields = form.FormFields(IMailAction)
    form_fields['model'].custom_widget = ModelWidget
    label = _(u"Add Mail Action")
    description = _(u"A mail action can mail different recipient.")
    form_name = _(u"Configure element")

    def create(self, data):
        a = MailAction()
        form.applyChanges(a, self.form_fields, data)
        return a
コード例 #5
0
class IMailModel(Interface):
    """A named utility providing a mail model.

    The mail content rule will allow the user ot pick a mail model based on
    a vocabulary of all named utilities providing this interface. When the
    content rule action is executed, the object being acted upon will be
    adapted to the interface specified under `replacer_interface`.
    Substitutions will then be made based on variables matching field names
    (e.g. "${foobar}" matches the `foobar` field). The substituted values
    are obtained from the adapter.
    """

    title = TextLine(title=_(u"A friendly name for model", ))

    replacer_interface = Object(
        title=_(u"Mail replacer schema"),
        description=_(u"Interface providing word substitution in "\
                        "mail fields: source, recipients, subject, text"),
        schema=Interface)

    fields = List(
        title=_(u"Fields help text"),
        description=_(u"Exposes the variables provided by the replacer"),
        value_type=Tuple(title=_(u"Pair of (key, help text,)"),
                         value_type=TextLine(title=_(u"Name or help text"))))
コード例 #6
0
 def summary(self):
     return _(u"Email report to ${recipients}",
              mapping=dict(recipients=self.recipients))
コード例 #7
0
from collective.contentrules.mail.interfaces import IMailReplacer
from collective.contentrules.mail import MessageFactory as _


class MailModel(object):
    """A mail model described by interface.

    Create instances of this (as shown for DefaultMailModel below) and
    register these as unique named utilities providing IMailModel.
    """

    implements(IMailModel)

    def __init__(self, title, replacer_interface):
        self.title = title
        self.replacer_interface = replacer_interface

    @property
    def fields(self):
        fields = []

        # List of variables provided by replacer interface
        for name, field in getFieldsInOrder(self.replacer_interface):
            fields.append((name, field.title))

        return fields

# The default mail model, which uses the default mail replacer.
DefaultMailModel = MailModel(title=_(u"Standard model for plone content"),
                             replacer_interface=IMailReplacer)
コード例 #8
0
class IMailReplacer(Interface):
    """Interface providing variables which can be used in mail fields:
    source, recipients, subject, text. This is the default implementation,
    which should work on any CMF content providing the IDublinCore interface.

    It is possible to extend this with other attributes and provide a new
    IMailModel utility with a different interface provided as the
    `replacer_interface`.
    """

    id = TextLine(title=_(u"Id of content", ))

    title = TextLine(title=_(u"Title of content", ))

    description = TextLine(title=_(u"Description of content", ))

    url = TextLine(title=_(u"URL to access content", ))

    relative_url = TextLine(
        title=_(u"Relative URL from portal to access content", ))

    portal_url = TextLine(title=_(u"URL of portal", ))

    owner_id = TextLine(title=_(u"Login of content ower", ))

    owner_fullname = TextLine(title=_(u"Full name of content owner", ))

    owner_emails = TextLine(
        title=_(u"Emails of users having Owner role on content", ))

    reader_emails = TextLine(
        title=_(u"Emails of users having Reader role on content", ))

    contributor_emails = TextLine(
        title=_(u"Emails of users having Contributor role on content", ))

    editor_emails = TextLine(
        title=_(u"Emails of users having Editor role on content", ))

    reviewer_emails = TextLine(
        title=_(u"Emails of users having Reviewer role on content", ))

    default_from_email = TextLine(
        title=_(u"Email address of default sender", ))

    default_from_name = TextLine(title=_(u"Full name of default sender", ))

    review_state = TextLine(title=_(u"State of content", ))
コード例 #9
0
from collective.contentrules.mail import MessageFactory as _


class MailModel(object):
    """A mail model described by interface.

    Create instances of this (as shown for DefaultMailModel below) and
    register these as unique named utilities providing IMailModel.
    """

    implements(IMailModel)

    def __init__(self, title, replacer_interface):
        self.title = title
        self.replacer_interface = replacer_interface

    @property
    def fields(self):
        fields = []

        # List of variables provided by replacer interface
        for name, field in getFieldsInOrder(self.replacer_interface):
            fields.append((name, field.title))

        return fields


# The default mail model, which uses the default mail replacer.
DefaultMailModel = MailModel(title=_(u"Standard model for plone content"),
                             replacer_interface=IMailReplacer)
コード例 #10
0
class IMailAction(Interface):
    """Definition of the configuration available for a mail action
    """

    model = Choice(
        title=_(u"Mail model"),
        required=True,
        vocabulary="collective.contentrules.mail.vocabulary.model",
    )

    mimetype = Choice(
        title=_(u"Mail mimetype"),
        required=True,
        vocabulary="collective.contentrules.mail.vocabulary.mimetype",
    )

    subject = TextLine(title=_(u"Subject"),
                       description=_(u"Subject of the message"),
                       required=True)

    source = TextLine(
        title=_(u"Email source"),
        description=_("The email address that sends the email. If no email is"\
                      " provided here, it will use the portal from address."),
        required=False)

    recipients = TextLine(
        title=_(u"Email recipients"),
        description=_("The email where you want to send this message. To send"\
            " it to different email addresses, just separate them with commas."),
        required=True)

    cc = TextLine(
        title=_(u"CC recipients"),
        description=_("The email to receive a copy of this message. To send"\
            " it to different email addresses, just separate them with commas."),
        required=False)

    bcc = TextLine(
        title=_(u"BCC recipients"),
        description=_("The email to receive a blind copy of this message. To"\
     " send it to different email addresses, just separate them with commas."),
        required=False)

    message = Text(
        title=_(u"Message"),
        description=_(u"Type in here the message that you want to mail."),
        required=True)
コード例 #11
0
 def summary(self):
     return _(u"Email report to ${recipients}",
              mapping=dict(recipients=self.recipients))