mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
clubs: adapt tests to new display and fix form validation issue for start_date
This commit is contained in:
parent
3eb3565a63
commit
68f61a432a
@ -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>
|
||||
|
@ -51,7 +51,7 @@ class ClubTest(TestCase):
|
||||
)
|
||||
self.assertTrue(response.status_code == 200)
|
||||
self.assertTrue(
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
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</a></td>\\n <td>Responsable info</td>" in content
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
in content
|
||||
)
|
||||
self.assertTrue(
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
in content
|
||||
)
|
||||
|
||||
@ -90,7 +91,7 @@ class ClubTest(TestCase):
|
||||
reverse("club:club_members", kwargs={"club_id": self.bdf.id})
|
||||
)
|
||||
self.assertFalse(
|
||||
"Guy Carlier</a></td>\\n <td>Responsable info</td>"
|
||||
"Guy Carlier</a></td>\\n <td>Responsable info</td>"
|
||||
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</a></td>\\n <td>Responsable info</td>"
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
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</a></td>\\n <td>Vice-Pr\\xc3\\xa9sident</td>"""
|
||||
"""Richard Batsbak</a></td>\\n <td>Vice-Pr\\xc3\\xa9sident</td>"""
|
||||
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</a></td>\\n <td>Responsable info</td>"
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
in content
|
||||
)
|
||||
self.assertTrue(
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>" in content
|
||||
"S' 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
|
||||
@ -234,7 +236,7 @@ class ClubTest(TestCase):
|
||||
{"users_old": self.rbatsbak.id},
|
||||
)
|
||||
self.assertFalse(
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
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</a></td>\\n <td>Responsable info</td>"
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
in content
|
||||
)
|
||||
self.assertFalse(
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>" in content
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
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</a></td>\\n <td>Responsable info</td>"
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
in content
|
||||
)
|
||||
self.assertFalse(
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>" in content
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
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</a></td>\\n <td>Responsable info</td>"
|
||||
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||
in content
|
||||
)
|
||||
self.assertFalse(
|
||||
"S' Kia</a></td>\\n <td>Curieux</td>" in content
|
||||
"S' Kia</a></td>\\n <td>Curieux</td>" 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</a></td>\\n <td>Responsable info</td>"
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
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</a></td>\\n <td>Curieux</td>" in content
|
||||
"Richard Batsbak</a></td>\\n <td>Curieux</td>" in content
|
||||
)
|
||||
self.assertTrue(
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>" in content
|
||||
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||
in content
|
||||
)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user