Skip to content

Commit

Permalink
Change the way we display the disabled vote button
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Dec 1, 2024
1 parent 2bd5ccf commit 996a8fe
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 82 deletions.
13 changes: 9 additions & 4 deletions backend/hub/templates/hub/candidate/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,15 @@

{% else %}

<p class="button is-disabled">
{% trans "You can't vote this candidate" %}
</p>

{% if not organization_has_domain %}
<p class="button is-disabled">
{% trans "You need to choose your domain" %}
</p>
{% else %}
<p class="button is-disabled">
{% trans "You can't vote" %}
</p>
{% endif %}
{% endif %}
{% endif %}

Expand Down
14 changes: 13 additions & 1 deletion backend/hub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ def _get_candidate_approval_context(self, user: User, candidate: Candidate) -> D

def _get_candidate_vote_context(self, user: User, candidate: Candidate) -> Dict[str, bool]:
context = {
"user_has_organization": False,
"organization_has_domain": False,
"can_vote_candidate": False,
"voted_candidate": False,
"used_all_domain_votes": False,
Expand All @@ -783,7 +785,17 @@ def _get_candidate_vote_context(self, user: User, candidate: Candidate) -> Dict[

# An organization can only vote for candidates from its own domain
user_org = user.organization
if user_org and not user_org.is_elector(domain):
if not user_org:
return context

context["user_has_organization"] = True

if not user_org.voting_domain:
return context

context["organization_has_domain"] = True

if not user_org.is_elector(domain):
return context

context["can_vote_candidate"] = True
Expand Down
80 changes: 42 additions & 38 deletions backend/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-01 19:09+0200\n"
"POT-Creation-Date: 2024-12-01 20:34+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -600,7 +600,7 @@ msgstr ""
msgid "I agree to the {terms_url} of the VotONG platform"
msgstr ""

#: hub/forms.py:108 hub/forms.py:227 hub/views.py:550
#: hub/forms.py:108 hub/forms.py:227 hub/views.py:553
msgid "An organization with the same email address is already registered."
msgstr ""

Expand Down Expand Up @@ -979,7 +979,7 @@ msgstr ""
msgid "Is proposed?"
msgstr ""

#: hub/models.py:768 hub/templates/hub/candidate/detail.html:146
#: hub/models.py:768 hub/templates/hub/candidate/detail.html:153
msgid "Representative name"
msgstr "Candidate name"

Expand All @@ -999,7 +999,7 @@ msgstr ""
msgid "Candidate photo"
msgstr ""

#: hub/models.py:790 hub/templates/hub/candidate/detail.html:170
#: hub/models.py:790 hub/templates/hub/candidate/detail.html:177
msgid "Representative statement"
msgstr "Candidate statement"

Expand All @@ -1011,7 +1011,7 @@ msgid ""
"record."
msgstr ""

#: hub/models.py:802 hub/templates/hub/candidate/detail.html:150
#: hub/models.py:802 hub/templates/hub/candidate/detail.html:157
msgid "Mandate"
msgstr ""

Expand All @@ -1021,7 +1021,7 @@ msgid ""
"highlighting of the domain for which it is running"
msgstr ""

#: hub/models.py:813 hub/templates/hub/candidate/detail.html:155
#: hub/models.py:813 hub/templates/hub/candidate/detail.html:162
msgid "Letter of intent"
msgstr ""

Expand All @@ -1031,31 +1031,31 @@ msgid ""
"CES)"
msgstr ""

#: hub/models.py:821 hub/templates/hub/candidate/detail.html:160
#: hub/models.py:821 hub/templates/hub/candidate/detail.html:167
msgid "CV"
msgstr ""

#: hub/models.py:825
msgid "Europass format CV"
msgstr ""

#: hub/models.py:829 hub/templates/hub/candidate/detail.html:165
#: hub/models.py:829 hub/templates/hub/candidate/detail.html:172
msgid "Declaration of interests"
msgstr ""

#: hub/models.py:833
msgid "Official format Declaration of interests"
msgstr ""

#: hub/models.py:837 hub/templates/hub/candidate/detail.html:175
#: hub/models.py:837 hub/templates/hub/candidate/detail.html:182
msgid "Fiscal record"
msgstr ""

#: hub/models.py:841
msgid "Fiscal record, valid at the time of submitting the candidacy"
msgstr ""

#: hub/models.py:845 hub/templates/hub/candidate/detail.html:180
#: hub/models.py:845 hub/templates/hub/candidate/detail.html:187
msgid "Criminal record"
msgstr ""

Expand Down Expand Up @@ -1171,27 +1171,31 @@ msgstr ""
msgid "Confirm candidate status"
msgstr ""

#: hub/templates/hub/candidate/detail.html:115
#: hub/templates/hub/candidate/detail.html:116
msgid "✔ VOTED"
msgstr ""

#: hub/templates/hub/candidate/detail.html:119
#: hub/templates/hub/candidate/detail.html:120
msgid "You have used all the votes allotted for this domain."
msgstr ""

#: hub/templates/hub/candidate/detail.html:123
#: hub/templates/hub/candidate/detail.html:124
msgid "Vote"
msgstr ""

#: hub/templates/hub/candidate/detail.html:130
msgid "You can't vote this candidate"
#: hub/templates/hub/candidate/detail.html:132
msgid "You can't vote"
msgstr ""

#: hub/templates/hub/candidate/detail.html:142
#: hub/templates/hub/candidate/detail.html:136
msgid "You need to choose your domain"
msgstr ""

#: hub/templates/hub/candidate/detail.html:149
msgid "Candidate information"
msgstr ""

#: hub/templates/hub/candidate/detail.html:147
#: hub/templates/hub/candidate/detail.html:154
msgid "Representative role"
msgstr ""

Expand Down Expand Up @@ -1706,100 +1710,100 @@ msgstr ""
msgid "Thank you! We'll get in touch soon!"
msgstr ""

#: hub/views.py:445
#: hub/views.py:448
#, python-format
msgid ""
"Thank you for signing up! The form you filled in has reached us. Someone "
"from our team will reach out to you as soon as your organization is "
"validated. If you have any further questions, send us a message at %s."
msgstr ""

#: hub/views.py:483
#: hub/views.py:486
msgid "Update organization's profile"
msgstr ""

#: hub/views.py:484
#: hub/views.py:487
msgid ""
"Some data in this organization's profile can only be updated through NGO Hub."
msgstr ""

#: hub/views.py:487
#: hub/views.py:490
msgid "The organization's information is complete"
msgstr ""

#: hub/views.py:489
#: hub/views.py:492
msgid ""
"If you have recently edited information in the organization's account on NGO "
"Hub and want to update it in the profile on VotONG, click here"
msgstr ""

#: hub/views.py:502
#: hub/views.py:505
msgid ""
"The organization does not have the voting domain set. To be able to vote, "
"please set the voting domain."
msgstr ""

#: hub/views.py:543
#: hub/views.py:546
msgid "You must write a rejection message."
msgstr ""

#: hub/views.py:812
#: hub/views.py:821
msgid "The candidate has been proposed and is gathering the necessary support."
msgstr ""

#: hub/views.py:816
#: hub/views.py:825
msgid ""
"The candidate has been approved by the admins and is waiting for validation."
msgstr ""

#: hub/views.py:820
#: hub/views.py:829
msgid ""
"The candidate has been validated by the electoral commission and can be "
"voted."
msgstr ""

#: hub/views.py:824
#: hub/views.py:833
msgid ""
"The candidate has been rejected by the admins or the electoral commission."
msgstr ""

#: hub/views.py:897
#: hub/views.py:906
msgid "User is not authenticated."
msgstr ""

#: hub/views.py:902
#: hub/views.py:911
msgid "Authenticated user does not have an organization."
msgstr ""

#: hub/views.py:997
#: hub/views.py:1006
msgid "Candidate editing disabled"
msgstr ""

#: hub/views.py:1004
#: hub/views.py:1013
msgid "No user organization"
msgstr ""

#: hub/views.py:1007
#: hub/views.py:1016
msgid "No candidate"
msgstr ""

#: hub/views.py:1010
#: hub/views.py:1019
msgid "Candidate does not belong to user organization"
msgstr ""

#: hub/views.py:1028
#: hub/views.py:1037
msgid "A candidate can't be voted twice by the same organization."
msgstr ""

#: hub/views.py:1140
#: hub/views.py:1149
msgid "Cannot delete another user's confirmations"
msgstr ""

#: hub/views.py:1145
#: hub/views.py:1154
msgid "Confirmations successfully deleted"
msgstr ""

#: hub/views.py:1170
#: hub/views.py:1179
#, python-format
msgid "Please wait %(minutes_threshold)s minutes before updating again."
msgstr ""
Expand Down
Loading

0 comments on commit 996a8fe

Please sign in to comment.