clubs: adapt tests to new display and fix form validation issue for start_date

This commit is contained in:
Antoine Bartuccio 2019-04-25 17:31:42 +02:00
parent 3eb3565a63
commit 68f61a432a
Signed by: klmp200
GPG Key ID: E7245548C53F904B
3 changed files with 35 additions and 18 deletions

View File

@ -47,6 +47,7 @@
</form>
<form action="{{ url('club:club_members', club_id=club.id) }}" id="add_users" method="post">
{% csrf_token %}
{{ form.non_field_errors() }}
<p>
{{ form.users.errors }}
<label for="{{ form.users.id_for_label }}">{{ form.users.label }} :</label>
@ -58,6 +59,13 @@
<label for="{{ form.role.id_for_label }}">{{ form.role.label }} :</label>
{{ form.role }}
</p>
{% if form.start_date %}
<p>
{{ form.start_date.errors }}
<label for="{{ form.start_date.id_for_label }}">{{ form.start_date.label }} :</label>
{{ form.start_date }}
</p>
{% endif %}
<p>
{{ form.description.errors }}
<label for="{{ form.description.id_for_label }}">{{ form.description.label }} :</label>

View File

@ -71,7 +71,8 @@ class ClubTest(TestCase):
self.assertTrue(response.status_code == 200)
content = str(response.content)
self.assertTrue(
"S&#39; Kia</a></td>\\n <td>Responsable info</td>" in content
"S&#39; Kia</a></td>\\n <td>Responsable info</td>"
in content
)
self.assertTrue(
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
@ -215,7 +216,8 @@ class ClubTest(TestCase):
in content
)
self.assertTrue(
"S&#39; Kia</a></td>\\n <td>Responsable info</td>" in content
"S&#39; Kia</a></td>\\n <td>Responsable info</td>"
in content
)
# Skia is board member so he should be able to mark as old even without being in the club
@ -265,7 +267,8 @@ class ClubTest(TestCase):
in content
)
self.assertFalse(
"S&#39; Kia</a></td>\\n <td>Responsable info</td>" in content
"S&#39; Kia</a></td>\\n <td>Responsable info</td>"
in content
)
def test_mark_old_user_to_club_from_richard_ok(self):
@ -297,7 +300,8 @@ class ClubTest(TestCase):
in content
)
self.assertFalse(
"S&#39; Kia</a></td>\\n <td>Responsable info</td>" in content
"S&#39; Kia</a></td>\\n <td>Responsable info</td>"
in content
)
# Test with lower rights
@ -366,5 +370,6 @@ class ClubTest(TestCase):
"Richard Batsbak</a></td>\\n <td>Curieux</td>" in content
)
self.assertTrue(
"S&#39; Kia</a></td>\\n <td>Responsable info</td>" in content
"S&#39; Kia</a></td>\\n <td>Responsable info</td>"
in content
)

View File

@ -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