Skip to content

Commit d7abdd6

Browse files
authored
Merge pull request readthedocs#2501 from rpkilby/upgrade-django-filter
Upgrade django filter
2 parents aacec83 + b8ba17e commit d7abdd6

File tree

11 files changed

+23
-22
lines changed

11 files changed

+23
-22
lines changed

readthedocs/builds/filters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ class VersionFilter(django_filters.FilterSet):
2727
project = django_filters.CharFilter(name='project__slug')
2828
# Allow filtering on slug= or version=
2929
slug = django_filters.CharFilter(label=_("Name"), name='slug',
30-
lookup_type='exact')
30+
lookup_expr='exact')
3131
version = django_filters.CharFilter(label=_("Version"), name='slug',
32-
lookup_type='exact')
32+
lookup_expr='exact')
3333

3434
class Meta:
3535
model = Version
3636
fields = ['project', 'slug', 'version']
3737

3838

3939
class BuildFilter(django_filters.FilterSet):
40-
date = django_filters.DateRangeFilter(label=_("Build Date"), name="date", lookup_type='range')
40+
date = django_filters.DateRangeFilter(label=_("Build Date"), name="date", lookup_expr='range')
4141
type = django_filters.ChoiceFilter(label=_("Build Type"),
4242
choices=BUILD_TYPES)
4343

readthedocs/projects/filters.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ class ProjectFilter(django_filters.FilterSet):
4444
"""Project filter for filter views"""
4545

4646
name = django_filters.CharFilter(label=_("Name"), name='name',
47-
lookup_type='icontains')
47+
lookup_expr='icontains')
4848
slug = django_filters.CharFilter(label=_("Slug"), name='slug',
49-
lookup_type='icontains')
49+
lookup_expr='icontains')
5050
pub_date = django_filters.DateRangeFilter(label=_("Created Date"),
5151
name="pub_date")
5252
repo = django_filters.CharFilter(label=_("Repository URL"), name='repo',
53-
lookup_type='icontains')
53+
lookup_expr='icontains')
5454
repo_type = django_filters.ChoiceFilter(
5555
label=_("Repository Type"),
5656
name='repo',
57-
lookup_type='icontains',
57+
lookup_expr='icontains',
5858
choices=REPO_CHOICES,
5959
)
6060

@@ -65,7 +65,7 @@ class Meta:
6565

6666
class DomainFilter(django_filters.FilterSet):
6767
project = django_filters.CharFilter(label=_("Project"), name='project__slug',
68-
lookup_type='exact')
68+
lookup_expr='exact')
6969

7070
class Meta:
7171
model = Domain

readthedocs/templates/builds/build_list.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h3>
4545

4646
<div id="build_list">
4747

48-
{% autopaginate filter 15 %}
48+
{% autopaginate filter.qs 15 %}
4949

5050
<!-- BEGIN builds list -->
5151
<div class="module">
@@ -67,9 +67,10 @@ <h3>
6767
{% endfor %}
6868
</select>
6969
</li>
70-
</form>
71-
</div>
70+
</ul>
71+
</form>
7272
</div>
73+
</div>
7374
{% endif %}
7475
{% endblock %}
7576

readthedocs/templates/core/build_list_detailed.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% load i18n %}
22
{% load static %}
33

4-
{% for build in filter %}
4+
{% for build in filter.qs %}
55
<li class="module-item col-span">
66
<div id="build-{{ build.id }}">
77
<a href="{{ build.get_absolute_url }}"><span id="build-state">{% if build.state != 'finished' %}{{ build.get_state_display }} {% else %} {% if build.success %}{% trans "Passed" %}{% else %}{% trans "Failed" %}{% endif %}{% endif %}</span>

readthedocs/templates/core/filter_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load i18n %}
22

3-
{% for obj in filter %}
3+
{% for obj in filter.qs %}
44
<li class="module-item col-span">
55
<div id="obj-{{ obj.id }}">
66
<a href="{{ obj.get_absolute_url }}">

readthedocs/templates/core/project_details.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h3>{% trans "Versions" %}</h3>
3232

3333
<div class="module-list-wrapper">
3434
<ul>
35-
{% for version in filter|sort_version_aware %}
35+
{% for version in filter.qs|sort_version_aware %}
3636
<li class="module-item col-span">
3737
{% if version.uploaded or version.built %}
3838
{# Link to the docs #}
@@ -70,7 +70,7 @@ <h3>{% trans "Build a version" %}</h3>
7070
<div class="version_right">
7171
<form method="post" action="{% url "generic_build" project.pk %}">
7272
<select id="id_version" name="version_slug">
73-
{% for version in filter|sort_version_aware %}
73+
{% for version in filter.qs|sort_version_aware %}
7474
<option value="{{ version.slug }}">{{ version.slug }}</option>
7575
{% endfor %}
7676
</select>

readthedocs/templates/core/version_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="module-list-wrapper">
22
<ul>
3-
{% for version in filter %}
3+
{% for version in filter.qs %}
44
<li class="module-item">
55
{# Link to the docs #}
66
<a class="module-item-title" href="{{ version.get_absolute_url }}">{{ version.slug }}</a>

readthedocs/templates/filter.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{% block content %}
1717

1818

19-
{% autopaginate filter 15 %}
19+
{% autopaginate filter.qs 15 %}
2020

2121
<!-- BEGIN builds list -->
2222
<div class="module">

readthedocs/templates/projects/project_dashboard_base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
<div class="col-major project-dashboard-right">
1616
{% if project_list %}
1717

18-
{% if filter|length > 0 %}
18+
{% if filter.qs.count > 0 %}
1919
<div class="module-header">
2020
<h3>{% trans "Important Versions" %}</h3>
2121
</div>
2222

2323
<div class="filter">
24-
{% autopaginate filter 15 %}
24+
{% autopaginate filter.qs 15 %}
2525

2626
<!-- BEGIN filter list -->
2727
<div class="module">

readthedocs/templates/projects/project_version_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h3>Filters</h3>
3636
<h1>{% trans "Active Versions" %}</h1>
3737
<div class="module-list-wrapper">
3838
<ul>
39-
{% for version in active_filter|sort_version_aware %}
39+
{% for version in active_filter.qs|sort_version_aware %}
4040
{% block active-versions %}
4141
<li class="module-item">
4242
{# Link to the docs #}
@@ -84,7 +84,7 @@ <h1>{% trans "Active Versions" %}</h1>
8484
<h1>{% trans "Inactive Versions" %}</h1>
8585
<div class="module-list-wrapper">
8686
<ul>
87-
{% for version in inactive_filter|sort_version_aware %}
87+
{% for version in inactive_filter.qs|sort_version_aware %}
8888

8989
{% block inactive-versions %}
9090
<li class="module-item">

requirements/pip.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ docker-py==1.3.1
5656
django-textclassifier==1.0
5757
django-annoying==0.8.4
5858
django-messages-extends==0.5
59-
django-filter<1.0
59+
django-filter==1.0.0
6060

6161
# Docs
6262
sphinxcontrib-httpdomain==1.4.0

0 commit comments

Comments
 (0)