Skip to content

Commit

Permalink
Merge 657d8a6 into ec8a371
Browse files Browse the repository at this point in the history
  • Loading branch information
charettes committed Oct 23, 2022
2 parents ec8a371 + 657d8a6 commit 372c15f
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 61 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Expand Up @@ -2,3 +2,4 @@
source = reverse_unique
branch = 1
omit = reverse_unique/test*
relative_files = 1
58 changes: 58 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,58 @@
name: Test

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v1-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions
- name: Tox tests
run: |
tox -v
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: Unit Test

coveralls_finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
47 changes: 0 additions & 47 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
@@ -1,8 +1,8 @@
django-reverse-unique
=====================

.. image:: https://travis-ci.org/akaariai/django-reverse-unique.svg?branch=master
:target: https://travis-ci.org/akaariai/django-reverse-unique
.. image:: https://github.com/akaariai/django-reverse-unique/workflows/Test/badge.svg
:target: https://github.com/akaariai/django-reverse-unique/actions
:alt: Build Status

.. image:: https://coveralls.io/repos/akaariai/django-reverse-unique/badge.svg?branch=master
Expand Down
12 changes: 9 additions & 3 deletions reverse_unique/fields.py
Expand Up @@ -128,7 +128,7 @@ def get_filters(self):
else:
return self.filters

def get_extra_restriction(self, where_class, alias, related_alias):
def _get_extra_restriction(self, alias, related_alias):
remote_model = get_remote_field_model(self)
qs = remote_model.objects.filter(self.get_filters()).query
my_table = self.model._meta.db_table
Expand All @@ -141,11 +141,17 @@ def get_extra_restriction(self, where_class, alias, related_alias):
where.relabel_aliases({my_table: related_alias, rel_table: alias})
return where

if django.VERSION[0] >= 4:
get_extra_restriction = _get_extra_restriction
else:
def get_extra_restriction(self, where_class, alias, related_alias):
return self._get_extra_restriction(alias, related_alias)

def get_extra_descriptor_filter(self, instance):
return self.get_filters()

def get_path_info(self, filtered_relation):
ret = super(ReverseUnique, self).get_path_info(filtered_relation)
def get_path_info(self, *args, **kwargs):
ret = super(ReverseUnique, self).get_path_info(*args, **kwargs)
assert len(ret) == 1
return [ret[0]._replace(direct=False)]

Expand Down
28 changes: 19 additions & 9 deletions tox.ini
Expand Up @@ -2,26 +2,36 @@
args_are_paths = false
envlist =
flake8,
py39-{2.0,2.1,2.2,3.0,3.1,3.2},
py310-{3.0,3.1,3.2}
py36-3.2,
py37-3.2,
py38-{3.2,4.0,4.1,main},
py39-{3.2,4.0,4.1,main},
py310-{3.2,4.0,4.1,main},

[gh-actions]
python =
3.6: py36, flake8, isort
3.7: py37
3.8: py38
3.9: py39
3.10: py310

[testenv]
usedevelop = true
commands =
python -R -Wonce {envbindir}/coverage run {envbindir}/django-admin.py test -v2 --settings=reverse_unique_tests.settings {posargs}
{envpython} -R -Wonce {envbindir}/coverage run -a -m django test -v2 --settings=reverse_unique_tests.settings {posargs}
coverage report
deps =
coverage
2.0: Django>=2.0,<2.1
2.1: Django>=2.1,<2.2
2.2: Django>=2.2,<3.0
3.0: Django>=3.0,<3.1
3.1: Django>=3.1,<3.2
3.2: Django>=3.2,<4.0
4.0: Django>=4.0,<4.1
4.1: Django>=4.1,<4.2
main: https://github.com/django/django/archive/main.tar.gz
passenv =
GITHUB_*

[testenv:flake8]
basepython = python3.9
basepython = python3.6
commands =
flake8 reverse_unique
deps =
Expand Down

0 comments on commit 372c15f

Please sign in to comment.