def post(self, participant_id): participant = self.get_participant(participant_id) form = AcknowledgeEmailForm(request.form) if form.validate(): context = { 'participant': participant, 'template': 'meetings/printouts/acknowledge_detail.html' } attachment = PdfRenderer('meetings/printouts/printout.html', width=ACK_W, height=ACK_H, orientation='portrait', as_attachment=True, context=context).as_attachment() if send_single_message(form.to.data, form.subject.data, form.message.data, attachment=attachment, attachment_name='registration_detail.pdf'): flash('Message successfully sent', 'success') return redirect( url_for('.participant_detail', participant_id=participant.id)) else: flash('Message failed to send', 'error') set_language(participant.lang) return render_template(self.template_name, participant=participant, form=form)
def post(self): if current_user.is_authenticated: # abort(404) return Response(status=404) registration_token = session.get('registration_token', None) if not registration_token: # abort(400) return Response(status=400) participant = ( Participant.query .filter_by(registration_token=registration_token) .first_or_404()) if participant.language: set_language(participant.lang) form = RegistrationUserForm(request.form) if form.validate(): participant.user = form.save() db.session.flush() participant.clone() db.session.commit() return redirect(url_for('meetings.registration_user_success')) phrases = { 'success_phrase': self.get_success_phrase(), 'user_phrase': self.get_user_phrase(), } return render_template('meetings/registration/success.html', participant=participant, phrases=phrases, form=form)
def post(self, participant_id): participant = self.get_participant(participant_id) form = AcknowledgeEmailForm(request.form) if form.validate(): context = {"participant": participant, "template": "meetings/printouts/acknowledge_detail.html"} attachment = PdfRenderer( "meetings/printouts/printout.html", width=ACK_W, height=ACK_H, orientation="portrait", as_attachment=True, context=context, ).as_attachment() if send_single_message( form.to.data, form.subject.data, form.message.data, attachment=attachment, attachment_name="registration_detail.pdf", ): flash("Message successfully sent", "success") return redirect(url_for(".participant_detail", participant_id=participant.id)) else: flash("Message failed to send", "error") set_language(participant.lang) return render_template(self.template_name, participant=participant, form=form)
def get(self, participant_id): participant = self.get_participant(participant_id) subject = Phrase.query.filter_by(meeting=g.meeting, group=Phrase.ACK_EMAIL, name=Phrase.SUBJECT).scalar() body = Phrase.query.filter_by(meeting=g.meeting, group=Phrase.ACK_EMAIL, name=Phrase.BODY).scalar() form = AcknowledgeEmailForm(to=participant.email) language = getattr(participant, "lang", "english") if subject: form.subject.data = getattr(subject.description, language, None) if body: form.message.data = getattr(body.description, language, None) set_language(language) return render_template(self.template_name, participant=participant, form=form, language=language)
def get(self, participant_id): participant = ( Participant.query.current_meeting().participants().filter_by( id=participant_id).first_or_404()) context = {'participant': participant} language = getattr(participant, 'lang', 'english') set_language(language) return PdfRenderer('meetings/printouts/acknowledge_detail.html', width=ACK_W, height=ACK_H, orientation='portrait', footer=False, context=context).as_response()
def get(self, participant_id): participant = Participant.query.current_meeting().participants().filter_by(id=participant_id).first_or_404() context = {"participant": participant} language = getattr(participant, "lang", "english") set_language(language) return PdfRenderer( "meetings/printouts/acknowledge_detail.html", width=ACK_W, height=ACK_H, orientation="portrait", footer=False, context=context, ).as_response()
def get(self, participant_id): participant = ( Participant.query.current_meeting().participants().filter_by( id=participant_id).first_or_404()) set_language(participant.lang) context = {'participant': participant} return PdfRenderer('meetings/participant/envelope.html', width=ENVEL_W, height=ENVEL_H, orientation="portrait", footer=False, context=context).as_response()
def get(self, participant_id): participant = self.get_participant(participant_id) subject = Phrase.query.filter_by(meeting=g.meeting, group=Phrase.ACK_EMAIL, name=Phrase.SUBJECT).scalar() body = Phrase.query.filter_by(meeting=g.meeting, group=Phrase.ACK_EMAIL, name=Phrase.BODY).scalar() form = AcknowledgeEmailForm(to=participant.email) language = getattr(participant, 'lang', 'english') if subject: form.subject.data = getattr(subject.description, language, None) if body: form.message.data = getattr(body.description, language, None) set_language(language) return render_template(self.template_name, participant=participant, form=form, language=language)
def send_registration_message(sender, participant): sender = get_meeting_sender() if not sender: flash('No email for sender.', 'error') return subject = "%s registration confirmation" % (participant.meeting.acronym, ) phrase = Phrase.query.filter_by(meeting=participant.meeting, group=Phrase.EMAIL_CONFIRMATION, name=Phrase.FOR_PARTICIPANTS).first() if participant.language: set_language(participant.lang) template = app.jinja_env.get_template( 'meetings/registration/mail_template.html') body_html = template.render({'participant': participant, 'phrase': phrase}) msg = Message(subject=subject, html=body_html, sender=sender, recipients=[participant.email]) mail.send(msg)
def get(self): registration_token = session.get('registration_token', None) if not registration_token: abort(400) session.pop('registration_token', None) participant = (Participant.query.filter_by( registration_token=registration_token).first_or_404()) if participant.language: set_language(participant.lang) if participant.participant_type == Participant.PARTICIPANT: class_form = ParticipantEditForm g.rule_type = Rule.PARTICIPANT else: class_form = MediaParticipantEditForm g.rule_type = Rule.MEDIA Form = custom_form_factory(class_form) Object = custom_object_factory(participant) form = Form(obj=Object()) return render_template('meetings/registration/user_success.html', form=form)
def dispatch_request(self, *args, **kwargs): g.rule_type = self.rule_type lang = request.args.get('lang', 'en') if lang in ('en', 'fr', 'es'): set_language(lang) return super(BaseRegistration, self).dispatch_request(*args, **kwargs)