Skip to content

Commit ff8c569

Browse files
committed
Cleanup the question color choices, no longer used
1 parent 8842d1a commit ff8c569

File tree

5 files changed

+3
-56
lines changed

5 files changed

+3
-56
lines changed

templates/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{% edit_content 'polls.poll_update' latest_poll.pk "#id_title" "-m-8" "dark" %}
1313
{{ latest_poll.title }}
1414
</div>
15-
<div class="{% if latest_poll.get_first_question.get_border_color_choice %} border-{{ latest_poll.get_first_question.get_border_color_choice }} {% else %}border-{{ border_color }}{% endif %} font-alt font-bold italic left-border mt-8 hover-parent">
15+
<div class="border-{{ border_color }} font-alt font-bold italic left-border mt-8 hover-parent">
1616
{% edit_content 'polls.poll_questions' latest_poll.pk "#id_ruleset_"|add:latest_poll.get_first_question.flow_result.result_uuid|add:"_title" "-m-8" "dark" %}
1717
{{ latest_poll.get_first_question.title }}
1818
</div>

templates/public/polls.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
<div data-html2canvas-ignore
249249
class="flex-none bg-circle bg-black text-white font-bold">{{ forloop.counter }}</div>
250250
<div class="flex-1 flex-center-y">
251-
<div class="{% if is_rtl_org %}{% cycle 'mr-4' 'ml-4' as margin %}{% else %}{% cycle 'ml-4' 'mr-4' as margin %}{% endif %} {% cycle 'white' 'black' 'white' 'white' as border_color silent %}{% if question.get_border_color_choice %} border-{{ question.get_border_color_choice }} {% else %}border-{{ border_color }}{% endif %} h-1 border-t">
251+
<div class="{% if is_rtl_org %}{% cycle 'mr-4' 'ml-4' as margin %}{% else %}{% cycle 'ml-4' 'mr-4' as margin %}{% endif %} {% cycle 'white' 'black' 'white' 'white' as border_color silent %} border-{{ border_color }} h-1 border-t">
252252
</div>
253253
</div>
254254
</div>

ureport/polls/models.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -867,27 +867,6 @@ class PollQuestion(SmartModel):
867867
("D3", _("Dark 3 background and Black text")),
868868
)
869869

