def send_bulk_email(): form = SendEmailForm(request.form) if form.validate_on_submit(): addAuditLog(AuditSeverity.MODERATION, current_user, "Sent bulk email", None, None, form.text.data) text = form.text.data html = render_markdown(text) for user in User.query.filter(User.email != None).all(): send_user_email.delay(user.email, form.subject.data, text, html) return redirect(url_for("admin.admin_page")) return render_template("admin/send_bulk_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(): 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 send_single_email(): username = request.args["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 = send_user_email.delay(user.email, form.subject.data, text, html) return redirect(url_for("tasks.check", id=task.id, r=next_url)) return render_template("admin/send_email.html", form=form, user=user)
def markdown(): return render_markdown(request.data.decode("utf-8"))