Skip to content
Snippets Groups Projects
Commit 88eae95f authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Mostly changes to admin_topic_show

parent ff9627d0
No related branches found
No related tags found
No related merge requests found
......@@ -148,3 +148,8 @@ class Statement(db.Model):
self.execution_time = datetime.now()
return True
def undo(self):
if not self.executed:
return False
self.executed = False
self.execution_time = datetime(1970, 1, 1)
......@@ -189,7 +189,7 @@ def topic_edit():
if form.validate_on_submit():
form.populate_obj(topic)
db.session.commit()
return redirect(url_for(".index"))
return redirect(url_for(".topic_show", id=topic.id))
else:
return render_layout("admin_topic_edit.html", form=form, id=topic_id)
else:
......@@ -256,3 +256,11 @@ def statement_delete():
return redirect(url_for(".topic_show", id=topic_id))
return redirect(url_for(".index"))
@admin.route("/statement/undo")
@login_required
@admin_permission.require()
def statement_undo():
statement = Statement.query.filter_by(executed=True).order_by(db.desc(Statement.execution_time)).first()
statement.undo()
db.session.commit()
return redirect(url_for(".topic_show", id=statement.topic.id))
......@@ -35,5 +35,12 @@
</tbody>
</table>
</div>
{{ render_form(form, action_url=url_for(".statement_new"), action_text="Add", title="Add Statement", class_="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--3-col mdl-cell-3-col-tablet mdl-cell--4-col-phone") }}
<div class="mdl-cell mdl-cell--3-col mdl-cell--3-col-tablet mdl-cell--4-col-phone mdl-grid mdl-grid--no-spacing">
{{ render_form(form, action_url=url_for(".statement_new"), action_text="Add", title="Add Statement", class_="mdl-card mdl-shadow--2dp mdl-cell mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone") }}
<div class="mdl-cell mdl-card mdl-shadow--2dp mdl-cell--12-col mdl-cell--8-col-tablet mdl-cell--4-col-phone">
<ul class="mdl-menu">
<li class="mdl-menu__item"><a class="mdl-navigation__link" href="{{ url_for(".statement_undo") }}"><i class="material-icons" role="presentation">undo</i>Undo</a></li>
</ul>
</div>
</div>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment