From 24384b2a351a5b6d242d243c63cfb933acf527d7 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Fri, 23 Feb 2024 14:40:07 -0500 Subject: [PATCH] Update bulk mailer tool Use new admin site theme, allow for tinyMCE api key to be input to config.py --- goathacks/admin/__init__.py | 6 ++++-- goathacks/templates/mail.html | 35 +++++++++++++++++------------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/goathacks/admin/__init__.py b/goathacks/admin/__init__.py index 3d2eeba..7f567fc 100644 --- a/goathacks/admin/__init__.py +++ b/goathacks/admin/__init__.py @@ -1,4 +1,4 @@ -from flask import Blueprint, jsonify, redirect, render_template, request, url_for +from flask import Blueprint, current_app, jsonify, redirect, render_template, request, url_for from flask_login import current_user, login_required from flask_mail import Message @@ -62,8 +62,10 @@ def mail(): return redirect(url_for("dashboard.home")) total_count = len(db.session.execute(db.select(User)).scalars().all()) + api_key = current_app.config["MCE_API_KEY"] - return render_template("mail.html", NUM_HACKERS=total_count) + return render_template("mail.html", NUM_HACKERS=total_count, + MCE_API_KEY=api_key) @bp.route("/users") @login_required diff --git a/goathacks/templates/mail.html b/goathacks/templates/mail.html index f58fef7..a85567f 100644 --- a/goathacks/templates/mail.html +++ b/goathacks/templates/mail.html @@ -1,23 +1,20 @@ - - - - 🍪CookieMailer +{% extends 'admin-layout.html' %} + + {% block head %} + {{super()}} - - - -
-
-
-
-

🍪CookieMailer

+ {% endblock %} + {% block app_content %} +
+
+

🍪CookieMailer


- @@ -26,7 +23,8 @@

- +



- +
@@ -77,6 +75,7 @@ ]; if((rec != "all" && window.confirm("Send test email?")) || (rec == "all" && window.confirm("Send email to {{NUM_HACKERS}} recipients?"))) { + console.log(`Sending email to ${rec}`) fetch('/admin/send', {method: 'POST', body: JSON.stringify(body), headers: headers}).then(async (res) => { window.alert(await res.text()); }).catch((err) => { @@ -96,7 +95,7 @@ // }) } - - - +
+
+{% endblock %}