Browse Source

Flesh out admin some more

master
Drew DeVault 6 years ago
parent
commit
eaa42767aa
  1. BIN
      _static/donate-with-fosspay.png
  2. 25
      fosspay/blueprints/html.py
  3. 20
      templates/admin.html

BIN
_static/donate-with-fosspay.png

After

Width: 141  |  Height: 20  |  Size: 3.2 KiB

25
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("/")

20
templates/admin.html

@ -1,5 +1,6 @@
{% extends "layout.html" %}
{% block body %}
<a href="/logout" class="pull-right">Log out</a>
<h1>Fosspay Admin</h1>
{% if first %}
<div class="well">
@ -32,11 +33,24 @@
<table class="table">
<thead>
<tr>
<th style="width: 10%"></th>
<th>Project Name</th>
<th>One-off donations</th>
<th>Recurring donations</th>
<th>One-time</th>
<th>Recurring</th>
<th>README Button</th>
</tr>
</thead>
<tbody>
{% for project in projects %}
<tr>
<td><button type="button" class="close">&times;</button></td>
<td>{{ project.name }}</td>
<td>${{ one_times(project) }}</td>
<td>${{ recurring(project) }}</td>
<td><a href="#" class="btn btn-primary btn-sm">Get Markdown</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-6">
@ -45,7 +59,7 @@
<div class="form-group">
<input class="form-control" type="text" placeholder="Project name" name="name" />
</div>
<input type="submit" value="Add" />
<input type="submit" value="Add" class="btn btn-default pull-right" />
</form>
</div>
</div>

Loading…
Cancel
Save