mirror of
https://github.com/ae-utbm/sith.git
synced 2026-06-19 14:32:41 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f15facd8f |
@@ -251,8 +251,12 @@ class ApplyElectionResultForm(forms.Form):
|
||||
user_id=c.user_id,
|
||||
club_id=c.role.club_role.club_id,
|
||||
role=c.role.club_role,
|
||||
description=(
|
||||
c.role.title if c.role.title != c.role.club_role.name else ""
|
||||
),
|
||||
)
|
||||
for c in candidates
|
||||
]
|
||||
Membership.objects.bulk_create(memberships)
|
||||
Membership._add_club_groups(memberships)
|
||||
return memberships
|
||||
|
||||
@@ -13,6 +13,7 @@ from pytest_django.asserts import assertRedirects
|
||||
from club.models import Club, ClubRole, Membership
|
||||
from core.baker_recipes import subscriber_user
|
||||
from core.models import Group, User
|
||||
from election.forms import ApplyElectionResultForm
|
||||
from election.models import Candidature, Election, ElectionList, Role, Vote
|
||||
|
||||
|
||||
@@ -155,6 +156,19 @@ class TestApplyResult(TestCase):
|
||||
response = self.client.post(self.url, data={"candidates": ids})
|
||||
assert response.status_code == 403
|
||||
|
||||
def test_membership_description(self):
|
||||
"""Test that if club role name and election role name are different,
|
||||
then the election role name is used as membership description.
|
||||
"""
|
||||
form = ApplyElectionResultForm(
|
||||
election=self.election, data={"candidates": [self.candidatures[0].id]}
|
||||
)
|
||||
assert form.is_valid()
|
||||
memberships = form.save()
|
||||
assert len(memberships) == 1
|
||||
assert memberships[0].role == self.club_roles[0]
|
||||
assert memberships[0].description == "election role 1"
|
||||
|
||||
def test_no_result_to_apply(self):
|
||||
self.election.roles.update(club_role=None)
|
||||
user = baker.make(
|
||||
|
||||
Reference in New Issue
Block a user