870-
QUESTION_COLOR_CHOICE_BLOCK_CSS_CLASSES = {
871-
"D1": "bg-dark1 text-white",
872-
"L1": "bg-light1 text-black",
873-
"D2": "bg-dark2 text-white",
874-
"D3": "bg-dark3 text-black",
875-
}
876-
877-
QUESTION_COLOR_CHOICE_BG_COLORS = {
878-
"D1": ("dark1_color", "#98DFF9"),
879-
"L1": ("light1_color", "#143E49"),
880-
"D2": ("dark2_color", "#FFC20E"),
881-
"D3": ("dark3_color", "#FF7100"),
882-
}
883-
884-
QUESTION_COLOR_CHOICE_BORDER_COLORS = {
885-
"D1": "white",
886-
"L1": "black",
887-
"D2": "white",
888-
"D3": "white",
889-
}
890-
891870
QUESTION_HIDDEN_CHARTS_CHOICES = (
892871
(None, _("Show Age, Gender and Location charts")),
893872
("A", _("Hide Age chart ONLY")),
@@ -946,17 +925,6 @@ def get_last_pill(self):
946925
return "age"
947926
return "all"
948927

949-
def get_color_choice_css(self):
950-
return self.QUESTION_COLOR_CHOICE_BLOCK_CSS_CLASSES.get(self.color_choice, "")
951-
952-
def get_border_color_choice(self):
953-
return self.QUESTION_COLOR_CHOICE_BORDER_COLORS.get(self.color_choice, "")
954-
955-
def get_bg_color_choice(self):
956-
org = self.poll.org
957-
color_tuple = self.QUESTION_COLOR_CHOICE_BG_COLORS.get(self.color_choice, ("", ""))
958-
return org.get_config(color_tuple[0]) or color_tuple[1]
959-
960928
@classmethod
961929
def update_or_create(cls, user, poll, ruleset_label, uuid, ruleset_type):
962930
flow_result = FlowResult.update_or_create(poll.org, poll.flow_uuid, uuid, ruleset_label)

ureport/polls/tests.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -869,15 +869,13 @@ def test_questions_poll(self):
869869
response = self.client.get(uganda_questions_url, SERVER_NAME="uganda.ureport.io")
870870
self.assertEqual(response.status_code, 200)
871871
self.assertTrue("form" in response.context)
872-
self.assertEqual(len(response.context["form"].fields), 6)
872+
self.assertEqual(len(response.context["form"].fields), 5)
873873
self.assertTrue("ruleset_uuid-101_include" in response.context["form"].fields)
874874
self.assertTrue("ruleset_uuid-101_priority" in response.context["form"].fields)
875875
self.assertTrue("ruleset_uuid-101_label" in response.context["form"].fields)
876876
self.assertTrue("ruleset_uuid-101_title" in response.context["form"].fields)
877-
self.assertTrue("ruleset_uuid-101_color" in response.context["form"].fields)
878877
self.assertTrue("ruleset_uuid-101_hidden_charts" in response.context["form"].fields)
879878
self.assertEqual(response.context["form"].fields["ruleset_uuid-101_priority"].initial, 0)
880-
self.assertIsNone(response.context["form"].fields["ruleset_uuid-101_color"].initial)
881879
self.assertIsNone(response.context["form"].fields["ruleset_uuid-101_hidden_charts"].initial)
882880
self.assertEqual(response.context["form"].fields["ruleset_uuid-101_label"].initial, "question poll 1")
883881
self.assertEqual(response.context["form"].fields["ruleset_uuid-101_title"].initial, "question poll 1")
@@ -923,7 +921,6 @@ def test_questions_poll(self):
923921
post_data["ruleset_uuid-101_include"] = True
924922
post_data["ruleset_uuid-101_title"] = "electricity network coverage"
925923
post_data["ruleset_uuid-101_priority"] = 5
926-
post_data["ruleset_uuid-101_color"] = "D1"
927924
post_data["ruleset_uuid-101_hidden_charts"] = "GL"
928925
response = self.client.post(uganda_questions_url, post_data, follow=True, SERVER_NAME="uganda.ureport.io")
929926

@@ -933,7 +930,6 @@ def test_questions_poll(self):
933930
self.assertEqual(poll_question.title, "electricity network coverage")
934931
self.assertEqual(poll_question.ruleset_label, "question poll 1")
935932
self.assertEqual(poll_question.priority, 5)
936-
self.assertEqual(poll_question.color_choice, "D1")
937933
self.assertTrue(poll_question.show_age())
938934
self.assertFalse(poll_question.show_gender())
939935
self.assertFalse(poll_question.show_locations())

ureport/polls/views.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ def derive_fields(self):
428428
fields.append("ruleset_%s_include" % result_uuid)
429429
fields.append("ruleset_%s_label" % result_uuid)
430430

431-
fields.append("ruleset_%s_color" % result_uuid)
432-
433431
fields.append("ruleset_%s_hidden_charts" % result_uuid)
434432

435433
fields.append("ruleset_%s_title" % result_uuid)
@@ -500,16 +498,6 @@ def get_form(self):
500498
help_text=_("The question posed to your audience, will be displayed publicly"),
501499
)
502500

503-
color_field_name = f"ruleset_{result_uuid}_color"
504-
color_field_initial = initial.get(color_field_name, "")
505-
color_field = forms.ChoiceField(
506-
label=_("Color Choice"),
507-
choices=PollQuestion.QUESTION_COLOR_CHOICES,
508-
required=False,
509-
initial=color_field_initial,
510-
help_text=_("The color to use for the question block will be displayed publicly"),
511-
)
512-
513501
hidden_charts_field_name = f"ruleset_{result_uuid}_hidden_charts"
514502
hidden_charts_field_initial = initial.get(hidden_charts_field_name, "")
515503
hidden_charts_field = forms.ChoiceField(
@@ -524,7 +512,6 @@ def get_form(self):
524512
self.form.fields[priority_field_name] = priority_field
525513
self.form.fields[label_field_name] = label_field
526514
self.form.fields[title_field_name] = title_field
527-
self.form.fields[color_field_name] = color_field
528515
self.form.fields[hidden_charts_field_name] = hidden_charts_field
529516

530517
categories = question.get_public_categories()
@@ -569,15 +556,12 @@ def save(self, obj):
569556

570557
title = data[f"ruleset_{result_uuid}_title"]
571558

572-
color_choice = data[f"ruleset_{result_uuid}_color"]
573-
574559
hidden_charts_choice = data[f"ruleset_{result_uuid}_hidden_charts"]
575560

576561
PollQuestion.objects.filter(poll=poll, flow_result__result_uuid=result_uuid).update(
577562
is_active=included,
578563
title=title,
579564
priority=priority,
580-
color_choice=color_choice,
581565
hidden_charts=hidden_charts_choice,
582566
)
583567

@@ -620,7 +604,6 @@ def derive_initial(self):
620604
initial["ruleset_%s_priority" % result_uuid] = question.priority
621605
initial["ruleset_%s_label" % result_uuid] = result_name
622606
initial["ruleset_%s_title" % result_uuid] = question.title
623-
initial["ruleset_%s_color" % result_uuid] = question.color_choice
624607
initial["ruleset_%s_hidden_charts" % result_uuid] = question.hidden_charts
625608

626609
categories = question.get_public_categories()

0 commit comments

Comments
 (0)