Update bulk mailer tool
Use new admin site theme, allow for tinyMCE api key to be input to config.py
This commit is contained in:
parent
f1640493ec
commit
24384b2a35
2 changed files with 21 additions and 20 deletions
|
@ -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_login import current_user, login_required
|
||||||
from flask_mail import Message
|
from flask_mail import Message
|
||||||
|
|
||||||
|
@ -62,8 +62,10 @@ def mail():
|
||||||
return redirect(url_for("dashboard.home"))
|
return redirect(url_for("dashboard.home"))
|
||||||
|
|
||||||
total_count = len(db.session.execute(db.select(User)).scalars().all())
|
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")
|
@bp.route("/users")
|
||||||
@login_required
|
@login_required
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
<!DOCTYPE html>
|
{% extends 'admin-layout.html' %}
|
||||||
<html lang="en">
|
|
||||||
<head>
|
{% block head %}
|
||||||
<title>🍪CookieMailer</title>
|
{{super()}}
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
<meta name="description" content="" />
|
<meta name="description" content="" />
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
|
||||||
<meta name="theme-color" content="">
|
<meta name="theme-color" content="">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/mail.css" />
|
|
||||||
<script src="https://cdn.tiny.cloud/1/{{MCE_API_KEY}}/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script></head>
|
<script src="https://cdn.tiny.cloud/1/{{MCE_API_KEY}}/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script></head>
|
||||||
<body>
|
{% endblock %}
|
||||||
<div id="loader"></div>
|
{% block app_content %}
|
||||||
<div class="container">
|
<div class="card">
|
||||||
<div class="row">
|
<div class="card-body">
|
||||||
<div id="root" class="col">
|
<h1 class="h3 mb-3 fw-normal">🍪CookieMailer</h1>
|
||||||
<h2>🍪CookieMailer</h2>
|
|
||||||
<label for="recipients">To: </label>
|
<label for="recipients">To: </label>
|
||||||
<br/>
|
<br/>
|
||||||
<select id="recipients" name="recipients">
|
<select class="form-control" id="recipients" name="recipients">
|
||||||
<option value="admin">Test Email (SysAdmin)</option>
|
<option value="admin">Test Email (SysAdmin)</option>
|
||||||
<option value="org">Test Email (Organizers)</option>
|
<option value="org">Test Email (Organizers)</option>
|
||||||
<!-- <option value="wpi">WPI Only</option> -->
|
<!-- <option value="wpi">WPI Only</option> -->
|
||||||
|
@ -26,7 +23,8 @@
|
||||||
<br/>
|
<br/>
|
||||||
<label for="subject">Subject: </label>
|
<label for="subject">Subject: </label>
|
||||||
<br/>
|
<br/>
|
||||||
<input id="subject" name="subject" width="100%" type="text" value="Hack@WPI" />
|
<input class="form-control" id="subject" name="subject" width="100%"
|
||||||
|
type="text" value="GoatHacks -- " />
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<textarea id="content" name="content">
|
<textarea id="content" name="content">
|
||||||
|
@ -40,7 +38,7 @@
|
||||||
</textarea>
|
</textarea>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="button" onClick="send()" value="Send"/>
|
<input class="btn btn-primary" type="button" onClick="send()" value="Send"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,6 +75,7 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
if((rec != "all" && window.confirm("Send test email?")) || (rec == "all" && window.confirm("Send email to {{NUM_HACKERS}} recipients?"))) {
|
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) => {
|
fetch('/admin/send', {method: 'POST', body: JSON.stringify(body), headers: headers}).then(async (res) => {
|
||||||
window.alert(await res.text());
|
window.alert(await res.text());
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
@ -96,7 +95,7 @@
|
||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</div>
|
||||||
|
</div>
|
||||||
</html>
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue