Skip to content

Commit

Permalink
Merge pull request #160 from modlinltd/release/1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
asfaltboy committed Jan 23, 2022
2 parents a102f5c + f89c015 commit 985450e
Show file tree
Hide file tree
Showing 23 changed files with 484 additions and 64 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
branch = True
omit = */test*
source = advanced_filters
parallel = true

[report]
# Regexes for lines to exclude from consideration
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test with tox

on:
- pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions coveralls
- name: Test with tox
run: tox -p auto
env:
TOX_PARALLEL_NO_SPINNER: 1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ tests/db.sqlite*
.pytest_cache
/tests/local.db
/.venv
.vscode/settings.json
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
Changelog
=========

1.4.0 - Latvian translation and minor fixes
-------------------------------------------

**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**

Changes since 1.3.0:

Features
~~~~~~~~

- Add Latvian translation (#135)
- Commit compiled translation files (Merge db448fa)

Bug fixes
~~~~~~~~~

- switch from ugettext to gettext (#134)
- don't use default dict (Merge db448fa)
- correctly update extra_context (Merge db448fa)
- support parallel coverage reporting (Merge db448fa)

Other
~~~~~

- Fix CI for 2021 (#147)
- Don't run tests in GitHub actions twice, one per PR is enough (da6fe7f24982a0fa69fcebff79d658b087de5e5b)
- Ignore vscode settings (Merge db448fa)

Contributors
~~~~~~~~~~~~

- Pavel Savchenko
- Māris Nartišs


1.3.0 - Django 3.1 and more
---------------------------

Expand Down
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Requirements
============

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


Expand Down
2 changes: 1 addition & 1 deletion advanced_filters/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.0'
__version__ = '1.4.0'
47 changes: 26 additions & 21 deletions advanced_filters/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
from django.contrib.admin.utils import unquote
from django.http import HttpResponseRedirect
from django.shortcuts import resolve_url
from django.utils.translation import ugettext_lazy as _

from .forms import AdvancedFilterForm
from .models import AdvancedFilter

# django < 1.9 support
from django import VERSION
if VERSION >= (2, 0):
from django.utils.translation import gettext_lazy as _
else:
from django.utils.translation import ugettext_lazy as _


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

Expand Down Expand Up @@ -50,10 +56,7 @@ class AdminAdvancedFiltersMixin(object):

def __init__(self, *args, **kwargs):
super(AdminAdvancedFiltersMixin, self).__init__(*args, **kwargs)
if self.change_list_template:
self.original_change_list_template = self.change_list_template
else:
self.original_change_list_template = "admin/change_list.html"
self.original_change_list_template = "admin/change_list.html"
self.change_list_template = self.advanced_change_list_template
# add list filters to filters
self.list_filter = (AdvancedListFilters,) + tuple(self.list_filter)
Expand All @@ -74,30 +77,32 @@ def save_advanced_filter(self, request, form):
path=request.path, qparams="?_afilter={id}".format(
id=afilter.id))
return HttpResponseRedirect(url)
elif request.method == "POST":
else:
logger.info('Failed saving advanced filter, params: %s', form.data)

def adv_filters_handle(self, request, extra_context={}):
data = request.POST if request.POST.get(
'action') == 'advanced_filters' else None
adv_filters_form = self.advanced_filter_form(
data=data, model_admin=self, extra_form=True)
def changelist_view(self, request, extra_context=None):
"""Add advanced_filters form to changelist context"""
if extra_context is None:
extra_context = {}

data = None
if request.method == "POST":
if request.POST.get('action') == 'advanced_filters':
data = request.POST

form = self.advanced_filter_form(data=data, model_admin=self, extra_form=True)
extra_context.update({
'original_change_list_template': self.original_change_list_template,
'advanced_filters': adv_filters_form,
'advanced_filters': form,
'current_afilter': request.GET.get('_afilter'),
'app_label': self.opts.app_label,
})
return self.save_advanced_filter(request, adv_filters_form)

def changelist_view(self, request, extra_context=None):
"""Add advanced_filters form to changelist context"""
if extra_context is None:
extra_context = {}
response = self.adv_filters_handle(request,
extra_context=extra_context)
if response:
return response
if request.method == "POST":
response = self.save_advanced_filter(request, form)
if response:
return response

return super(AdminAdvancedFiltersMixin, self
).changelist_view(request, extra_context=extra_context)

Expand Down
12 changes: 8 additions & 4 deletions advanced_filters/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@
from django.db.models.fields import DateField
from django.forms.formsets import formset_factory, BaseFormSet
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _
from six.moves import range, reduce
from django.utils.text import capfirst

import django

from .models import AdvancedFilter
from .form_helpers import CleanWhiteSpacesMixin, VaryingTypeCharField

# django < 1.9 support
from django import VERSION
if VERSION >= (2, 0):
from django.utils.translation import gettext_lazy as _
else:
from django.utils.translation import ugettext_lazy as _


# django < 1.9 support
USE_VENDOR_DIR = django.VERSION >= (1, 9)
USE_VENDOR_DIR = VERSION >= (1, 9)
logger = logging.getLogger('advanced_filters.forms')

# select2 location can be modified via settings
Expand Down
Binary file added advanced_filters/locale/es/LC_MESSAGES/django.mo
Binary file not shown.
Binary file added advanced_filters/locale/ja/LC_MESSAGES/django.mo
Binary file not shown.
Binary file added advanced_filters/locale/lv/LC_MESSAGES/django.mo
Binary file not shown.
156 changes: 156 additions & 0 deletions advanced_filters/locale/lv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Māris Nartišs <mn@sungis.lv>, 2021.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-30 12:51+0200\n"
"PO-Revision-Date: 2021-01-30 13:20+0200\n"
"Last-Translator: Māris Nartišs <mn@sungis.lv>\n"
"Language-Team: Latvian <kde-i18n-doc@kde.org>\n"
"Language: lv_LV\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 :"
" 2);\n"
"X-Generator: Lokalize 20.08.2\n"

#: admin.py:25
msgid "Advanced filters"
msgstr "Paplašināti filtri"

#: admin.py:76
msgid "Advanced filter added successfully."
msgstr "Sekmīgi pievienots paplašināts filtrs."

#: forms.py:51
msgid "Equals"
msgstr "vienāds"

#: forms.py:52
msgid "Contains"
msgstr "satur"

#: forms.py:53
msgid "One of"
msgstr "viens no"

#: forms.py:54
msgid "DateTime Range"
msgstr "datuma un laika diapazons"

#: forms.py:55
msgid "Is NULL"
msgstr "ir NULL"

#: forms.py:56
msgid "Is TRUE"
msgstr "ir TRUE"

#: forms.py:57
msgid "Is FALSE"
msgstr "ir FALSE"

#: forms.py:58
msgid "Less Than"
msgstr "mazāks kā"

#: forms.py:59
msgid "Greater Than"
msgstr "lielāks kā"

#: forms.py:60
msgid "Less Than or Equal To"
msgstr "mazāks vai vienāds ar"

#: forms.py:61
msgid "Greater Than or Equal To"
msgstr "lielāks vai vienāds ar"

#: forms.py:65
msgid "Or (mark an or between blocks)"
msgstr "vai (pievieno vai starp blokiem)"

#: forms.py:69
msgid "Field"
msgstr "Lauks"

#: forms.py:71
msgid "Operator"
msgstr "Operators"

#: forms.py:75
msgid "Value"
msgstr "Vērtība"

#: forms.py:80
msgid "Negate"
msgstr "Pretēji"

#: models.py:24 templates/admin/advanced_filters.html:14
msgid "Advanced Filter"
msgstr "Paplašināts filtrs"

#: models.py:25
msgid "Advanced Filters"
msgstr "Paplašināti filtri"

#: models.py:27
msgid "Title"
msgstr "Nosaukums"

#: models.py:31
msgid "Created by"
msgstr "Izveidojis"

#: models.py:34
msgid "Created at"
msgstr "Izveidots"

#: models.py:35
msgid "URL"
msgstr "URL"

#: models.py:36
msgid "Users"
msgstr "Lietotāji"

#: models.py:37
msgid "Groups"
msgstr "Grupas"

#: templates/admin/advanced_filters.html:14
msgid "Edit"
msgstr "Rediģēt"

#: templates/admin/advanced_filters.html:26
msgid "Create advanced filter"
msgstr "Izveidot paplašinātu filtru"

#: templates/admin/advanced_filters.html:64
msgid "Save"
msgstr "Saglabāt"

#: templates/admin/advanced_filters.html:65
#: templates/admin/advanced_filters/change_form.html:50
msgid "Save & Filter Now!"
msgstr "Saglabāt un filtrēt!"

#: templates/admin/advanced_filters.html:66
msgid "Cancel"
msgstr "Atcelt"

#: templates/admin/advanced_filters/change_form.html:14
msgid "Change advanced filter"
msgstr "Mainīt paplašināto filtru"

#: templates/admin/common_js_init.html:14
msgid "Add another filter"
msgstr "Pievienot vēl vienu filtru"

#: templates/admin/common_js_init.html:15
msgid "Remove"
msgstr "Noņemt"
Binary file added advanced_filters/locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
Binary file added advanced_filters/locale/tr/LC_MESSAGES/django.mo
Binary file not shown.

0 comments on commit 985450e

Please sign in to comment.