Skip to content

Commit

Permalink
Add a tooltip explaining the candidate statuses
Browse files Browse the repository at this point in the history
* add a tooltip to explain what each of the four candidate statuses means

---------

Co-authored-by: Tudor Amariei <[email protected]>
  • Loading branch information
danniel and tudoramariei authored Nov 18, 2024
1 parent 5e53da5 commit 0ee2120
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 59 deletions.
8 changes: 4 additions & 4 deletions backend/hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,10 @@ class Candidate(StatusModel, TimeStampedModel, BaseCompleteModel):
# CONFIRMED: has received confirmation from the electoral commission
# REJECTED: has been rejected
STATUS = Choices(
("pending", _("Pending")),
("accepted", _("In Validation")),
("confirmed", _("Confirmed")),
("rejected", _("Rejected")),
("pending", _("Pending candidate")),
("accepted", _("Accepted candidate")),
("confirmed", _("Validated candidate")),
("rejected", _("Rejected candidate")),
)
status = models.CharField(_("Status"), choices=STATUS, default=STATUS.pending, max_length=30, db_index=True)

Expand Down
1 change: 1 addition & 0 deletions backend/hub/templates/hub/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,300" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
<link rel="stylesheet" href="{% static "css/bulma-collapsible.min.css" %}">
<link rel="stylesheet" href="{% static "css/bulma-tooltip.min.css" %}">
<link rel="stylesheet" href="{% static "css/colors.css" %}">
<link rel="stylesheet" href="{% static "css/sizing.css" %}">
<link rel="stylesheet" href="{% static "css/footer.css" %}">
Expand Down
4 changes: 4 additions & 0 deletions backend/hub/templates/hub/candidate/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
{% if display_candidate_validation_label %}
{% if user|already_confirmed_candidate_status:candidate %}(validată){% else %}(nevalidată){% endif %}
{% endif %}

<span class="has-tooltip-multiline is-multiline status-{{ candidate.status }}" data-tooltip="{{ candidate_status_explainer }}">
<i class="fas fa-question-circle"></i>
</span>
</div>

</div>
Expand Down
34 changes: 34 additions & 0 deletions backend/hub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,39 @@ def _get_candidate_vote_context(self, user: User, candidate: Candidate) -> Dict[

return context

def _build_candidate_status_explainer(self) -> Dict:
candidate_statuses = {
Candidate.STATUS.pending: {
"title": Candidate.STATUS[Candidate.STATUS.pending],
"detail": _("The candidate has been proposed and is gathering the necessary support."),
"period": _("(25th october - 17th november 2024)"),
},
Candidate.STATUS.accepted: {
"title": Candidate.STATUS[Candidate.STATUS.accepted],
"detail": _("The candidate has been approved by the admins and is waiting for validation."),
"period": _("(18th - 20th november 2024)"),
},
Candidate.STATUS.confirmed: {
"title": Candidate.STATUS[Candidate.STATUS.confirmed],
"detail": _("The candidate has been validated by the electoral commission and can be voted."),
"period": _("(21th - 22th november 2024)"),
},
Candidate.STATUS.rejected: {
"title": Candidate.STATUS[Candidate.STATUS.rejected],
"detail": _("The candidate has been rejected by the admins or the electoral commission."),
},
}

status_explainers = {}

for status, status_data in candidate_statuses.items():
status_explainer = f"{status_data['title']}: {status_data['detail']}"
if "period" in status_data:
status_explainer += f"\n{status_data['period']}"
status_explainers[status] = status_explainer

return status_explainers

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)

Expand All @@ -755,6 +788,7 @@ def get_context_data(self, **kwargs):
candidate_status = candidate.STATUS[candidate.status]
context["candidate_status"] = candidate_status
context["display_candidate_validation_label"] = False
context["candidate_status_explainer"] = self._build_candidate_status_explainer()[candidate.status]

if user.is_anonymous:
return context
Expand Down
86 changes: 61 additions & 25 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-11-18 09:59+0200\n"
"POT-Creation-Date: 2024-11-18 13:55+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 @@ -381,11 +381,11 @@ msgid "accounts/error/user-role/"
msgstr ""

#: civil_society_vote/urls.py:78
msgid "accounts/"
msgid "accounts/login/"
msgstr ""

#: civil_society_vote/urls.py:79
msgid "accounts/login/"
msgid "accounts/"
msgstr ""

#: civil_society_vote/urls.py:81
Expand Down Expand Up @@ -789,7 +789,7 @@ msgstr ""
msgid "Admin"
msgstr ""

#: hub/models.py:293 hub/models.py:705
#: hub/models.py:293
msgid "Rejected"
msgstr ""

Expand Down Expand Up @@ -924,15 +924,19 @@ msgid "Organizations"
msgstr ""

#: hub/models.py:702
msgid "Pending"
msgid "Pending candidate"
msgstr ""

#: hub/models.py:703
msgid "In Validation"
msgid "Accepted candidate"
msgstr ""

#: hub/models.py:704
msgid "Confirmed"
msgid "Validated candidate"
msgstr ""

#: hub/models.py:705
msgid "Rejected candidate"
msgstr ""

#: hub/models.py:717
Expand All @@ -949,7 +953,7 @@ msgstr ""
msgid "Is proposed?"
msgstr ""

#: hub/models.py:734 hub/templates/hub/candidate/detail.html:123
#: hub/models.py:734 hub/templates/hub/candidate/detail.html:129
msgid "Representative name"
msgstr "Candidate name"

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

#: hub/models.py:756 hub/templates/hub/candidate/detail.html:127
#: hub/models.py:756 hub/templates/hub/candidate/detail.html:133
msgid "Representative statement"
msgstr "Candidate statement"

Expand All @@ -980,7 +984,7 @@ msgid ""
"public office and is not a dignitary of the Romanian state."
msgstr ""

#: hub/models.py:768 hub/templates/hub/candidate/detail.html:132
#: hub/models.py:768 hub/templates/hub/candidate/detail.html:138
msgid "Mandate"
msgstr ""

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

#: hub/models.py:779 hub/templates/hub/candidate/detail.html:137
#: hub/models.py:779 hub/templates/hub/candidate/detail.html:143
msgid "Letter of intent"
msgstr ""

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

#: hub/models.py:787 hub/templates/hub/candidate/detail.html:142
#: hub/models.py:787 hub/templates/hub/candidate/detail.html:148
msgid "CV"
msgstr ""

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

#: hub/models.py:795 hub/templates/hub/candidate/detail.html:147
#: hub/models.py:795 hub/templates/hub/candidate/detail.html:153
msgid "Declaration of interests"
msgstr ""

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

#: hub/models.py:803 hub/templates/hub/candidate/detail.html:152
#: hub/models.py:803 hub/templates/hub/candidate/detail.html:158
msgid "Fiscal record"
msgstr ""

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

#: hub/models.py:811 hub/templates/hub/candidate/detail.html:157
#: hub/models.py:811 hub/templates/hub/candidate/detail.html:163
msgid "Criminal record"
msgstr ""

Expand Down Expand Up @@ -1127,32 +1131,32 @@ msgstr ""
msgid "Section: "
msgstr ""

#: hub/templates/hub/candidate/detail.html:77
#: hub/templates/hub/candidate/detail.html:83
#: hub/templates/hub/committee/candidates.html:44
msgid "Supporters:"
msgstr ""

#: hub/templates/hub/candidate/detail.html:82
#: hub/templates/hub/candidate/detail.html:88
msgid "Confirm candidate status"
msgstr ""

#: hub/templates/hub/candidate/detail.html:98
#: hub/templates/hub/candidate/detail.html:104
msgid "✔ VOTED"
msgstr ""

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

#: hub/templates/hub/candidate/detail.html:106
#: hub/templates/hub/candidate/detail.html:112
msgid "Vote"
msgstr ""

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

#: hub/templates/hub/candidate/detail.html:124
#: hub/templates/hub/candidate/detail.html:130
msgid "Representative role"
msgstr ""

Expand Down Expand Up @@ -1683,15 +1687,47 @@ msgstr ""
msgid "You must write a rejection message."
msgstr ""

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

#: hub/views.py:740
msgid "(25th october - 17th november 2024)"
msgstr ""

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

#: hub/views.py:745
msgid "(18th - 20th november 2024)"
msgstr ""

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

#: hub/views.py:750
msgid "(21th - 22th november 2024)"
msgstr ""

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

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

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

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

0 comments on commit 0ee2120

Please sign in to comment.