1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge pull request #74 from fredericsureau/master

Fix bug #21
This commit is contained in:
fredericsureau 2012-01-27 16:37:45 -08:00
commit adfa5f9263
4 changed files with 30 additions and 11 deletions

View file

@ -182,17 +182,22 @@ tr.payer_line .balance-name{
opacity: 0.6; opacity: 0.6;
text-align: center; text-align: center;
} }
.action a, .action a:hover { .action form {
height: 16px; margin: 0;
padding-left: 20px; padding: 0;
}
.action button, .action button:hover {
width: auto;
margin: 0;
padding: 0 0 0 20px;
} }
.delete a, .delete a:hover { .delete button, .delete button:hover {
background: url('images/deleter.png') left no-repeat; background: url('images/deleter.png') left no-repeat;
color: red; color: red;
} }
.reactivate a, .reactivate a:hover { .reactivate button, .reactivate button:hover {
background: url('images/reactivate.png') left no-repeat; background: url('images/reactivate.png') left no-repeat;
color: white; color: white;
} }

View file

@ -27,7 +27,7 @@
// ask for confirmation before removing an user // ask for confirmation before removing an user
$('.action').each(function(){ $('.action').each(function(){
$(this).hide(); $(this).hide();
var link = $(this).find('a'); var link = $(this).find('button');
link.click(function(){ link.click(function(){
if ($(this).hasClass("confirm")){ if ($(this).hasClass("confirm")){
return true; return true;
@ -83,9 +83,13 @@
{% if balance[member.id] > 0 %}+{% endif %}{{ balance[member.id] }} {% if balance[member.id] > 0 %}+{% endif %}{{ balance[member.id] }}
</td> </td>
{% if member.activated %} {% if member.activated %}
<td class="action delete"> <a href="{{ url_for(".remove_member", member_id=member.id) }}">{{ _("delete") }}</a></td> <td class="action delete">
<form action="{{ url_for(".remove_member", member_id=member.id) }}" method="POST">
<button type="submit">{{ _("delete") }}</button></form></td>
{% else %} {% else %}
<td class="action reactivate"> <a href="{{ url_for(".reactivate", member_id=member.id) }}">{{ _("reactivate") }}</a></td> <td class="action reactivate">
<form action="{{ url_for(".reactivate", member_id=member.id) }}" method="POST">
<button type="submit">{{ _("reactivate") }}</button></form></td>
{% endif %} {% endif %}
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -214,6 +214,16 @@ class BudgetTestCase(TestCase):
self.assertEqual( self.assertEqual(
len(models.Project.query.get("randomid").active_members), 1) len(models.Project.query.get("randomid").active_members), 1)
def test_member_delete_method(self):
self.post_project("raclette")
self.login("raclette")
# adds a member to this project
self.app.post("/raclette/members/add", data={'name': 'alexis' })
# try to remove the member using GET method
response = self.app.get("/raclette/members/1/delete")
self.assertEqual(response.status_code, 405)
def test_demo(self): def test_demo(self):
# Test that it is possible to connect automatically by going onto /demo # Test that it is possible to connect automatically by going onto /demo

View file

@ -185,7 +185,7 @@ 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"]) @main.route("/<project_id>/delete", methods=["POST"])
def remove_project(): def remove_project():
g.project.remove_project() g.project.remove_project()
@ -265,7 +265,7 @@ def add_member():
return render_template("add_member.html", form=form) return render_template("add_member.html", form=form)
@main.route("/<project_id>/members/<member_id>/reactivate", methods=["GET",]) @main.route("/<project_id>/members/<member_id>/reactivate", methods=["POST"])
def reactivate(member_id): def reactivate(member_id):
person = Person.query.filter(Person.id == member_id)\ person = Person.query.filter(Person.id == member_id)\
.filter(Project.id == g.project.id).all() .filter(Project.id == g.project.id).all()
@ -276,7 +276,7 @@ def reactivate(member_id):
return redirect(url_for(".list_bills")) return redirect(url_for(".list_bills"))
@main.route("/<project_id>/members/<member_id>/delete", methods=["GET", "POST"]) @main.route("/<project_id>/members/<member_id>/delete", methods=["POST"])
def remove_member(member_id): def remove_member(member_id):
member = g.project.remove_member(member_id) member = g.project.remove_member(member_id)
if member.activated == False: if member.activated == False: