Skip to content

Commit

Permalink
Add a display for the intermediate results (#379)
Browse files Browse the repository at this point in the history
- change the label to not show the "final results" text
  • Loading branch information
tudoramariei authored Dec 3, 2024
1 parent c96e809 commit 696dc83
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
12 changes: 8 additions & 4 deletions backend/hub/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.urls import reverse

from civil_society_vote.common.cache import cache_decorator
from hub.models import FLAG_CHOICES, FeatureFlag, SETTINGS_CHOICES
from hub.models import FLAG_CHOICES, FeatureFlag


@cache_decorator(cache_key="hub_settings", timeout=settings.TIMEOUT_CACHE_SHORT)
Expand All @@ -21,7 +21,10 @@ def hub_settings(_: HttpRequest) -> Dict[str, Any]:
candidate_supporting_enabled = flags.get(FLAG_CHOICES.enable_candidate_supporting, False)
candidate_voting_enabled = flags.get(FLAG_CHOICES.enable_candidate_voting, False)
candidate_confirmation_enabled = flags.get(FLAG_CHOICES.enable_candidate_confirmation, False)

results_enabled = flags.get(FLAG_CHOICES.enable_results_display, False)
final_results_enabled = flags.get(FLAG_CHOICES.enable_final_results_display, False)

org_approval_enabled = flags.get(FLAG_CHOICES.enable_org_approval, False)
org_editing_enabled = flags.get(FLAG_CHOICES.enable_org_editing, False)
org_registration_enabled = flags.get(FLAG_CHOICES.enable_org_registration, False)
Expand All @@ -44,13 +47,14 @@ def hub_settings(_: HttpRequest) -> Dict[str, Any]:
"CANDIDATE_VOTING_ENABLED": candidate_voting_enabled,
"CANDIDATE_CONFIRMATION_ENABLED": candidate_confirmation_enabled,
"RESULTS_ENABLED": results_enabled,
"FINAL_RESULTS_ENABLED": final_results_enabled,
"ORG_APPROVAL_ENABLED": org_approval_enabled,
"ORG_EDITING_ENABLED": org_editing_enabled,
"ORG_REGISTRATION_ENABLED": org_registration_enabled,
# Settings flags
"GLOBAL_SUPPORT_ENABLED": flags.get(SETTINGS_CHOICES.global_support_round, False),
"VOTING_DOMAIN_ENABLED": flags.get(SETTINGS_CHOICES.enable_voting_domain, False),
"SINGLE_DOMAIN_ROUND": flags.get(SETTINGS_CHOICES.single_domain_round, False),
"GLOBAL_SUPPORT_ENABLED": flags.get(FLAG_CHOICES.global_support_round, False),
"VOTING_DOMAIN_ENABLED": flags.get(FLAG_CHOICES.enable_voting_domain, False),
"SINGLE_DOMAIN_ROUND": flags.get(FLAG_CHOICES.single_domain_round, False),
# Composite flags
"ELECTION_IN_PROGRESS": (
candidate_registration_enabled
Expand Down
40 changes: 40 additions & 0 deletions backend/hub/migrations/0079_alter_featureflag_flag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.2.16 on 2024-12-03 14:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("hub", "0078_candidatevote_organization"),
]

operations = [
migrations.AlterField(
model_name="featureflag",
name="flag",
field=models.CharField(
choices=[
("enable_org_registration", "Enable organization registration"),
("enable_org_editing", "Enable organization editing"),
("enable_org_approval", "Enable organization approvals"),
("enable_candidate_registration", "Enable candidate registration"),
("enable_candidate_editing", "Enable candidate editing"),
("enable_candidate_supporting", "Enable candidate supporting"),
("enable_candidate_voting", "Enable candidate voting"),
("enable_candidate_confirmation", "Enable candidate confirmation"),
("enable_results_display", "Enable the display of results"),
("enable_final_results_display", "Enable the display of results after resolving all complaints"),
("single_domain_round", "Voting round with just one domain (some restrictions will apply)"),
(
"global_support_round",
"Enable global support (the support of at least 10 organizations is required)",
),
("enable_voting_domain", "Enable the voting domain restriction for an organization"),
],
max_length=254,
unique=True,
verbose_name="Flag",
),
),
]
1 change: 1 addition & 0 deletions backend/hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def select_public_storage():
("enable_candidate_voting", _("Enable candidate voting")),
("enable_candidate_confirmation", _("Enable candidate confirmation")),
("enable_results_display", _("Enable the display of results")),
("enable_final_results_display", _("Enable the display of results after resolving all complaints")),
)
SETTINGS_CHOICES = Choices(
("single_domain_round", _("Voting round with just one domain (some restrictions will apply)")),
Expand Down
8 changes: 7 additions & 1 deletion backend/hub/templates/hub/candidate/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@
<div class="need-title is-hidden-mobile">
<a class="has-text-black" href="{% url 'candidate-detail' candidate.pk %}">{{ candidate.name }}</a>
</div>

{% if forloop.counter <= domain.seats %}
<div class="need-title has-text-success">Câștigător (rezultate finale)</div>
{% if FINAL_RESULTS_ENABLED %}
<div class="need-title has-text-success">Câștigător (rezultate finale)</div>
{% else %}
<div class="need-title has-text-success">Câștigător</div>
{% endif %}
{% endif %}

<div class="need-title">Voturi: {{ candidate.count_votes }}</div>
</div>

Expand Down

0 comments on commit 696dc83

Please sign in to comment.