def send_email_page(username): user = User.query.filter_by(username=username).first() if user is None: abort(404) next_url = url_for("user_profile_page", username=user.username) if user.email is None: flash("User has no email address!", "error") return redirect(next_url) form = SendEmailForm(request.form) if form.validate_on_submit(): text = form.text.data html = markdown(text) task = sendEmailRaw.delay([user.email], form.subject.data, text, html) return redirect(url_for("check_task", id=task.id, r=next_url)) return render_template("users/send_email.html", form=form)
def send_email(username): user = User.query.filter_by(username=username).first() if user is None: abort(404) next_url = url_for("users.profile", username=user.username) if user.email is None: flash("User has no email address!", "danger") return redirect(next_url) form = SendEmailForm(request.form) if form.validate_on_submit(): addAuditLog(AuditSeverity.MODERATION, current_user, "Sent email to {}".format(user.display_name), url_for("users.profile", username=username)) text = form.text.data html = render_markdown(text) task = sendEmailRaw.delay([user.email], form.subject.data, text, html) return redirect(url_for("tasks.check", id=task.id, r=next_url)) return render_template("users/send_email.html", form=form)
def emit(self, record): text = self.format(record) if self.formatter else None html = self.html_formatter.format( record) if self.html_formatter else None sendEmailRaw.delay(self.send_to, self.getSubject(record), text, html)