Skip to content

Commit

Permalink
Fix None displayed when category description was empty (Pierre-Sassou…
Browse files Browse the repository at this point in the history
  • Loading branch information
maximloginov authored Oct 29, 2022
1 parent 09a7c27 commit f1eca4b
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
2 changes: 1 addition & 1 deletion survey/templates/survey/survey.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1> {{survey.name}} </h1>
{% csrf_token %}
{% for category in categories %}
<h3> {{category}} </h3>
<p> {{category.description}} </p>
<p> {{category.description|default_if_none:""}} </p>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
Expand Down
77 changes: 76 additions & 1 deletion survey/tests/testdump.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,22 @@
"redirect_url": "https://www.google.com"
}
},
{
"model": "survey.survey",
"pk": 13,
"fields": {
"name": "Category without description",
"description": "Test survey with category without description",
"is_published": true,
"need_logged_user": false,
"editable_answers": true,
"display_method": 0,
"template": null,
"publish_date": "2022-10-29",
"expire_date": "2050-03-15",
"redirect_url": ""
}
},
{
"model": "survey.category",
"pk": 1,
Expand Down Expand Up @@ -272,6 +288,26 @@
"description": "A second multipage category"
}
},
{
"model": "survey.category",
"pk": 6,
"fields": {
"name": "Category with description",
"survey": 13,
"order": 1,
"description": "Description of category"
}
},
{
"model": "survey.category",
"pk": 7,
"fields": {
"name": "Category without description",
"survey": 13,
"order": 2,
"description": null
}
},
{
"model": "survey.question",
"pk": 1,
Expand Down Expand Up @@ -478,7 +514,46 @@
"survey": 12,
"type": "text",
"choices": ""
}
}
},
{
"model": "survey.question",
"pk": 17,
"fields": {
"text": "Question for category with description",
"order": 1,
"required": false,
"category": 6,
"survey": 13,
"type": "text",
"choices": ""
}
},
{
"model": "survey.question",
"pk": 18,
"fields": {
"text": "Question for category without description",
"order": 2,
"required": false,
"category": 7,
"survey": 13,
"type": "text",
"choices": ""
}
},
{
"model": "survey.question",
"pk": 19,
"fields": {
"text": "Question without category",
"order": 3,
"required": false,
"category": null,
"survey": 13,
"type": "text",
"choices": ""
}
},
{
"model": "survey.response",
Expand Down
16 changes: 16 additions & 0 deletions survey/tests/views/test_survey_category.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import logging

from django.urls.base import reverse

from survey.tests import BaseTest

LOGGER = logging.getLogger(__name__)


class TestSurveyCategory(BaseTest):
def test_category_description_none_not_shown(self):
"""
Checks that blank category description is not shown (no 'None').
"""
response = self.client.get(reverse("survey-detail", args=(13,)))
self.assertNotContains(response, "None")

0 comments on commit f1eca4b

Please sign in to comment.