Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.5.1 #1

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 160 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,160 @@
docs/_build
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
python:
- 3.7
- 3.8
- 3.9
services:
- postgresql
- mysql
Expand All @@ -15,6 +16,9 @@ env:
- DJANGO=3.0 DATABASE_ENGINE=sqlite
- DJANGO=3.0 DATABASE_ENGINE=postgres
- DJANGO=3.0 DATABASE_ENGINE=mysql
- DJANGO=4.0 DATABASE_ENGINE=sqlite
- DJANGO=4.0 DATABASE_ENGINE=postgres
- DJANGO=4.0 DATABASE_ENGINE=mysql

install:
- pip install -U setuptools zc.buildout
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Django Tagging Changelog
========================

Version 0.5.1, 6th April 2024:
------------------------------

* Add Django 4.2 support

Version 0.5.0, 6th March 2020:
------------------------------

Expand Down
2 changes: 1 addition & 1 deletion tagging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Django-tagging
"""
__version__ = '0.5.0'
__version__ = '0.5.1'
__license__ = 'BSD License'

__author__ = 'Jonathan Buchanan'
Expand Down
10 changes: 6 additions & 4 deletions tagging/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from django.contrib.contenttypes.models import ContentType
from django.db import connection
from django.db import models
from django.utils.encoding import smart_text
from django.db.models.query_utils import Q
from django.utils.encoding import smart_str
from django.utils.translation import gettext_lazy as _

from tagging import settings
Expand Down Expand Up @@ -155,8 +156,9 @@ def usage_for_model(self, model, counts=False, min_count=None,
filters = {}

queryset = model._default_manager.filter()
for f in filters.items():
queryset.query.add_filter(f)
for k, v in filters.items():
# Add support for both Django 4 and inferior versions
queryset.query.add_q(Q((k, v)))
usage = self.usage_for_queryset(queryset, counts, min_count)

return usage
Expand Down Expand Up @@ -519,4 +521,4 @@ class Meta:
verbose_name_plural = _('tagged items')

def __str__(self):
return '%s [%s]' % (smart_text(self.object), smart_text(self.tag))
return '%s [%s]' % (smart_str(self.object), smart_str(self.tag))
6 changes: 3 additions & 3 deletions tagging/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ def test_tag_d_validation(self):
def test_tag_get_from_model(self):
FormTest.objects.create(tags='test3 test2 test1')
FormTest.objects.create(tags='toto titi')
self.assertEquals(FormTest.tags, 'test1 test2 test3 titi toto')
self.assertEqual(FormTest.tags, 'test1 test2 test3 titi toto')


#########
Expand Down Expand Up @@ -1194,7 +1194,7 @@ def get_view(self, url, queries=1, code=200,
template='tests/article_list.html'):
with self.assertNumQueries(queries):
response = self.client.get(url)
self.assertEquals(response.status_code, code)
self.assertEqual(response.status_code, code)

if code == 200:
self.assertTrue(isinstance(response.context['tag'], Tag))
Expand All @@ -1214,7 +1214,7 @@ def test_view_dynamic(self):
def test_view_related(self):
response = self.get_view('/static/related/',
queries=2, expected_items=2)
self.assertEquals(len(response.context['related_tags']), 2)
self.assertEqual(len(response.context['related_tags']), 2)

def test_view_no_queryset_no_model(self):
self.assertRaises(ImproperlyConfigured, self.get_view,
Expand Down
12 changes: 6 additions & 6 deletions tagging/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Test urls for tagging."""
from django.conf.urls import url
from django.urls import re_path

from tagging.tests.models import Article
from tagging.views import TaggedObjectList
Expand All @@ -11,10 +11,10 @@ class StaticTaggedObjectList(TaggedObjectList):


urlpatterns = [
url(r'^static/$', StaticTaggedObjectList.as_view()),
url(r'^static/related/$', StaticTaggedObjectList.as_view(
re_path(r'^static/$', StaticTaggedObjectList.as_view()),
re_path(r'^static/related/$', StaticTaggedObjectList.as_view(
related_tags=True)),
url(r'^no-tag/$', TaggedObjectList.as_view(model=Article)),
url(r'^no-query-no-model/$', TaggedObjectList.as_view()),
url(r'^(?P<tag>[^/]+(?u))/$', TaggedObjectList.as_view(model=Article)),
re_path(r'^no-tag/$', TaggedObjectList.as_view(model=Article)),
re_path(r'^no-query-no-model/$', TaggedObjectList.as_view()),
re_path(r'^(?P<tag>[^/]+(?u))/$', TaggedObjectList.as_view(model=Article)),
]