Flesh out admin some more
This commit is contained in:
parent
5ed02a5fbf
commit
eaa42767aa
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
|
@ -35,5 +35,26 @@ def setup():
|
||||||
@html.route("/admin")
|
@html.route("/admin")
|
||||||
@adminrequired
|
@adminrequired
|
||||||
def admin():
|
def admin():
|
||||||
first=bool(request.args.get("first-run"))
|
first = request.args.get("first-run") is not None
|
||||||
return render_template("admin.html", first=first)
|
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("/")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
<a href="/logout" class="pull-right">Log out</a>
|
||||||
<h1>Fosspay Admin</h1>
|
<h1>Fosspay Admin</h1>
|
||||||
{% if first %}
|
{% if first %}
|
||||||
<div class="well">
|
<div class="well">
|
||||||
|
@ -32,11 +33,24 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="width: 10%"></th>
|
||||||
<th>Project Name</th>
|
<th>Project Name</th>
|
||||||
<th>One-off donations</th>
|
<th>One-time</th>
|
||||||
<th>Recurring donations</th>
|
<th>Recurring</th>
|
||||||
|
<th>README Button</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for project in projects %}
|
||||||
|
<tr>
|
||||||
|
<td><button type="button" class="close">×</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>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
@ -45,7 +59,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input class="form-control" type="text" placeholder="Project name" name="name" />
|
<input class="form-control" type="text" placeholder="Project name" name="name" />
|
||||||
</div>
|
</div>
|
||||||
<input type="submit" value="Add" />
|
<input type="submit" value="Add" class="btn btn-default pull-right" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue