Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1107 from kawazrepos/fix-filter
Browse files Browse the repository at this point in the history
Support django-filter 1.0
  • Loading branch information
giginet committed Nov 27, 2016
2 parents ac344fe + 4f29f2f commit 1a32cbd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pillow
markdown2>=2.3.0
djangorestframework
django-permission>=0.8.8
django-filter>=0.15.3,<1
django-filter>=1.0.0
django-roughpages>=0.1.2
django-thumbnailfield>=0.2.3
django-inspectional-registration
Expand Down
4 changes: 2 additions & 2 deletions src/kawaz/apps/events/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def test_list_with_categories(self):
password='password'))
r = self.client.get('/events/?category={}'.format(category.pk))
self.assertTemplateUsed(r, 'events/event_list.html')
self.assertEqual(len(r.context['filter']), 1)
self.assertTrue(event1 in r.context['filter'])
self.assertEqual(r.context['filter'].qs.count(), 1)
self.assertTrue(event1 in r.context['filter'].qs)


@mock.patch('django.utils.timezone.now', static_now)
Expand Down
14 changes: 7 additions & 7 deletions src/kawaz/apps/products/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_anyone_can_see_product_list(self):
r = self.client.get('/products/')
self.assertEqual(r.status_code, 200)
self.assertTemplateUsed(r, 'products/product_list.html')
self.assertIn(product, r.context['filter'])
self.assertIn(product, r.context['filter'].qs)

def test_list_with_platforms(self):
"""
Expand All @@ -110,9 +110,9 @@ def test_list_with_platforms(self):
self.prefer_login(user)
r = self.client.get('/products/?platforms={}'.format(self.p0.pk))
self.assertTemplateUsed(r, 'products/product_list.html')
self.assertEqual(len(r.context['filter']), 1)
self.assertIn(product1, r.context['filter'])
self.assertNotIn(product2, r.context['filter'])
self.assertEqual(r.context['filter'].qs.count(), 1)
self.assertIn(product1, r.context['filter'].qs)
self.assertNotIn(product2, r.context['filter'].qs)

def test_list_with_categories(self):
"""
Expand All @@ -123,9 +123,9 @@ def test_list_with_categories(self):
self.prefer_login(self.members[0])
r = self.client.get('/products/?categories={}'.format(self.c0.pk))
self.assertTemplateUsed(r, 'products/product_list.html')
self.assertEqual(len(r.context['filter']), 1)
self.assertIn(product1, r.context['filter'])
self.assertNotIn(product2, r.context['filter'])
self.assertEqual(r.context['filter'].qs.count(), 1)
self.assertIn(product1, r.context['filter'].qs)
self.assertNotIn(product2, r.context['filter'].qs)


class ProductCreateViewTestCase(ViewTestCaseBase):
Expand Down
1 change: 1 addition & 0 deletions src/kawaz/core/personas/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ class PersonaFilter(FilterSet):

class Meta:
model = Persona
exclude = ('avatar',)
2 changes: 1 addition & 1 deletion src/templates/events/event_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h1>{% trans "Upcoming events" %}</h1>

{% block content-main %}
<div class="event-list-wrap">
{% for event in filter %}
{% for event in filter.qs %}
{% include "events/components/list-item.html" %}
{% empty %}
<div class="alert alert-info">
Expand Down
4 changes: 2 additions & 2 deletions src/templates/personas/persona_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
{% endblock %}
{% block content-header %}
<div class="page-header">
<h1>{% trans "Members" %}({{ filter | length }})</h1>
<h1>{% trans "Members" %}({{ filter.qs.count }})</h1>
</div>
{% endblock %}
{% block content-main %}
{% if filter|length_is:"0" %}
{% if filter.qs.exists %}
<div class="alert alert-info">
<p>該当するメンバーは存在しません</p>
</div>
Expand Down

0 comments on commit 1a32cbd

Please sign in to comment.