Skip to content
Snippets Groups Projects
Commit 50f252de authored by Alexandre Detiste's avatar Alexandre Detiste
Browse files

Update upstream source from tag 'upstream/1.4.0'

Update to upstream version '1.4.0'
with Debian dir 26152573208d377e94dc665d050ec088969a52d7
parents df31c405 1daf7b54
No related branches found
No related tags found
No related merge requests found
Pipeline #833383 failed
---
name: Bug report
about: Open a bug report
title: "[bug] "
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of the bug or unexpected behavior.
**Steps To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**System Informatioon:**
- OS: [e.g. Ubuntu 24.04 LTS]
- Python Version: [e.g. Python 3.11.2]
- Django Version: [e.g. Django 4.2.5]
---
name: Feature request
about: Suggest an idea for this project
title: "[feature] "
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
---
name: Question
about: Please use the Discussion Forum to ask questions
title: "[question] "
labels: question
assignees: ''
---
Please use the [Discussion Forum](https://github.com/openwisp/django-swappable-models/discussions) to ask questions.
We will take care of moving the discussion to a more relevant repository if needed.
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
commit-message:
prefix: "[deps] "
- package-ecosystem: "github-actions" # Check for GitHub Actions updates
directory: "/" # The root directory where the Ansible role is located
schedule:
interval: "monthly" # Check for updates weekly
commit-message:
prefix: "[ci] "
## Checklist
- [ ] I have read the [OpenWISP Contributing Guidelines](http://openwisp.io/docs/developer/contributing.html).
- [ ] I have manually tested the changes proposed in this pull request.
- [ ] I have written new test cases for new code and/or updated existing tests for changes to existing code.
- [ ] I have updated the documentation.
## Reference to Existing Issue
Closes #<issue-number>.
Please [open a new issue](https://github.com/openwisp/django-swappable-models/issues/new/choose) if there isn't an existing issue yet.
## Description of Changes
Please describe these changes.
## Screenshot
Please include any relevant screenshots.
......@@ -15,21 +15,26 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
id: deps
run: |
pip install -U "pip==20.2.4" wheel setuptools
pip install -U pip wheel setuptools
pip install tox tox-gh-actions
pip install openwisp-utils[qa]@https://github.com/openwisp/openwisp-utils/tarball/master
......@@ -37,4 +42,5 @@ jobs:
run: ./run-qa-checks
- name: Test
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
run: tox
name: Publish Python Package to Pypi.org
on:
release:
types: [published]
permissions:
id-token: write
jobs:
pypi-publish:
name: Release Python Package on Pypi.org
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/swapper
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -U pip
pip install build
- name: Build package
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1.9.0
Changelog
=========
Version 1.4.0 [2024-08-14]
--------------------------
Changes
~~~~~~~
Dependencies
++++++++++++
- Added support for Django ``4.2`` and ``5.0``.
- Dropped support for Django ``Django 4.0a1``.
- Added support for Python ``3.10`` and ``3.11``.
- Dropped support for Python ``3.7``.
Verson 1.3.0 [2021-11-29]
-------------------------
- [change] Allow possibility to point swappable dependency to specific migration number
(instead of only to ``__latest__``)
- [change] Allow possibility to point swappable dependency to specific
migration number (instead of only to ``__latest__``)
Version 1.2.0 [2021-11-12]
--------------------------
- [feature] Add possibility to point swappable dependency to ``__latest__``
- [feature] Add possibility to point swappable dependency to
``__latest__``
- [change] Added support for Python 3.9
- [change] Added support for Django 3.2 and Django 4.0a1
- [change] Dropped support for old Django versions (<2.2)
- [change] Dropped support for old Python versions (<3.7)
- [feature] Added optional ``require_ready`` argument to ``load_model`` function
- [feature] Added optional ``require_ready`` argument to ``load_model``
function
Version 1.1.2 [2020-01-15]
--------------------------
......@@ -34,19 +50,22 @@ Version 1.1.0 [2017-05-11]
--------------------------
- [test] Added tests for swapper.split
- `#13 <https://github.com/openwisp/django-swappable-models/pull/13>`_ [fix] Handle contrib apps and apps with dot in app_label.
- `#13 <https://github.com/openwisp/django-swappable-models/pull/13>`_
[fix] Handle contrib apps and apps with dot in app_label.
Version 1.0.0 [2016-08-26]
--------------------------
- [docs] Improved usuability docs
- `86e238 <https://github.com/openwisp/django-swappable-models/commit/86e238>`_:
- `86e238
<https://github.com/openwisp/django-swappable-models/commit/86e238>`_:
[deps] Compatibility with django 1.10 added
Version 0.3.0 [2015-11-17]
--------------------------
- `#9 <https://github.com/openwisp/django-swappable-models/pull/9>`_ [deps] Added support for django 1.9
- `#9 <https://github.com/openwisp/django-swappable-models/pull/9>`_
[deps] Added support for django 1.9
Version 0.2.2 [2015-06-16]
--------------------------
......@@ -54,7 +73,8 @@ Version 0.2.2 [2015-06-16]
- [deps] Added support for django~=1.6.0
- [deps] Added support for Python 3.3
- [docs] Fix model reference in README
- [docs] Notes for load_model initialization (`for more info see #2 <https://github.com/openwisp/django-swappable-models/issues/2>`_)
- [docs] Notes for load_model initialization (`for more info see #2
<https://github.com/openwisp/django-swappable-models/issues/2>`_)
Version 0.2.1 [2014-11-18]
--------------------------
......
......@@ -32,9 +32,10 @@ setup(
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Framework :: Django',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
......@@ -43,6 +44,8 @@ setup(
'Framework :: Django :: 3.1',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.2',
'Framework :: Django :: 5.0',
],
tests_require=['django>=2.0'],
test_suite='tests',
......
......@@ -7,8 +7,10 @@ _prefixes = {}
def swappable_setting(app_label, model):
"""
Returns the setting name to use for the given model (i.e. AUTH_USER_MODEL)
"""Returns the setting name to use for the given model
Returns the setting name to use for the given model (i.e.
AUTH_USER_MODEL)
"""
prefix = _prefixes.get(app_label, app_label)
setting = "{prefix}_{model}_MODEL".format(
......@@ -23,7 +25,8 @@ def swappable_setting(app_label, model):
def is_swapped(app_label, model):
"""
"""Returns the value of the swapped setting.
Returns the value of the swapped setting, or False if the model hasn't
been swapped.
"""
......@@ -37,15 +40,17 @@ def is_swapped(app_label, model):
def get_model_name(app_label, model):
"""
Returns [app_label.model] unless the model has been swapped, in which case
returns the swappable setting value.
"""Returns [app_label.model].
Returns [app_label.model] unless the model has been swapped, in which
case returns the swappable setting value.
"""
return is_swapped(app_label, model) or join(app_label, model)
def dependency(app_label, model, version=None):
"""
"""Returns a Django 1.7+ style dependency tuple
Returns a Django 1.7+ style dependency tuple for inclusion in
migration.dependencies[]
"""
......@@ -56,16 +61,12 @@ def dependency(app_label, model, version=None):
def get_model_names(app_label, models):
"""
Map model names to their swapped equivalents for the given app
"""
"""Map model names to their swapped equivalents for the given app"""
return dict((model, get_model_name(app_label, model)) for model in models)
def load_model(app_label, model, required=True, require_ready=True):
"""
Load the specified model class, or the class it was swapped out for.
"""
"""Load the specified model class, or the class it was swapped out for."""
swapped = is_swapped(app_label, model)
if swapped:
app_label, model = split(swapped)
......@@ -83,9 +84,7 @@ def load_model(app_label, model, required=True, require_ready=True):
def set_app_prefix(app_label, prefix):
"""
Set a custom prefix to use for the given app (e.g. WQ)
"""
"""Set a custom prefix to use for the given app (e.g. WQ)"""
_prefixes[app_label] = prefix
......
......@@ -15,7 +15,6 @@ else:
class SwapperTestCase(TestCase):
# Tests that should work whether or not default_app.Type is swapped
def test_fields(self):
Type = swapper.load_model('default_app', 'Type')
......
[tox]
envlist =
py{37,38}-django22-{noswap,swap}
py{37,38}-django30-{noswap,swap}
py{37,38,39}-django31-{noswap,swap}
py{37,38,39}-django32-{noswap,swap}
py{38,39}-django40-{noswap, swap}
py{38}-django22-{noswap,swap}
py{38}-django30-{noswap,swap}
py{38,39}-django31-{noswap,swap}
py{38,39,310}-django32-{noswap,swap}
py{38,39,310}-django40-{noswap, swap}
py{38,39,310,311}-django42-{noswap, swap}
py{310,311}-django50-{noswap, swap}
lint
[gh-actions]
python =
3.7: py37
3.8: py38, lint
3.9: py39, lint
3.10: py310, lint
3.11: py311, lint
[testenv]
commands =
......@@ -22,13 +25,18 @@ deps =
django30: django~=3.0.0
django31: django~=3.1.0
django32: django~=3.2.0
django40: django~=4.0a1
django40: django~=4.0.0
django42: django~=4.2.0
django50: django~=5.0.0
setenv =
noswap: DJANGO_SETTINGS_MODULE=tests.settings
swap: DJANGO_SETTINGS_MODULE=tests.swap_settings
whitelist_externals = rm
allowlist_externals = rm
[testenv:lint]
commands =
rm -rf tests/default_app/migrations/ tests/alt_app/migrations/
flake8 swapper tests
allowlist_externals =
rm
flake8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment