Skip to content

Commit 985450e

Browse files
authored
Merge pull request #160 from modlinltd/release/1.4.0
Release 1.4.0
2 parents a102f5c + f89c015 commit 985450e

File tree

23 files changed

+484
-64
lines changed

23 files changed

+484
-64
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
branch = True
33
omit = */test*
44
source = advanced_filters
5+
parallel = true
56

67
[report]
78
# Regexes for lines to exclude from consideration

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test with tox
2+
3+
on:
4+
- pull_request
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install tox tox-gh-actions coveralls
23+
- name: Test with tox
24+
run: tox -p auto
25+
env:
26+
TOX_PARALLEL_NO_SPINNER: 1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ tests/db.sqlite*
1717
.pytest_cache
1818
/tests/local.db
1919
/.venv
20+
.vscode/settings.json

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
Changelog
22
=========
33

4+
1.4.0 - Latvian translation and minor fixes
5+
-------------------------------------------
6+
7+
**NOTE: This release will be the last one to include features in 1.X branch, other than urgent hotfixes; version 2.X will drop support for EOL python and Django versions, and all future development will be done against 2.X branch**
8+
9+
Changes since 1.3.0:
10+
11+
Features
12+
~~~~~~~~
13+
14+
- Add Latvian translation (#135)
15+
- Commit compiled translation files (Merge db448fa)
16+
17+
Bug fixes
18+
~~~~~~~~~
19+
20+
- switch from ugettext to gettext (#134)
21+
- don't use default dict (Merge db448fa)
22+
- correctly update extra_context (Merge db448fa)
23+
- support parallel coverage reporting (Merge db448fa)
24+
25+
Other
26+
~~~~~
27+
28+
- Fix CI for 2021 (#147)
29+
- Don't run tests in GitHub actions twice, one per PR is enough (da6fe7f24982a0fa69fcebff79d658b087de5e5b)
30+
- Ignore vscode settings (Merge db448fa)
31+
32+
Contributors
33+
~~~~~~~~~~~~
34+
35+
- Pavel Savchenko
36+
- Māris Nartišs
37+
38+
439
1.3.0 - Django 3.1 and more
540
---------------------------
641

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Requirements
2727
============
2828

2929
- Django >= 1.9 (Django 1.9 - 3.1 on Python 2/3/PyPy3)
30-
- django-braces >= 1.4, <= 1.14.0
3130
- simplejson >= 3.6.5, < 4
3231

3332

advanced_filters/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.0'
1+
__version__ = '1.4.0'

advanced_filters/admin.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
from django.contrib.admin.utils import unquote
66
from django.http import HttpResponseRedirect
77
from django.shortcuts import resolve_url
8-
from django.utils.translation import ugettext_lazy as _
98

109
from .forms import AdvancedFilterForm
1110
from .models import AdvancedFilter
1211

12+
# django < 1.9 support
13+
from django import VERSION
14+
if VERSION >= (2, 0):
15+
from django.utils.translation import gettext_lazy as _
16+
else:
17+
from django.utils.translation import ugettext_lazy as _
18+
1319

1420
logger = logging.getLogger('advanced_filters.admin')
1521

@@ -50,10 +56,7 @@ class AdminAdvancedFiltersMixin(object):
5056

5157
def __init__(self, *args, **kwargs):
5258
super(AdminAdvancedFiltersMixin, self).__init__(*args, **kwargs)
53-
if self.change_list_template:
54-
self.original_change_list_template = self.change_list_template
55-
else:
56-
self.original_change_list_template = "admin/change_list.html"
59+
self.original_change_list_template = "admin/change_list.html"
5760
self.change_list_template = self.advanced_change_list_template
5861
# add list filters to filters
5962
self.list_filter = (AdvancedListFilters,) + tuple(self.list_filter)
@@ -74,30 +77,32 @@ def save_advanced_filter(self, request, form):
7477
path=request.path, qparams="?_afilter={id}".format(
7578
id=afilter.id))
7679
return HttpResponseRedirect(url)
77-
elif request.method == "POST":
80+
else:
7881
logger.info('Failed saving advanced filter, params: %s', form.data)
7982

80-
def adv_filters_handle(self, request, extra_context={}):
81-
data = request.POST if request.POST.get(
82-
'action') == 'advanced_filters' else None
83-
adv_filters_form = self.advanced_filter_form(
84-
data=data, model_admin=self, extra_form=True)
83+
def changelist_view(self, request, extra_context=None):
84+
"""Add advanced_filters form to changelist context"""
85+
if extra_context is None:
86+
extra_context = {}
87+
88+
data = None
89+
if request.method == "POST":
90+
if request.POST.get('action') == 'advanced_filters':
91+
data = request.POST
92+
93+
form = self.advanced_filter_form(data=data, model_admin=self, extra_form=True)
8594
extra_context.update({
8695
'original_change_list_template': self.original_change_list_template,
87-
'advanced_filters': adv_filters_form,
96+
'advanced_filters': form,
8897
'current_afilter': request.GET.get('_afilter'),
8998
'app_label': self.opts.app_label,
9099
})
91-
return self.save_advanced_filter(request, adv_filters_form)
92100

93-
def changelist_view(self, request, extra_context=None):
94-
"""Add advanced_filters form to changelist context"""
95-
if extra_context is None:
96-
extra_context = {}
97-
response = self.adv_filters_handle(request,
98-
extra_context=extra_context)
99-
if response:
100-
return response
101+
if request.method == "POST":
102+
response = self.save_advanced_filter(request, form)
103+
if response:
104+
return response
105+
101106
return super(AdminAdvancedFiltersMixin, self
102107
).changelist_view(request, extra_context=extra_context)
103108

advanced_filters/forms.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@
1515
from django.db.models.fields import DateField
1616
from django.forms.formsets import formset_factory, BaseFormSet
1717
from django.utils.functional import cached_property
18-
from django.utils.translation import ugettext_lazy as _
1918
from six.moves import range, reduce
2019
from django.utils.text import capfirst
2120

22-
import django
23-
2421
from .models import AdvancedFilter
2522
from .form_helpers import CleanWhiteSpacesMixin, VaryingTypeCharField
2623

24+
# django < 1.9 support
25+
from django import VERSION
26+
if VERSION >= (2, 0):
27+
from django.utils.translation import gettext_lazy as _
28+
else:
29+
from django.utils.translation import ugettext_lazy as _
30+
2731

2832
# django < 1.9 support
29-
USE_VENDOR_DIR = django.VERSION >= (1, 9)
33+
USE_VENDOR_DIR = VERSION >= (1, 9)
3034
logger = logging.getLogger('advanced_filters.forms')
3135

3236
# select2 location can be modified via settings
1.94 KB
Binary file not shown.

0 commit comments

Comments
 (0)