diff --git a/memopol/tests/test_representatives_list.py b/memopol/tests/test_representatives_list.py index 876120c391ed6a912854eef762b10e155a90ddb5..cda5458416b89e6ccc89d88c9658d31ea0a230e0 100644 --- a/memopol/tests/test_representatives_list.py +++ b/memopol/tests/test_representatives_list.py @@ -122,3 +122,6 @@ class RepresentativeListTest(UrlGetTestMixin, TestCase): def test_filter_multiple(self): self.filter_test('e', 110, 1, 17) + + def test_filter_notfound(self): + self.filter_test('non-existing-rep-name') diff --git a/static/scss/filter.scss b/static/scss/filter.scss index 6edf3981985847e6a9c1d03585535b0ce3020afc..7d0209fe829ec59d4dd7ae0545bbacbc382e5fc1 100644 --- a/static/scss/filter.scss +++ b/static/scss/filter.scss @@ -59,4 +59,12 @@ } } } +} + +.no-results { + margin-top: 1em; + font-size: larger; + font-weight: bold; + color: #555; + margin: 2em 0; } \ No newline at end of file diff --git a/templates/representatives/representative_list.haml b/templates/representatives/representative_list.haml index 087f2f1101477fd618eeee5933fa7a96f58d1651..d745a7b8c7b28fdf727c4d37126cebdf98ca89d0 100644 --- a/templates/representatives/representative_list.haml +++ b/templates/representatives/representative_list.haml @@ -15,47 +15,53 @@ {% url 'representative-list' as action_url %} - include 'representatives/_filter_form.html' with action=action_url form=filter.form qs=request.GET.urlencode - - include 'core/blocks/pagination.html' - - - block list - - %table.table - %tr - %th - - trans 'Photo' - %th - - trans 'Name' - %th - - trans 'Chamber' - %th - - trans 'Country' - %th - - trans 'Group' - %th - - trans 'Score' - - - for representative in object_list - %tr.representative_item{'class': '{{ representative.active|yesno:"active,inactive" }}'} - %td.photo - %a{'href': "{% url 'representative-detail' representative.slug %}"} - %img{'src': '={representative.photo}', 'width': '80'}/ - - %td - %a{'href': "{% url 'representative-detail' representative.slug %}"} - = representative.full_name - - %td - %a{'href': "{% chamber_url representative.chamber %}"} - = representative.chamber - - %td - %a{'href': "{% country_url representative.country %}"} - = representative.country - - %td - %a{'href': "{% group_url representative.main_mandate.group %}"} - = representative.main_mandate.group|group_icon - %td - = representative.score.score|score_label - - - include 'core/blocks/pagination.html' + - if object_list|length == 0 + + .no-results="No matching representatives found :(" + + - else + + - include 'core/blocks/pagination.html' + + - block list + + %table.table + %tr + %th + - trans 'Photo' + %th + - trans 'Name' + %th + - trans 'Chamber' + %th + - trans 'Country' + %th + - trans 'Group' + %th + - trans 'Score' + + - for representative in object_list + %tr.representative_item{'class': '{{ representative.active|yesno:"active,inactive" }}'} + %td.photo + %a{'href': "{% url 'representative-detail' representative.slug %}"} + %img{'src': '={representative.photo}', 'width': '80'}/ + + %td + %a{'href': "{% url 'representative-detail' representative.slug %}"} + = representative.full_name + + %td + %a{'href': "{% chamber_url representative.chamber %}"} + = representative.chamber + + %td + %a{'href': "{% country_url representative.country %}"} + = representative.country + + %td + %a{'href': "{% group_url representative.main_mandate.group %}"} + = representative.main_mandate.group|group_icon + %td + = representative.score.score|score_label + + - include 'core/blocks/pagination.html'