예제 #1
0
    def preview(self, subject, body, recipients, sender_email, sender_name,
                instance, include_footer):
        recipients_list = sorted(list(recipients), key=lambda r: r.name)
        if recipients_list:
            try:
                rendered_body = render_body(body, recipients_list[0],
                                            is_preview=True)
            except (KeyError, ValueError) as e:
                rendered_body = _('Could not render message: %s') % str(e)
        else:
            rendered_body = body

        # wrap body, but leave long words (e.g. links) intact
        rendered_body = u'\n'.join(textwrap.fill(line, break_long_words=False)
                                   for line in rendered_body.split(u'\n'))

        data = {
            'sender_email': sender_email,
            'sender_name': sender_name,
            'subject': subject,
            'body': rendered_body,
            'recipients': recipients_list,
            'recipients_count': len(recipients_list),
            'params': request.params,
            'include_footer': include_footer,
            'instance': instance,
        }
        return render('/massmessage/preview.html', data)
예제 #2
0
    def preview(self, subject, body, recipients, sender_email, sender_name,
                instance, include_footer):
        recipients_list = sorted(list(recipients), key=lambda r: r.name)
        if recipients_list:
            try:
                rendered_body = render_body(body,
                                            recipients_list[0],
                                            is_preview=True)
            except (KeyError, ValueError) as e:
                rendered_body = _('Could not render message: %s') % str(e)
        else:
            rendered_body = body

        # wrap body, but leave long words (e.g. links) intact
        rendered_body = u'\n'.join(
            textwrap.fill(line, break_long_words=False)
            for line in rendered_body.split(u'\n'))

        data = {
            'sender_email': sender_email,
            'sender_name': sender_name,
            'subject': subject,
            'body': rendered_body,
            'recipients': recipients_list,
            'recipients_count': len(recipients_list),
            'params': request.params,
            'include_footer': include_footer,
            'instance': instance,
        }
        return render('/massmessage/preview.html', data)
예제 #3
0
    def notify(self, force_resend=False):

        if (self.recipient.is_email_activated()
                and self.recipient.email_messages):

            from adhocracy.lib import mail
            from adhocracy.lib.message import render_body

            body = render_body(self.message.body, self.recipient,
                               self.message.include_footer)

            mail.to_user(self.recipient,
                         self.message.subject,
                         body,
                         headers={},
                         decorate_body=False,
                         email_from=self.message.sender_email,
                         name_from=self.message.sender_name)
예제 #4
0
파일: massmessage.py 프로젝트: whausen/part
    def preview(self, sender, subject, body, recipients):
        recipients_list = sorted(list(recipients), key=lambda r: r.name)
        if recipients_list:
            try:
                rendered_body = render_body(body, recipients[0])
            except (KeyError, ValueError) as e:
                rendered_body = _('Could not render message: %s') % str(e)
        else:
            rendered_body = body

        data = {
            'sender': sender,
            'subject': subject,
            'body': rendered_body,
            'recipients': recipients_list,
            'recipients_count': len(recipients_list),
            'params': request.params,
        }
        return render('/massmessage/preview.html', data)
예제 #5
0
파일: message.py 프로젝트: alkadis/vcv
 def show(self, id, format='html'):
     c.message = get_entity_or_abort(model.Message, id)
     require.message.show(c.message)
     c.body = _message.render_body(c.message.body, c.user)
     return render('/message/show.html', overlay=format == 'overlay')
예제 #6
0
파일: message.py 프로젝트: alkadis/vcv
    def rendered_body(self, user):
        from adhocracy.lib.message import render_body

        return render_body(self.body, user)
예제 #7
0
파일: message.py 프로젝트: alkadis/vcv
 def show(self, id, format='html'):
     c.message = get_entity_or_abort(model.Message, id)
     require.message.show(c.message)
     c.body = _message.render_body(c.message.body, c.user)
     return render('/message/show.html', overlay=format == 'overlay')
예제 #8
0
파일: message.py 프로젝트: alkadis/vcv
    def rendered_body(self, user):
        from adhocracy.lib.message import render_body

        return render_body(self.body, user)