mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Add a way to delete a project. Fix #63
This commit is contained in:
parent
655774e4d4
commit
f3972db96a
5 changed files with 20 additions and 2 deletions
|
@ -51,7 +51,6 @@ class EditProjectForm(Form):
|
||||||
name = TextField(_("Project name"), validators=[Required()])
|
name = TextField(_("Project name"), validators=[Required()])
|
||||||
password = TextField(_("Private code"), validators=[Required()])
|
password = TextField(_("Private code"), validators=[Required()])
|
||||||
contact_email = TextField(_("Email"), validators=[Required(), Email()])
|
contact_email = TextField(_("Email"), validators=[Required(), Email()])
|
||||||
submit = SubmitField(_("Edit the project"))
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Create a new project with the information given by this form.
|
"""Create a new project with the information given by this form.
|
||||||
|
|
|
@ -70,6 +70,10 @@ class Project(db.Model):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return person
|
return person
|
||||||
|
|
||||||
|
def remove_project(self):
|
||||||
|
db.session.delete(self)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Project %s>" % self.name
|
return "<Project %s>" % self.name
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
$('#delete-project').click(function ()
|
||||||
|
{
|
||||||
|
$(this).html("<a style='color:red; ' href='{{ url_for('.remove_project') }}' >{{_("you sure?")}}</a>");
|
||||||
|
});
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2>{{ _("Edit this project") }}</h2>
|
<h2>{{ _("Edit this project") }}</h2>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
|
|
@ -65,7 +65,10 @@
|
||||||
{{ input(form.name) }}
|
{{ input(form.name) }}
|
||||||
{{ input(form.password) }}
|
{{ input(form.password) }}
|
||||||
{{ input(form.contact_email) }}
|
{{ input(form.contact_email) }}
|
||||||
{{ submit(form.submit) }}
|
<div class="actions">
|
||||||
|
<button class="btn primary">{{ _("Edit the project") }}</button>
|
||||||
|
<a id="delete-project" style="color:red; margin-left:10px; cursor:pointer; ">{{ _("delete") }}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,11 @@ def edit_project():
|
||||||
|
|
||||||
return render_template("edit_project.html", form=form)
|
return render_template("edit_project.html", form=form)
|
||||||
|
|
||||||
|
@main.route("/<project_id>/delete", methods=["GET"])
|
||||||
|
def remove_project():
|
||||||
|
g.project.remove_project()
|
||||||
|
|
||||||
|
return redirect(url_for(".home"))
|
||||||
|
|
||||||
@main.route("/exit")
|
@main.route("/exit")
|
||||||
def exit():
|
def exit():
|
||||||
|
|
Loading…
Reference in a new issue