diff --git a/backend/civil_society_vote/settings.py b/backend/civil_society_vote/settings.py index 9f358c78..d06849d5 100644 --- a/backend/civil_society_vote/settings.py +++ b/backend/civil_society_vote/settings.py @@ -539,6 +539,7 @@ def show_toolbar(request): ) +# Flag necessary if the elections require support from other members GLOBAL_SUPPORT_ENABLED = env("GLOBAL_SUPPORT_ENABLED") diff --git a/backend/hub/admin.py b/backend/hub/admin.py index 01d6bb42..129fd7ad 100644 --- a/backend/hub/admin.py +++ b/backend/hub/admin.py @@ -219,7 +219,7 @@ def send_confirm_email_to_committee(request, candidate, to_email): current_site = get_current_site(request) protocol = "https" if request.is_secure() else "http" - confirmation_link_path = reverse("candidate-detail", args=(candidate.pk,)) + confirmation_link_path = reverse("candidate-status-confirm", args=(candidate.pk,)) confirmation_link = f"{protocol}://{current_site.domain}{confirmation_link_path}" utils.send_email( diff --git a/backend/hub/templates/candidate/detail.html b/backend/hub/templates/candidate/detail.html index 7f9186b3..36e8e61d 100644 --- a/backend/hub/templates/candidate/detail.html +++ b/backend/hub/templates/candidate/detail.html @@ -68,14 +68,14 @@ - {% if not user.is_superuser and GLOBAL_SUPPORT_ENABLED and CANDIDATE_SUPPORTING_ENABLED and "support_candidate" in user_permissions and candidate.is_proposed %} + {% if not user.is_superuser and candidate.org.STATUS and GLOBAL_SUPPORT_ENABLED and CANDIDATE_SUPPORTING_ENABLED and "support_candidate" in user_permissions and candidate.is_proposed %}
@@ -88,13 +88,13 @@ {% if not user.is_superuser and CANDIDATE_VOTING_ENABLED and not CANDIDATE_SUPPORTING_ENABLED and not CANDIDATE_REGISTRATION_ENABLED and "vote_candidate" in user_permissions and candidate.status == 'accepted' %} {% if user|cant_vote:candidate %} - Nu poți vota la această rundă de alegeri. + Nu poți vota la această rundă de alegeri. {% elif user|can_vote_candidate:candidate %} - Votează + Votează {% elif user|already_voted_candidate:candidate %} - ✔ VOTAT + ✔ VOTAT {% else %} - Ai utilizat toate voturile alocate pentru acest domeniu. + Ai utilizat toate voturile alocate pentru acest domeniu. {% endif %} {% endif %} diff --git a/backend/hub/templatetags/hub_tags.py b/backend/hub/templatetags/hub_tags.py index b10a0a5c..a18b664f 100644 --- a/backend/hub/templatetags/hub_tags.py +++ b/backend/hub/templatetags/hub_tags.py @@ -42,6 +42,19 @@ def can_vote_candidate(user, candidate): return True +@register.filter +def can_support_candidate(user): + orgs = Organization.objects.filter(user=user) + + if not orgs: + return False + + if any(org.status == "accepted" for org in orgs): + return True + else: + return False + + @register.filter def already_voted_candidate(user, candidate): if CandidateVote.objects.filter(user=user, candidate=candidate).exists():