diff --git a/club/templates/club/club_members.jinja b/club/templates/club/club_members.jinja index d950c8b6..22f609f8 100644 --- a/club/templates/club/club_members.jinja +++ b/club/templates/club/club_members.jinja @@ -47,6 +47,7 @@
{% csrf_token %} + {{ form.non_field_errors() }}

{{ form.users.errors }} @@ -58,6 +59,13 @@ {{ form.role }}

+ {% if form.start_date %} +

+ {{ form.start_date.errors }} + + {{ form.start_date }} +

+ {% endif %}

{{ form.description.errors }} diff --git a/club/tests.py b/club/tests.py index 1a99ed52..25f6e019 100644 --- a/club/tests.py +++ b/club/tests.py @@ -51,7 +51,7 @@ class ClubTest(TestCase): ) self.assertTrue(response.status_code == 200) self.assertTrue( - "S' Kia\\n Responsable info" + "S' Kia\\n Responsable info" in str(response.content) ) @@ -71,10 +71,11 @@ class ClubTest(TestCase): self.assertTrue(response.status_code == 200) content = str(response.content) self.assertTrue( - "S' Kia\\n Responsable info" in content + "S' Kia\\n Responsable info" + in content ) self.assertTrue( - "Richard Batsbak\\n Responsable info" + "Richard Batsbak\\n Responsable info" in content ) @@ -90,7 +91,7 @@ class ClubTest(TestCase): reverse("club:club_members", kwargs={"club_id": self.bdf.id}) ) self.assertFalse( - "Guy Carlier\\n Responsable info" + "Guy Carlier\\n Responsable info" in str(response.content) ) @@ -104,7 +105,7 @@ class ClubTest(TestCase): reverse("club:club_members", kwargs={"club_id": self.bdf.id}) ) self.assertTrue( - "S' Kia\\n Responsable info" + "S' Kia\\n Responsable info" in str(response.content) ) response = self.client.post( @@ -157,7 +158,7 @@ class ClubTest(TestCase): ) self.assertTrue(response.status_code == 200) self.assertTrue( - """Richard Batsbak\\n Vice-Pr\\xc3\\xa9sident""" + """Richard Batsbak\\n Vice-Pr\\xc3\\xa9sident""" in str(response.content) ) @@ -211,11 +212,12 @@ class ClubTest(TestCase): self.assertTrue(response.status_code == 200) content = str(response.content) self.assertFalse( - "Richard Batsbak\\n Responsable info" + "Richard Batsbak\\n Responsable info" in content ) self.assertTrue( - "S' Kia\\n Responsable info" in content + "S' Kia\\n Responsable info" + in content ) # Skia is board member so he should be able to mark as old even without being in the club @@ -234,7 +236,7 @@ class ClubTest(TestCase): {"users_old": self.rbatsbak.id}, ) self.assertFalse( - "Richard Batsbak\\n Responsable info" + "Richard Batsbak\\n Responsable info" in str(response.content) ) @@ -261,11 +263,12 @@ class ClubTest(TestCase): self.assertTrue(response.status_code == 200) content = str(response.content) self.assertFalse( - "Richard Batsbak\\n Responsable info" + "Richard Batsbak\\n Responsable info" in content ) self.assertFalse( - "S' Kia\\n Responsable info" in content + "S' Kia\\n Responsable info" + in content ) def test_mark_old_user_to_club_from_richard_ok(self): @@ -293,11 +296,12 @@ class ClubTest(TestCase): self.assertTrue(response.status_code == 200) content = str(response.content) self.assertTrue( - "Richard Batsbak\\n Responsable info" + "Richard Batsbak\\n Responsable info" in content ) self.assertFalse( - "S' Kia\\n Responsable info" in content + "S' Kia\\n Responsable info" + in content ) # Test with lower rights @@ -316,11 +320,11 @@ class ClubTest(TestCase): self.assertTrue(response.status_code == 200) content = str(response.content) self.assertTrue( - "Richard Batsbak\\n Responsable info" + "Richard Batsbak\\n Responsable info" in content ) self.assertFalse( - "S' Kia\\n Curieux" in content + "S' Kia\\n Curieux" in content ) def test_mark_old_user_to_club_from_richard_fail(self): @@ -343,7 +347,7 @@ class ClubTest(TestCase): ) self.assertTrue(response.status_code == 200) self.assertTrue( - "S' Kia\\n Responsable info" + "S' Kia\\n Responsable info" in str(response.content) ) @@ -363,8 +367,9 @@ class ClubTest(TestCase): self.assertTrue(response.status_code == 200) content = str(response.content) self.assertTrue( - "Richard Batsbak\\n Curieux" in content + "Richard Batsbak\\n Curieux" in content ) self.assertTrue( - "S' Kia\\n Responsable info" in content + "S' Kia\\n Responsable info" + in content ) diff --git a/club/views.py b/club/views.py index d7299208..74be7b71 100644 --- a/club/views.py +++ b/club/views.py @@ -397,6 +397,10 @@ class ClubMemberForm(forms.Form): """ cleaned_data = super(ClubMemberForm, self).clean() + if "start_date" in cleaned_data and not cleaned_data["start_date"]: + # Drop start_date if allowed to edition but not specified + cleaned_data.pop("start_date") + if not cleaned_data.get("users"): # No user to add equals no check needed return cleaned_data