diff --git a/budget/forms.py b/budget/forms.py index 7342762..36bde64 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 152ad34..b889794 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 0349fe7..e84ad97 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 0a06001..9e5ecd6 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 9509dec..715a223 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():