admin: Cleanup status messages

refucktor
informatic 2018-03-13 08:10:01 +01:00
parent 8738708eb2
commit 2650349785
2 changed files with 17 additions and 9 deletions

View File

@ -193,10 +193,13 @@ def match_manual():
def match(username, uid, months):
member = models.Member.query.filter_by(username=username).first()
if not member:
return "no member"
flash('No member found', 'danger')
return redirect(url_for(".match_manual"))
transfer = models.Transfer.query.filter_by(uid=uid).first()
if not transfer:
return "no transfer"
flash('No transfer found', 'danger')
return redirect(url_for(".match_manual"))
for _ in range(months):
year, month = member.get_next_unpaid()
@ -206,7 +209,9 @@ def match(username, uid, months):
db.session.commit()
member.get_status(force_refresh=True)
return "ok, %i PLN get!" % transfer.amount
flash('OK, %d get' % transfer.amount)
return redirect(url_for(".match_manual"))
@bp.route("/admin/match/", methods=["POST"])
@ -217,10 +222,13 @@ def match_user_transfer():
uid = request.form["uid"]
member = models.Member.query.filter_by(username=username).first()
if not member:
return "no such member! :("
flash('No member found', 'danger')
return redirect(url_for(".match_manual"))
transfer = models.Transfer.query.filter_by(uid=uid).first()
if not transfer:
return "no transfer"
flash('No transfer found', 'danger')
return redirect(url_for(".match_manual"))
return render_template("match_user_transfer.html", member=member, transfer=transfer)

View File

@ -63,11 +63,11 @@
</div>
</nav>
{% with messages = get_flashed_messages() %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<div class="flashes">
{% for message in messages %}
<div class="alert alert-info alert-dismissible" role="alert">
{% for category, message in messages %}
<div class="alert alert-{{ 'info' if category == 'message' else category }} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{{message}}
</div>
@ -76,7 +76,7 @@
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
{% block content %}{% endblock %}
<!-- Bootstrap core JavaScript
================================================== -->