diff --git a/survey/templates/survey/survey.html b/survey/templates/survey/survey.html index 4e72e1e7..614607dd 100644 --- a/survey/templates/survey/survey.html +++ b/survey/templates/survey/survey.html @@ -33,7 +33,7 @@

{{survey.name}}

{% csrf_token %} {% for category in categories %}

{{category}}

-

{{category.description}}

+

{{category.description|default_if_none:""}}

diff --git a/survey/tests/testdump.json b/survey/tests/testdump.json index 2232ca44..5e95be6d 100644 --- a/survey/tests/testdump.json +++ b/survey/tests/testdump.json @@ -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, @@ -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, @@ -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", diff --git a/survey/tests/views/test_survey_category.py b/survey/tests/views/test_survey_category.py new file mode 100644 index 00000000..a6bc7aa4 --- /dev/null +++ b/survey/tests/views/test_survey_category.py @@ -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")