diff --git a/budget/templates/edit_project.html b/budget/templates/edit_project.html index 585d231..0240eff 100644 --- a/budget/templates/edit_project.html +++ b/budget/templates/edit_project.html @@ -3,7 +3,7 @@ {% block js %} $('#delete-project').click(function () { - $(this).html("{{_("you sure?")}}"); + $(this).html("{{_("you sure?")}}"); }); {% endblock %} diff --git a/budget/tests.py b/budget/tests.py index cbcefec..d127b06 100644 --- a/budget/tests.py +++ b/budget/tests.py @@ -147,6 +147,24 @@ class BudgetTestCase(TestCase): # no new project added self.assertEqual(len(models.Project.query.all()), 1) + def test_project_deletion(self): + + with run.app.test_client() as c: + c.post("/create", data={ + 'name': 'raclette party', + 'id': 'raclette', + 'password': 'party', + 'contact_email': 'raclette@notmyidea.org' + }) + + # project added + self.assertEqual(len(models.Project.query.all()), 1) + + c.get('/raclette/delete') + + # project removed + self.assertEqual(len(models.Project.query.all()), 0) + def test_membership(self): self.post_project("raclette") self.login("raclette") diff --git a/budget/web.py b/budget/web.py index 6097d80..489874c 100644 --- a/budget/web.py +++ b/budget/web.py @@ -205,9 +205,10 @@ def edit_project(): return render_template("edit_project.html", form=form) -@main.route("//delete", methods=["POST"]) -def remove_project(): +@main.route("//delete") +def delete_project(): g.project.remove_project() + flash(_('Project successfully deleted')) return redirect(url_for(".home"))