mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 02:24:26 +00:00
clubs: fix membership form and add bulk mark as old tests
This commit is contained in:
parent
6964692556
commit
75328de5ca
191
club/tests.py
191
club/tests.py
@ -177,3 +177,194 @@ class ClubTest(TestCase):
|
|||||||
"<li>Vous n'avez pas la permission de faire cela</li>"
|
"<li>Vous n'avez pas la permission de faire cela</li>"
|
||||||
in str(response.content)
|
in str(response.content)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_role_required_if_users_specified(self):
|
||||||
|
self.client.login(username="root", password="plop")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users": self.rbatsbak.id, "start_date": "12/06/2016"},
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
'<ul class="errorlist"><li>Vous devez choisir un r' in str(response.content)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_mark_old_user_to_club_from_skia_ok(self):
|
||||||
|
self.client.login(username="root", password="plop")
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{
|
||||||
|
"users": "|%d|%d|" % (self.skia.id, self.rbatsbak.id),
|
||||||
|
"start_date": "12/06/2016",
|
||||||
|
"role": 3,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.client.login(username="skia", password="plop")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": self.rbatsbak.id},
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 302)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id})
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 200)
|
||||||
|
content = str(response.content)
|
||||||
|
self.assertFalse(
|
||||||
|
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||||
|
in content
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
"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
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": self.skia.id},
|
||||||
|
)
|
||||||
|
self.client.login(username="root", password="plop")
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users": self.rbatsbak.id, "start_date": "12/06/2016", "role": 3},
|
||||||
|
)
|
||||||
|
self.client.login(username="skia", password="plop")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": self.rbatsbak.id},
|
||||||
|
)
|
||||||
|
self.assertFalse(
|
||||||
|
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||||
|
in str(response.content)
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_mark_old_multiple_users_from_skia_ok(self):
|
||||||
|
self.client.login(username="root", password="plop")
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{
|
||||||
|
"users": "|%d|%d|" % (self.skia.id, self.rbatsbak.id),
|
||||||
|
"start_date": "12/06/2016",
|
||||||
|
"role": 3,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
self.client.login(username="skia", password="plop")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": [self.rbatsbak.id, self.skia.id]},
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 302)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id})
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 200)
|
||||||
|
content = str(response.content)
|
||||||
|
self.assertFalse(
|
||||||
|
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||||
|
in content
|
||||||
|
)
|
||||||
|
self.assertFalse(
|
||||||
|
"S' Kia</a></td>\\n <td>Responsable info</td>" in content
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_mark_old_user_to_club_from_richard_ok(self):
|
||||||
|
self.client.login(username="root", password="plop")
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{
|
||||||
|
"users": "|%d|%d|" % (self.skia.id, self.rbatsbak.id),
|
||||||
|
"start_date": "12/06/2016",
|
||||||
|
"role": 3,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test with equal rights
|
||||||
|
self.client.login(username="rbatsbak", password="plop")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": self.skia.id},
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 302)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id})
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 200)
|
||||||
|
content = str(response.content)
|
||||||
|
self.assertTrue(
|
||||||
|
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||||
|
in content
|
||||||
|
)
|
||||||
|
self.assertFalse(
|
||||||
|
"S' Kia</a></td>\\n <td>Responsable info</td>" in content
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test with lower rights
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users": self.skia.id, "start_date": "12/06/2016", "role": 0},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": self.skia.id},
|
||||||
|
)
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id})
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 200)
|
||||||
|
content = str(response.content)
|
||||||
|
self.assertTrue(
|
||||||
|
"Richard Batsbak</a></td>\\n <td>Responsable info</td>"
|
||||||
|
in content
|
||||||
|
)
|
||||||
|
self.assertFalse(
|
||||||
|
"S' Kia</a></td>\\n <td>Curieux</td>" in content
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_mark_old_user_to_club_from_richard_fail(self):
|
||||||
|
self.client.login(username="root", password="plop")
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users": self.skia.id, "start_date": "12/06/2016", "role": 3},
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test with richard outside of the club
|
||||||
|
self.client.login(username="rbatsbak", password="plop")
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": self.skia.id},
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 200)
|
||||||
|
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id})
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 200)
|
||||||
|
self.assertTrue(
|
||||||
|
"S' Kia</a></td>\\n <td>Responsable info</td>"
|
||||||
|
in str(response.content)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test with lower rights
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users": self.rbatsbak.id, "start_date": "12/06/2016", "role": 0},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.client.post(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id}),
|
||||||
|
{"users_old": self.skia.id},
|
||||||
|
)
|
||||||
|
response = self.client.get(
|
||||||
|
reverse("club:club_members", kwargs={"club_id": self.bdf.id})
|
||||||
|
)
|
||||||
|
self.assertTrue(response.status_code == 200)
|
||||||
|
content = str(response.content)
|
||||||
|
self.assertTrue(
|
||||||
|
"Richard Batsbak</a></td>\\n <td>Curieux</td>" in content
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
"S' Kia</a></td>\\n <td>Responsable info</td>" in content
|
||||||
|
)
|
||||||
|
@ -342,6 +342,14 @@ class ClubMemberForm(forms.Form):
|
|||||||
widgets={"start_date": SelectDate},
|
widgets={"start_date": SelectDate},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Role is required only if users is specified
|
||||||
|
self.fields["role"].required = False
|
||||||
|
|
||||||
|
# Start date and description are never really required
|
||||||
|
self.fields["start_date"].required = False
|
||||||
|
self.fields["description"].required = False
|
||||||
|
|
||||||
self.fields["users_old"] = forms.ModelMultipleChoiceField(
|
self.fields["users_old"] = forms.ModelMultipleChoiceField(
|
||||||
User.objects.filter(
|
User.objects.filter(
|
||||||
id__in=[
|
id__in=[
|
||||||
@ -385,9 +393,19 @@ class ClubMemberForm(forms.Form):
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
"""
|
"""
|
||||||
Check user rights
|
Check user rights for adding an user
|
||||||
"""
|
"""
|
||||||
cleaned_data = super(ClubMemberForm, self).clean()
|
cleaned_data = super(ClubMemberForm, self).clean()
|
||||||
|
|
||||||
|
if not cleaned_data.get("users"):
|
||||||
|
# No user to add equals no check needed
|
||||||
|
return cleaned_data
|
||||||
|
|
||||||
|
if cleaned_data.get("role", "") == "":
|
||||||
|
# Role is required if users exists
|
||||||
|
self.add_error("role", _("You should specify a role"))
|
||||||
|
return cleaned_data
|
||||||
|
|
||||||
request_user = self.request_user
|
request_user = self.request_user
|
||||||
membership = self.request_user_membership
|
membership = self.request_user_membership
|
||||||
if not (
|
if not (
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2019-04-24 03:06+0200\n"
|
"POT-Creation-Date: 2019-04-25 14:45+0200\n"
|
||||||
"PO-Revision-Date: 2016-07-18\n"
|
"PO-Revision-Date: 2016-07-18\n"
|
||||||
"Last-Translator: Skia <skia@libskia.so>\n"
|
"Last-Translator: Skia <skia@libskia.so>\n"
|
||||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||||
@ -174,7 +174,7 @@ msgstr "étiquette"
|
|||||||
msgid "target type"
|
msgid "target type"
|
||||||
msgstr "type de cible"
|
msgstr "type de cible"
|
||||||
|
|
||||||
#: accounting/models.py:313 club/models.py:422
|
#: accounting/models.py:313 club/models.py:413
|
||||||
#: club/templates/club/club_members.jinja:8
|
#: club/templates/club/club_members.jinja:8
|
||||||
#: club/templates/club/club_old_members.jinja:8
|
#: club/templates/club/club_old_members.jinja:8
|
||||||
#: club/templates/club/mailing.jinja:28 club/views.py:112
|
#: club/templates/club/mailing.jinja:28 club/views.py:112
|
||||||
@ -186,7 +186,7 @@ msgstr "type de cible"
|
|||||||
msgid "User"
|
msgid "User"
|
||||||
msgstr "Utilisateur"
|
msgstr "Utilisateur"
|
||||||
|
|
||||||
#: accounting/models.py:314 club/models.py:329
|
#: accounting/models.py:314 club/models.py:320
|
||||||
#: club/templates/club/club_detail.jinja:12
|
#: club/templates/club/club_detail.jinja:12
|
||||||
#: com/templates/com/mailing_admin.jinja:11
|
#: com/templates/com/mailing_admin.jinja:11
|
||||||
#: com/templates/com/news_admin_list.jinja:23
|
#: com/templates/com/news_admin_list.jinja:23
|
||||||
@ -955,48 +955,40 @@ msgstr "rôle"
|
|||||||
msgid "description"
|
msgid "description"
|
||||||
msgstr "description"
|
msgstr "description"
|
||||||
|
|
||||||
#: club/models.py:282
|
#: club/models.py:286
|
||||||
msgid "User must be subscriber to take part to a club"
|
|
||||||
msgstr "L'utilisateur doit être cotisant pour faire partie d'un club"
|
|
||||||
|
|
||||||
#: club/models.py:289
|
|
||||||
msgid "User is already member of that club"
|
|
||||||
msgstr "L'utilisateur est déjà membre de ce club"
|
|
||||||
|
|
||||||
#: club/models.py:298
|
|
||||||
msgid "past member"
|
msgid "past member"
|
||||||
msgstr "Anciens membres"
|
msgstr "Anciens membres"
|
||||||
|
|
||||||
#: club/models.py:332 club/models.py:427
|
#: club/models.py:323 club/models.py:418
|
||||||
msgid "Email address"
|
msgid "Email address"
|
||||||
msgstr "Adresse email"
|
msgstr "Adresse email"
|
||||||
|
|
||||||
#: club/models.py:340
|
#: club/models.py:331
|
||||||
msgid "Enter a valid address. Only the root of the address is needed."
|
msgid "Enter a valid address. Only the root of the address is needed."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Entrez une adresse valide. Seule la racine de l'adresse est nécessaire."
|
"Entrez une adresse valide. Seule la racine de l'adresse est nécessaire."
|
||||||
|
|
||||||
#: club/models.py:344 com/models.py:79 com/models.py:260 core/models.py:810
|
#: club/models.py:335 com/models.py:79 com/models.py:260 core/models.py:810
|
||||||
msgid "is moderated"
|
msgid "is moderated"
|
||||||
msgstr "est modéré"
|
msgstr "est modéré"
|
||||||
|
|
||||||
#: club/models.py:346 com/models.py:81 com/models.py:264
|
#: club/models.py:337 com/models.py:81 com/models.py:264
|
||||||
msgid "moderator"
|
msgid "moderator"
|
||||||
msgstr "modérateur"
|
msgstr "modérateur"
|
||||||
|
|
||||||
#: club/models.py:415 club/templates/club/mailing.jinja:14
|
#: club/models.py:406 club/templates/club/mailing.jinja:14
|
||||||
msgid "Mailing"
|
msgid "Mailing"
|
||||||
msgstr "Liste de diffusion"
|
msgstr "Liste de diffusion"
|
||||||
|
|
||||||
#: club/models.py:434
|
#: club/models.py:425
|
||||||
msgid "At least user or email is required"
|
msgid "At least user or email is required"
|
||||||
msgstr "Au moins un utilisateur ou un email est nécessaire"
|
msgstr "Au moins un utilisateur ou un email est nécessaire"
|
||||||
|
|
||||||
#: club/models.py:442
|
#: club/models.py:433
|
||||||
msgid "This email is already suscribed in this mailing"
|
msgid "This email is already suscribed in this mailing"
|
||||||
msgstr "Cet email est déjà abonné à cette mailing"
|
msgstr "Cet email est déjà abonné à cette mailing"
|
||||||
|
|
||||||
#: club/models.py:471 club/templates/club/mailing.jinja:36
|
#: club/models.py:462 club/templates/club/mailing.jinja:36
|
||||||
msgid "Unregistered user"
|
msgid "Unregistered user"
|
||||||
msgstr "Désabonner un utilisateur"
|
msgstr "Désabonner un utilisateur"
|
||||||
|
|
||||||
@ -1045,7 +1037,7 @@ msgstr "Description"
|
|||||||
msgid "Since"
|
msgid "Since"
|
||||||
msgstr "Depuis"
|
msgstr "Depuis"
|
||||||
|
|
||||||
#: club/templates/club/club_members.jinja:21
|
#: club/templates/club/club_members.jinja:21 club/views.py:363
|
||||||
#: core/templates/core/user_clubs.jinja:29
|
#: core/templates/core/user_clubs.jinja:29
|
||||||
msgid "Mark as old"
|
msgid "Mark as old"
|
||||||
msgstr "Marquer comme ancien"
|
msgstr "Marquer comme ancien"
|
||||||
@ -1071,7 +1063,7 @@ msgid "To"
|
|||||||
msgstr "Au"
|
msgstr "Au"
|
||||||
|
|
||||||
#: club/templates/club/club_sellings.jinja:5 club/views.py:195
|
#: club/templates/club/club_sellings.jinja:5 club/views.py:195
|
||||||
#: club/views.py:507 counter/templates/counter/counter_main.jinja:19
|
#: club/views.py:560 counter/templates/counter/counter_main.jinja:19
|
||||||
#: counter/templates/counter/last_ops.jinja:35
|
#: counter/templates/counter/last_ops.jinja:35
|
||||||
msgid "Sellings"
|
msgid "Sellings"
|
||||||
msgstr "Ventes"
|
msgstr "Ventes"
|
||||||
@ -1097,7 +1089,7 @@ msgstr "unités"
|
|||||||
msgid "Benefit: "
|
msgid "Benefit: "
|
||||||
msgstr "Bénéfice : "
|
msgstr "Bénéfice : "
|
||||||
|
|
||||||
#: club/templates/club/club_sellings.jinja:21 club/views.py:446
|
#: club/templates/club/club_sellings.jinja:21 club/views.py:499
|
||||||
#: core/templates/core/user_account_detail.jinja:18
|
#: core/templates/core/user_account_detail.jinja:18
|
||||||
#: core/templates/core/user_account_detail.jinja:51
|
#: core/templates/core/user_account_detail.jinja:51
|
||||||
#: counter/templates/counter/cash_summary_list.jinja:33 counter/views.py:168
|
#: counter/templates/counter/cash_summary_list.jinja:33 counter/views.py:168
|
||||||
@ -1289,28 +1281,36 @@ msgstr "Utilisateurs à ajouter"
|
|||||||
msgid "Search users to add (one or more)."
|
msgid "Search users to add (one or more)."
|
||||||
msgstr "Recherche les utilisateurs à ajouter (un ou plus)."
|
msgstr "Recherche les utilisateurs à ajouter (un ou plus)."
|
||||||
|
|
||||||
#: club/views.py:348
|
#: club/views.py:381
|
||||||
msgid "One of the selected users doesn't exist"
|
msgid "One of the selected users doesn't exist"
|
||||||
msgstr "Un des utilisateurs sélectionné n'existe pas"
|
msgstr "Un des utilisateurs sélectionné n'existe pas"
|
||||||
|
|
||||||
#: club/views.py:353 core/views/group.py:82
|
#: club/views.py:385
|
||||||
|
msgid "User must be subscriber to take part to a club"
|
||||||
|
msgstr "L'utilisateur doit être cotisant pour faire partie d'un club"
|
||||||
|
|
||||||
|
#: club/views.py:389 core/views/group.py:82
|
||||||
msgid "You can not add the same user twice"
|
msgid "You can not add the same user twice"
|
||||||
msgstr "Vous ne pouvez pas ajouter deux fois le même utilisateur"
|
msgstr "Vous ne pouvez pas ajouter deux fois le même utilisateur"
|
||||||
|
|
||||||
#: club/views.py:371 sas/views.py:129 sas/views.py:195 sas/views.py:286
|
#: club/views.py:406
|
||||||
|
msgid "You should specify a role"
|
||||||
|
msgstr "Vous devez choisir un rôle"
|
||||||
|
|
||||||
|
#: club/views.py:417 sas/views.py:129 sas/views.py:195 sas/views.py:286
|
||||||
msgid "You do not have the permission to do that"
|
msgid "You do not have the permission to do that"
|
||||||
msgstr "Vous n'avez pas la permission de faire cela"
|
msgstr "Vous n'avez pas la permission de faire cela"
|
||||||
|
|
||||||
#: club/views.py:435 counter/views.py:1481
|
#: club/views.py:488 counter/views.py:1481
|
||||||
msgid "Begin date"
|
msgid "Begin date"
|
||||||
msgstr "Date de début"
|
msgstr "Date de début"
|
||||||
|
|
||||||
#: club/views.py:441 com/views.py:85 com/views.py:221 counter/views.py:1487
|
#: club/views.py:494 com/views.py:85 com/views.py:221 counter/views.py:1487
|
||||||
#: election/views.py:190 subscription/views.py:52
|
#: election/views.py:190 subscription/views.py:52
|
||||||
msgid "End date"
|
msgid "End date"
|
||||||
msgstr "Date de fin"
|
msgstr "Date de fin"
|
||||||
|
|
||||||
#: club/views.py:464 core/templates/core/user_stats.jinja:27
|
#: club/views.py:517 core/templates/core/user_stats.jinja:27
|
||||||
#: counter/views.py:1635
|
#: counter/views.py:1635
|
||||||
msgid "Product"
|
msgid "Product"
|
||||||
msgstr "Produit"
|
msgstr "Produit"
|
||||||
|
Loading…
Reference in New Issue
Block a user