Example #1
0
 def _process(self):
     person_ids = request.form.getlist('person_id')
     user_ids = request.form.getlist('user_id')
     recipients = set(
         self._find_event_persons(
             person_ids,
             request.args.get('not_invited_only') == '1'))
     recipients |= set(self._find_users(user_ids))
     if self.no_account:
         tpl = get_template_module('events/persons/emails/invitation.html',
                                   event=self.event_new)
         disabled_until_change = False
     else:
         tpl = get_template_module('events/persons/emails/generic.html',
                                   event=self.event_new)
         disabled_until_change = True
     form = EmailEventPersonsForm(person_id=person_ids,
                                  user_id=user_ids,
                                  recipients=[x.email for x in recipients],
                                  body=tpl.get_html_body(),
                                  subject=tpl.get_subject(),
                                  register_link=self.no_account)
     if form.validate_on_submit():
         self._send_emails(form, recipients)
         num = len(recipients)
         flash(
             ngettext('Your email has been sent.',
                      '{} emails have been sent.', num).format(num))
         return jsonify_data()
     return jsonify_template('events/persons/email_dialog.html',
                             form=form,
                             disabled_until_change=disabled_until_change)
Example #2
0
 def _process(self):
     person_ids = request.form.getlist('person_id')
     recipients = {p.email for p in self._find_event_persons(person_ids) if p.email}
     form = EmailEventPersonsForm(person_id=person_ids, recipients=', '.join(recipients))
     if form.validate_on_submit():
         for recipient in recipients:
             email = make_email(to_list=recipient, from_address=form.from_address.data,
                                subject=form.subject.data, body=form.body.data, html=True)
             send_email(email, self.event_new, 'Event Persons')
         num = len(recipients)
         flash(ngettext('Your email has been sent.', '{} emails have been sent.', num).format(num))
         return jsonify_data()
     return jsonify_form(form, submit=_('Send'))
Example #3
0
 def _process(self):
     person_ids = request.form.getlist('person_id')
     recipients = {p.email for p in self._find_event_persons(person_ids) if p.email}
     form = EmailEventPersonsForm(person_id=person_ids, recipients=', '.join(recipients))
     if form.validate_on_submit():
         for recipient in recipients:
             email = make_email(to_list=recipient, from_address=form.from_address.data,
                                subject=form.subject.data, body=form.body.data, html=True)
             send_email(email, self.event_new, 'Event Persons')
         num = len(recipients)
         flash(ngettext('Your email has been sent.', '{} emails have been sent.', num).format(num))
         return jsonify_data()
     return jsonify_form(form, submit=_('Send'))
Example #4
0
 def _process(self):
     person_ids = request.form.getlist('person_id')
     user_ids = request.form.getlist('user_id')
     recipients = set(self._find_event_persons(person_ids, request.args.get('not_invited_only') == '1'))
     recipients |= set(self._find_users(user_ids))
     if self.no_account:
         tpl = get_template_module('events/persons/emails/invitation.html', event=self.event)
         disabled_until_change = False
     else:
         tpl = get_template_module('events/persons/emails/generic.html', event=self.event)
         disabled_until_change = True
     form = EmailEventPersonsForm(person_id=person_ids, user_id=user_ids,
                                  recipients=[x.email for x in recipients], body=tpl.get_html_body(),
                                  subject=tpl.get_subject(), register_link=self.no_account, event=self.event)
     if form.validate_on_submit():
         self._send_emails(form, recipients)
         num = len(recipients)
         flash(ngettext('Your email has been sent.', '{} emails have been sent.', num).format(num))
         return jsonify_data()
     return jsonify_template('events/persons/email_dialog.html', form=form,
                             disabled_until_change=disabled_until_change)