diff --git a/_static/donate-with-fosspay.png b/_static/donate-with-fosspay.png new file mode 100644 index 0000000..75965ec Binary files /dev/null and b/_static/donate-with-fosspay.png differ diff --git a/fosspay/blueprints/html.py b/fosspay/blueprints/html.py index ac15f66..4037a7a 100644 --- a/fosspay/blueprints/html.py +++ b/fosspay/blueprints/html.py @@ -35,5 +35,26 @@ def setup(): @html.route("/admin") @adminrequired def admin(): - first=bool(request.args.get("first-run")) - return render_template("admin.html", first=first) + first = request.args.get("first-run") is not None + projects = Project.query.all() + return render_template("admin.html", + first=first, + projects=projects, + one_times=lambda p: sum([d.amount for d in p.donations if d.type == DonationType.one_time]), + recurring=lambda p: sum([d.amount for d in p.donations if d.type == DonationType.recurring]) + ) + +@html.route("/create-project", methods=["POST"]) +@adminrequired +def create_project(): + name = request.form.get("name") + project = Project(name) + db.add(project) + db.commit() + return redirect("/admin") + +@html.route("/logout") +@loginrequired +def logout(): + logout_user() + return redirect("/") diff --git a/templates/admin.html b/templates/admin.html index 6541cf6..8627337 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -1,5 +1,6 @@ {% extends "layout.html" %} {% block body %} +Log out

Fosspay Admin

{% if first %}
@@ -32,11 +33,24 @@ + - - + + + + + {% for project in projects %} + + + + + + + + {% endfor %} +
Project NameOne-off donationsRecurring donationsOne-timeRecurringREADME Button
{{ project.name }}${{ one_times(project) }}${{ recurring(project) }}Get Markdown
@@ -45,7 +59,7 @@
- +