def create(self, subject, body, recipients, sender_email, sender_name, instance, include_footer): send_message(subject, body, c.user, recipients, sender_email=sender_email, sender_name=sender_name, instance=instance, include_footer=include_footer) return ret_success( message=_("Message sent to %d users.") % len(recipients))
def create(self, subject, body, recipients, sender_email, sender_name, instance, include_footer): send_message(subject, body, c.user, recipients, sender_email=sender_email, sender_name=sender_name, instance=instance, include_footer=include_footer) return ret_success(message=_("Message sent to %d users.") % len(recipients))
class MessageController(BaseController): def new(self, id, format='html', errors={}): c.page_user = get_entity_or_abort(model.User, id) require.user.message(c.page_user) html = render("/message/new.html", overlay=format == u'overlay') return htmlfill.render(html, defaults=request.params, errors=errors, force_defaults=False) def create(self, id, format='html'): c.page_user = get_entity_or_abort(model.User, id) require.user.message(c.page_user) try: self.form_result = MessageCreateForm().to_python(request.params) except Invalid, i: return self.new(id, errors=i.unpack_errors()) body = self.form_result.get('body') subject = self.form_result.get('subject') send_message(subject, body, c.user, [c.page_user], instance=c.instance, massmessage=False) h.flash(_("Your message has been sent. Thanks."), 'success') redirect(h.entity_url(c.page_user, instance=c.instance))
def create_proposal(self, proposal_id): c.proposal = get_entity_or_abort(Proposal, proposal_id) require.proposal.message(c.proposal) recipients = set() if self.form_result.get(u'supporters'): recipients.update(democracy.supporters(c.proposal.rate_poll)) if self.form_result.get(u'opponents'): recipients.update(democracy.opponents(c.proposal.rate_poll)) if self.form_result.get(u'creators'): recipients.update(c.proposal.get_creators()) send_message(self.form_result.get('subject'), self.form_result.get('body'), c.user, recipients, instance=c.instance) h.flash(_("Message sent to %d users.") % len(recipients), 'success') redirect(h.entity_url(c.proposal))