From f3972db96a718413b66efba1e4a0d0339222d83d Mon Sep 17 00:00:00 2001 From: Arnaud Bos Date: Wed, 2 Nov 2011 12:16:01 +0100 Subject: [PATCH 1/3] Add a way to delete a project. Fix #63 --- budget/forms.py | 1 - budget/models.py | 4 ++++ budget/templates/edit_project.html | 7 +++++++ budget/templates/forms.html | 5 ++++- budget/web.py | 5 +++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/budget/forms.py b/budget/forms.py index 73427623..36bde643 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -51,7 +51,6 @@ class EditProjectForm(Form): name = TextField(_("Project name"), validators=[Required()]) password = TextField(_("Private code"), validators=[Required()]) contact_email = TextField(_("Email"), validators=[Required(), Email()]) - submit = SubmitField(_("Edit the project")) def save(self): """Create a new project with the information given by this form. diff --git a/budget/models.py b/budget/models.py index 152ad341..b8897946 100644 --- a/budget/models.py +++ b/budget/models.py @@ -70,6 +70,10 @@ class Project(db.Model): db.session.commit() return person + def remove_project(self): + db.session.delete(self) + db.session.commit() + def __repr__(self): return "" % self.name diff --git a/budget/templates/edit_project.html b/budget/templates/edit_project.html index 0349fe74..e84ad97c 100644 --- a/budget/templates/edit_project.html +++ b/budget/templates/edit_project.html @@ -1,5 +1,12 @@ {% extends "layout.html" %} +{% block js %} + $('#delete-project').click(function () + { + $(this).html("{{_("you sure?")}}"); + }); +{% endblock %} + {% block content %}

{{ _("Edit this project") }}

diff --git a/budget/templates/forms.html b/budget/templates/forms.html index 0a06001d..9e5ecd65 100644 --- a/budget/templates/forms.html +++ b/budget/templates/forms.html @@ -65,7 +65,10 @@ {{ input(form.name) }} {{ input(form.password) }} {{ input(form.contact_email) }} - {{ submit(form.submit) }} +
+ + {{ _("delete") }} +
{% endmacro %} diff --git a/budget/web.py b/budget/web.py index 9509dec4..715a2239 100644 --- a/budget/web.py +++ b/budget/web.py @@ -185,6 +185,11 @@ def edit_project(): return render_template("edit_project.html", form=form) +@main.route("//delete", methods=["GET"]) +def remove_project(): + g.project.remove_project() + + return redirect(url_for(".home")) @main.route("/exit") def exit(): From ac2935b429358440fc911a80d10f0afda583d679 Mon Sep 17 00:00:00 2001 From: Arnaud Bos Date: Wed, 2 Nov 2011 13:20:00 +0100 Subject: [PATCH 2/3] Ease "Add a bill" form occurrence with slideUp/slideDown effects. Related to #53. --- budget/templates/list_bills.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index 18b3637b..d9bbd663 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -16,15 +16,17 @@ // display the form when clicking on the "add bill" button var show_form = function(){ - $('#bill-form').show(70); + $('#bill-form').slideDown(1000); + $("#hide-bill-form").show(); $("#new-bill").hide(); return false; } // and provide a mechanism to hide it back var hide_form = function(){ - $("#bill-form").hide(70); + $("#bill-form").slideUp(1000); $("#new-bill").show(); + $("#hide-bill-form").hide(); return false; } @@ -138,7 +140,7 @@ {{ _("Add a new bill") }} - {{ _("hide this form") }} + {{ _("hide this form") }} {{ forms.add_bill(bill_form) }} From 0fe49c13d5512a2a172c47f3497c0442d909a040 Mon Sep 17 00:00:00 2001 From: Arnaud Bos Date: Wed, 2 Nov 2011 13:44:55 +0100 Subject: [PATCH 3/3] See #54. Move the flashing message to absolute positionning to avoid annoying shifting of the bills list. --- budget/templates/layout.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/budget/templates/layout.html b/budget/templates/layout.html index c8f8df84..6ac0a3a6 100644 --- a/budget/templates/layout.html +++ b/budget/templates/layout.html @@ -9,6 +9,8 @@ {% block head %}{% endblock %}