Exemple #1
0
class IAnswer(form.Schema, IImageScaleTraversable):
    """
    An answer.
    """

    text = RichText(
        title=_(u"Answer"),
        description=_("The answer."),
        required=True,
    )
def questionAnswered(answer, event):
    """ Send mail when a question is answered.
    """
    wft = getToolByName(answer, 'portal_workflow')
    question = answer.aq_parent
    review_state = wft.getInfoFor(
        question, 'review_state', 'question_workflow')
    if review_state in ['submitted', ]:
        wft.doActionFor(question, 'answer')

    # get the basic mail settings and details
    errors, mail_host, mail_from, mail_to = get_basic_mailsettings(question)

    if errors:
        for error in errors:
            LOGGER.warn(error)
    else:
        # Compose email
        subject = _(u"Your question was answered.")
        view = answer.restrictedTraverse('@@answered-message')
        message = view()

        # Send email
        mail_host.send(message, mail_to, mail_from, subject=subject,
                       charset='utf-8')
Exemple #3
0
class IQuestion(form.Schema, IImageScaleTraversable):
    """
    A question about a piece of content.
    """

    text = schema.Text(
        title=_(u"Question"),
        description=_("The question."),
        required=True,
    )

    relatedContent = RelationChoice(
        title=_(u'label_content_item', default=u'Related Content'),
        source=ObjPathSourceBinder(
            object_provides='Products.CMFCore.interfaces._content.IContentish'
        ),
        required=False,
    )
class IAllowQuestionsBehavior(form.Schema):
    """
       Marker/Form interface for Allow Questions Behavior
    """
    form.fieldset(
        'settings',
        label=_(u'Settings'),
        fields=[
            'allowQuestions',
        ],
    )

    allowQuestions = schema.Bool(
        title=_(u"label_allowquestions", default=u"Allow questions"),
        required=False,
        default=False,
    )

    form.omitted('allowQuestions')
    form.no_omit(IEditForm, 'allowQuestions')
    form.no_omit(IAddForm, 'allowQuestions')
Exemple #5
0
    def notifyJSON(self):
        # get the basic mail settings and details
        errors, mail_host, mail_from, mail_to = get_basic_mailsettings(
            self.context)
        if errors:
            for error in errors:
                LOGGER.warn(error)
            return errors

        # Compose email
        subject = _(u"Your question was answered.")
        message = "Annotator mail test"
        # Send email
        mail_host.secureSend(message, mail_to, mail_from, subject=subject)
        result = 'success'
        return json.dumps({'result': result})