Skip to content

Commit

Permalink
Start adding support for Django 4.0 and python 3.10
Browse files Browse the repository at this point in the history
It *should* probably all work once django-taggit releases a version
that supports Django 4.0 and python 3.10.

See jazzband/django-taggit#776

For #223
  • Loading branch information
philgyford committed Dec 15, 2021
1 parent 591bdce commit 34fbce6
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 72 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ Changelog (Django Ditto)
Unreleased
----------

- None.
- **Backwards incompatible:** Drop support for Django 2.2.

- **Backwards incompatible:** Requires django-taggit >= v2.0.0
(It changed how `TaggableManager` sets tags: https://github.com/jazzband/django-taggit/blob/master/CHANGELOG.rst#200-2021-11-14 )

- Add support for Django 4.0 [WAITING ON django-taggit]

- Add support for Python 3.10 [WAITING ON django-taggit]


1.4.2 - 2021-10-22
Expand Down
2 changes: 1 addition & 1 deletion ditto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = "Django Ditto"
__version__ = "1.4.2"
__version__ = "2.0.0"
__author__ = "Phil Gyford"
__author_email__ = "[email protected]"
__license__ = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions ditto/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from django.urls import reverse
from django.http import Http404
from django.shortcuts import redirect
from django.utils.encoding import force_str, force_text
from django.utils.translation import ugettext as _
from django.utils.encoding import force_str
from django.utils.translation import gettext as _
from django.views.generic import ListView, TemplateView
from django.views.generic import DayArchiveView as DjangoDayArchiveView

Expand Down Expand Up @@ -574,7 +574,7 @@ def get_variety_counts(self):
raise Http404(
_("No %(verbose_name_plural)s available")
% {
"verbose_name_plural": force_text(
"verbose_name_plural": force_str(
qs.model._meta.verbose_name_plural
)
}
Expand Down
2 changes: 1 addition & 1 deletion ditto/flickr/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http import Http404
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic import DetailView, ListView
from django.views.generic.detail import SingleObjectMixin

Expand Down
2 changes: 1 addition & 1 deletion ditto/lastfm/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import timedelta

from django.http import Http404
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic import DetailView, TemplateView
from django.views.generic.detail import SingleObjectMixin

Expand Down
2 changes: 1 addition & 1 deletion ditto/pinboard/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _save_bookmark(self, bookmark, fetch_time, account):
},
)

bookmark_obj.tags.set(*bookmark["tags"])
bookmark_obj.tags.set(bookmark["tags"])


class AllBookmarksFetcher(BookmarksFetcher):
Expand Down
2 changes: 1 addition & 1 deletion ditto/pinboard/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.http import Http404
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic import DetailView, ListView
from django.views.generic.detail import SingleObjectMixin

Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def get_author_email():
version=get_version(),
packages=["ditto"],
install_requires=[
"django-imagekit>=4.0,<4.1",
"django-sortedm2m>=3.0.0,<3.1",
"django-taggit>=1.2.0,<1.6",
"django-imagekit>=4.0,<4.2",
"django-sortedm2m>=3.0.0,<3.2",
"django-taggit>=2.0.0,<2.1",
"flickrapi>=2.4,<2.5",
"pillow>=7.0.0,<9.0",
"pytz",
Expand All @@ -91,7 +91,7 @@ def get_author_email():
],
dependency_links=[],
tests_require=tests_require,
extras_require={"dev": dev_require + ["Django>=3.1,<3.3"], "test": tests_require},
extras_require={"dev": dev_require + ["Django>=4.0,<4.3"], "test": tests_require},
include_package_data=True,
license=get_license(),
description=(
Expand All @@ -107,9 +107,9 @@ def get_author_email():
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.1",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
Expand Down
12 changes: 6 additions & 6 deletions tests/core/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_home_no_twitter(self):
# def test_tag_detail_templates(self):
# "Uses the correct templates"
# bookmark = pinboardfactories.BookmarkFactory.create()
# bookmark.tags.set('fish')
# bookmark.tags.set(['fish'])
# response = self.client.get(reverse('ditto:tag_detail',
# kwargs={'slug': 'fish'}))
# self.assertEquals(response.status_code, 200)
Expand All @@ -169,11 +169,11 @@ def test_home_no_twitter(self):
# def test_tag_detail_context(self):
# "Sends correct data to templates"
# bookmark_1 = pinboardfactories.BookmarkFactory.create(title='Carp')
# bookmark_1.tags.set('Fish', 'carp')
# bookmark_1.tags.set(['Fish', 'carp'])
# bookmark_2 = pinboardfactories.BookmarkFactory.create(title='Cod')
# bookmark_2.tags.set('Fish', 'cod')
# bookmark_2.tags.set(['Fish', 'cod'])
# bookmark_3 = pinboardfactories.BookmarkFactory.create(title='Dog')
# bookmark_3.tags.set('mammals', 'dog')
# bookmark_3.tags.set(['mammals', 'dog'])
# response = self.client.get(reverse('ditto:tag_detail',
# kwargs={'slug': 'fish'}))
# self.assertTrue('tag' in response.context)
Expand All @@ -186,9 +186,9 @@ def test_home_no_twitter(self):
# def test_tag_detail_privacy(self):
# "Does not display private bookmarks"
# bookmark_1 = pinboardfactories.BookmarkFactory.create(is_private=True)
# bookmark_1.tags.set('fish')
# bookmark_1.tags.set(['fish'])
# bookmark_2 = pinboardfactories.BookmarkFactory.create(is_private=False)
# bookmark_2.tags.set('fish')
# bookmark_2.tags.set(['fish'])
# response = self.client.get(reverse('ditto:tag_detail',
# kwargs={'slug': 'fish'}))
# self.assertTrue('bookmark_list' in response.context)
Expand Down
2 changes: 1 addition & 1 deletion tests/pinboard/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def test_update_bookmarks(self):
description="My initial description",
url="http://fontello.com/",
)
bookmark.tags.set("initial", "tags")
bookmark.tags.set(["initial", "tags"])

bookmarks_from_json = self.get_bookmarks_from_json()
bookmarks_data = bookmarks_from_json["bookmarks"]
Expand Down
30 changes: 15 additions & 15 deletions tests/pinboard/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_ordering(self):
def test_tags(self):
"Can save and recall tags"
bookmark = BookmarkFactory()
bookmark.tags.set("banana", "cherry", "apple")
bookmark.tags.set(["banana", "cherry", "apple"])
bookmark_reloaded = Bookmark.objects.get(pk=bookmark.pk)
self.assertEqual(len(bookmark_reloaded.tags.all()), 3)
self.assertIsInstance(bookmark_reloaded.tags.first(), BookmarkTag)
Expand All @@ -135,7 +135,7 @@ def test_tags(self):
def test_tags_private(self):
"Doesn't fetch private tags"
bookmark = BookmarkFactory()
bookmark.tags.set("ispublic", ".isprivate", "alsopublic")
bookmark.tags.set(["ispublic", ".isprivate", "alsopublic"])
bookmark_reloaded = Bookmark.objects.get(pk=bookmark.pk)
self.assertEqual(len(bookmark_reloaded.tags.all()), 2)
self.assertEqual(bookmark_reloaded.tags.names().first(), "alsopublic")
Expand All @@ -145,13 +145,13 @@ def test_tags_private(self):
def test_slugs_match_tags_true(self):
"Returns true if a list of slugs is the same to bookmark's tags"
bookmark = BookmarkFactory()
bookmark.tags.set("banana", "cherry")
bookmark.tags.set(["banana", "cherry"])
self.assertTrue(bookmark.slugs_match_tags(["cherry", "banana"]))

def test_slugs_match_tags_false(self):
"Returns false if a list of slugs is different to bookmark's tags"
bookmark = BookmarkFactory()
bookmark.tags.set("banana", "cherry")
bookmark.tags.set(["banana", "cherry"])
self.assertFalse(bookmark.slugs_match_tags(["banana", "apple"]))

def test_default_manager(self):
Expand Down Expand Up @@ -255,66 +255,66 @@ class PinboardBookmarkTagSlugsTestCase(TestCase):

def test_standard(self):
bookmark = BookmarkFactory()
bookmark.tags.set("normal")
bookmark.tags.set(["normal"])
self.assertEqual(bookmark.tags.first().slug, "normal")

def test_hyphens(self):
bookmark = BookmarkFactory()
bookmark.tags.set("one-tag")
bookmark.tags.set(["one-tag"])
self.assertEqual(bookmark.tags.first().slug, "one-tag")

def test_underscores(self):
bookmark = BookmarkFactory()
bookmark.tags.set("one_tag")
bookmark.tags.set(["one_tag"])
self.assertEqual(bookmark.tags.first().slug, "one_tag")

def test_private(self):
bookmark = BookmarkFactory()
bookmark.tags.set(".private")
bookmark.tags.set([".private"])
self.assertEqual(bookmark.tags.first().slug, ".private")

def test_capitals(self):
bookmark = BookmarkFactory()
bookmark.tags.set("CAPITALtags")
bookmark.tags.set(["CAPITALtags"])
self.assertEqual(bookmark.tags.first().slug, "capitaltags")

def test_special_characters_1(self):
"Characters that don't change"
bookmark = BookmarkFactory()
bookmark.tags.set("!$()*:;=@[]-.^_`{|}")
bookmark.tags.set(["!$()*:;=@[]-.^_`{|}"])
self.assertEqual(bookmark.tags.first().slug, "!$()*:;=@[]-.^_`{|}")

def test_special_characters_2(self):
"Characters that do change"
bookmark = BookmarkFactory()
bookmark.tags.set("#-&-'-+-/-?-\"-%-<->-\\")
bookmark.tags.set(["#-&-'-+-/-?-\"-%-<->-\\"])
self.assertEqual(
bookmark.tags.first().slug,
"%23-%2526-%27-%252B-%252f-%3f-%22-%25-%3C-%3E-%5c",
)

def test_accents(self):
bookmark = BookmarkFactory()
bookmark.tags.set("Àddîñg-áçćèńtš-tô-Éñgłïśh-íš-śīłłÿ!")
bookmark.tags.set(["Àddîñg-áçćèńtš-tô-Éñgłïśh-íš-śīłłÿ!"])
self.assertEqual(
bookmark.tags.first().slug, "àddîñg-áçćèńtš-tô-éñgłïśh-íš-śīłłÿ!"
)

def test_musical_notes(self):
bookmark = BookmarkFactory()
bookmark.tags.set("♬♫♪♩")
bookmark.tags.set(["♬♫♪♩"])
self.assertEqual(bookmark.tags.first().slug, "♬♫♪♩")

def test_chinese(self):
bookmark = BookmarkFactory()
bookmark.tags.set("美国")
bookmark.tags.set(["美国"])
self.assertEqual(bookmark.tags.first().slug, "美国")

@override_settings(TAGGIT_CASE_INSENSITIVE=True)
def test_case_insensitive_tags(self):
"Creating tags named 'dog' and 'DOG' should not create different slugs."
bookmark = BookmarkFactory()
bookmark.tags.set("dog", "cat", "DOG")
bookmark.tags.set(["dog", "cat", "DOG"])
self.assertEqual(
sorted([tag.slug for tag in bookmark.tags.all()]), ["cat", "dog"]
)
Expand Down
14 changes: 7 additions & 7 deletions tests/pinboard/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class PopularBookmarkTagsTestCase(TestCase):
def test_tags(self):
"Contains the correct data"
bookmark_1 = BookmarkFactory()
bookmark_1.tags.set("fish", "carp")
bookmark_1.tags.set(["fish", "carp"])
bookmark_2 = BookmarkFactory()
bookmark_2.tags.set("fish", "cod")
bookmark_2.tags.set(["fish", "cod"])
tags = ditto_pinboard.popular_bookmark_tags()
self.assertEqual(len(tags), 3)
self.assertEqual(tags[0].name, "fish")
Expand All @@ -142,9 +142,9 @@ def test_tags(self):
def test_tags_privacy_bookmarks(self):
"Doesn't display tags from private bookmarks"
bookmark_1 = BookmarkFactory(is_private=True)
bookmark_1.tags.set("fish", "carp")
bookmark_1.tags.set(["fish", "carp"])
bookmark_2 = BookmarkFactory(is_private=False)
bookmark_2.tags.set("fish", "cod")
bookmark_2.tags.set(["fish", "cod"])
tags = ditto_pinboard.popular_bookmark_tags()
self.assertEqual(len(tags), 2)
self.assertEqual(tags[0].name, "fish")
Expand All @@ -155,7 +155,7 @@ def test_tags_privacy_bookmarks(self):
def test_tags_privacy_tags(self):
"Doesn't display private .tags"
bookmark = BookmarkFactory()
bookmark.tags.set("ispublic", ".notpublic", "alsopublic")
bookmark.tags.set(["ispublic", ".notpublic", "alsopublic"])
tags = ditto_pinboard.popular_bookmark_tags()
self.assertEqual(len(tags), 2)
# Tags are ordered by popularity, so can't be sure
Expand All @@ -167,13 +167,13 @@ def test_tags_privacy_tags(self):
def test_tags_limit_default(self):
"It should return 10 tags by default"
bookmark = BookmarkFactory()
bookmark.tags.set("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11")
bookmark.tags.set(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"])
tags = ditto_pinboard.popular_bookmark_tags()
self.assertEqual(len(tags), 10)

def test_tags_limit_custom(self):
"It should return `limit` tags"
bookmark = BookmarkFactory()
bookmark.tags.set("1", "2", "3", "4", "5")
bookmark.tags.set(["1", "2", "3", "4", "5"])
tags = ditto_pinboard.popular_bookmark_tags(limit=3)
self.assertEqual(len(tags), 3)
Loading

0 comments on commit 34fbce6

Please sign in to comment.