mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Fix project deletion. fix #87
This commit is contained in:
parent
e75809dddf
commit
6a544855d7
3 changed files with 22 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
|||
{% block js %}
|
||||
$('#delete-project').click(function ()
|
||||
{
|
||||
$(this).html("<a style='color:red; ' href='{{ url_for('.remove_project') }}' >{{_("you sure?")}}</a>");
|
||||
$(this).html("<a style='color:red; ' href='{{ url_for('.delete_project') }}' >{{_("you sure?")}}</a>");
|
||||
});
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -205,9 +205,10 @@ def edit_project():
|
|||
return render_template("edit_project.html", form=form)
|
||||
|
||||
|
||||
@main.route("/<project_id>/delete", methods=["POST"])
|
||||
def remove_project():
|
||||
@main.route("/<project_id>/delete")
|
||||
def delete_project():
|
||||
g.project.remove_project()
|
||||
flash(_('Project successfully deleted'))
|
||||
|
||||
return redirect(url_for(".home"))
|
||||
|
||||
|
|
Loading…
Reference in a new issue