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

Upgrade to Django 4.2 #3341

Merged
merged 58 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2f4010b
Upgrade Django to 4.2
BartSchuurmans Mar 29, 2024
45bd67c
Add migration resulting from Django 4.2 upgrade
BartSchuurmans Mar 29, 2024
3349817
settings.USE_L10N is deprecated
BartSchuurmans Mar 29, 2024
47fdad9
Use new STORAGES setting
BartSchuurmans Mar 29, 2024
0d621b6
Reorder operations in save() overrides
BartSchuurmans Mar 29, 2024
92a94d2
django.utils.timezone.utc alias is deprecated
BartSchuurmans Mar 29, 2024
984d7fb
Update pytest-django to 4.8.0
BartSchuurmans Mar 29, 2024
0007c86
Update environs to 11.0.0
BartSchuurmans Mar 29, 2024
cfcb873
Update pytest-cov to 5.0.0
BartSchuurmans Mar 29, 2024
4fa823e
Update django-storages to 1.14.2
BartSchuurmans Mar 29, 2024
b5ef9f6
Configure STORAGES using OPTIONS instead of subclassing
BartSchuurmans Mar 29, 2024
23bf089
Update boto3 to 1.34.74
BartSchuurmans Mar 29, 2024
3dfbc44
Update django-celery-beat to 2.6.0
BartSchuurmans Mar 29, 2024
16e1b17
Update django-csp to 3.8
BartSchuurmans Mar 29, 2024
ffb3549
Update django-imagekit to 5.0.0
BartSchuurmans Mar 29, 2024
69c2734
Update django-model-utils to 4.4.0
BartSchuurmans Mar 29, 2024
e0a14ea
Update django-sass-processor to 1.4
BartSchuurmans Mar 29, 2024
e9325b8
Update libsass to 0.23.0
BartSchuurmans Mar 29, 2024
1276112
Update opentelemetry dependencies
BartSchuurmans Mar 29, 2024
309147b
Update pycryptodome to 3.20.0
BartSchuurmans Mar 29, 2024
c11725a
Update pyotp to 2.9.0
BartSchuurmans Mar 29, 2024
1f8ba4d
Update python-dateutil to 2.9.0.post0
BartSchuurmans Mar 29, 2024
e1fd57a
Fix constructor arguments to SessionMiddleware in tests
BartSchuurmans Mar 30, 2024
d80a014
Update django-stubs to 4.2.7
BartSchuurmans Mar 30, 2024
869bc5a
Update mypy to 1.7.1
BartSchuurmans Mar 30, 2024
224fae7
Fix mypy errors
BartSchuurmans Mar 30, 2024
624115b
Use headers dict instead of HTTP_* kwargs or request.META
BartSchuurmans Apr 1, 2024
1303f53
Update psycopg to 2.9.9
BartSchuurmans Apr 1, 2024
b6174d9
Update bleach to 6.1.0
BartSchuurmans Apr 1, 2024
9ebda3f
Update celery to 5.3.6
BartSchuurmans Apr 1, 2024
01b3702
Update Markdown to 3.6
BartSchuurmans Apr 1, 2024
e46bc2e
Update redis-py to 5.0.3
BartSchuurmans Apr 1, 2024
1474c0d
Remove protobuf as a direct dependency
BartSchuurmans Apr 1, 2024
2537886
Group version constraints for indirect dependencies and change to >=
BartSchuurmans Apr 1, 2024
1cb8619
Update types-requests to 2.31.0.20240311
BartSchuurmans Apr 1, 2024
a1ff5a4
Update types-Pillow to 10.2.0.20240331
BartSchuurmans Apr 1, 2024
039160e
Update pytest-env to 1.1.3
BartSchuurmans Apr 1, 2024
f324a3c
Update pytest-xdist to 3.5.0
BartSchuurmans Apr 1, 2024
f6bbe67
Update responses to 0.25.0
BartSchuurmans Apr 1, 2024
22986a0
Update pytest to 8.1.1
BartSchuurmans Apr 1, 2024
39c2a0f
Update qrcode to 7.4.2
BartSchuurmans Apr 1, 2024
03ac846
Migrate from pytz to zoneinfo
BartSchuurmans Apr 1, 2024
2896219
Switch from django-redis to the built-in Redis cache backend
BartSchuurmans Apr 1, 2024
051dab7
Replace deprecated CICharField with custom collation for case-insensi…
BartSchuurmans Apr 1, 2024
f38622f
Define CSRF_TRUSTED_ORIGINS
BartSchuurmans Apr 2, 2024
de67c73
Add merge migration
BartSchuurmans Apr 10, 2024
77832cb
Add merge migration
BartSchuurmans Apr 15, 2024
7604d0a
Simplify ObjectMixin broadcast kwarg
BartSchuurmans Apr 25, 2024
a6c2ce1
Early return
BartSchuurmans Apr 25, 2024
e7f95ef
Modify update_fields in save() when modifying objects
BartSchuurmans Apr 25, 2024
c32f9fa
Upgrade pylint to 2.17.7
BartSchuurmans Apr 26, 2024
acae063
Fix new warnings from pylint upgrade
BartSchuurmans Apr 26, 2024
29f852b
consolidate multiple cache.delete() calls into cache.delete_many()
dato Apr 26, 2024
e6ee169
Narrow down bare `type: ignore` pragmas
dato Apr 3, 2024
44eedd0
Merge pull request #1 from dato/django-4.2
BartSchuurmans May 31, 2024
61d9e0c
Move comment to separate line
BartSchuurmans May 31, 2024
aa2312e
Merge branch 'main' into django-4.2
BartSchuurmans May 31, 2024
eca246f
Fix lint
BartSchuurmans May 31, 2024
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
10 changes: 5 additions & 5 deletions bookwyrm/activitypub/base_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ def get_representative():
to sign outgoing HTTP GET requests"""
return models.User.objects.get_or_create(
username=f"{INSTANCE_ACTOR_USERNAME}@{DOMAIN}",
defaults=dict(
email="bookwyrm@localhost",
local=True,
localname=INSTANCE_ACTOR_USERNAME,
),
defaults={
"email": "bookwyrm@localhost",
"local": True,
"localname": INSTANCE_ACTOR_USERNAME,
},
)[0]


Expand Down
8 changes: 6 additions & 2 deletions bookwyrm/connectors/connector_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def load_more_data(connector_id: str, book_id: str) -> None:
"""background the work of getting all 10,000 editions of LoTR"""
connector_info = models.Connector.objects.get(id=connector_id)
connector = load_connector(connector_info)
book = models.Book.objects.select_subclasses().get(id=book_id)
book = models.Book.objects.select_subclasses().get( # type: ignore[no-untyped-call]
id=book_id
)
connector.expand_book_data(book)


Expand All @@ -156,7 +158,9 @@ def create_edition_task(
"""separate task for each of the 10,000 editions of LoTR"""
connector_info = models.Connector.objects.get(id=connector_id)
connector = load_connector(connector_info)
work = models.Work.objects.select_subclasses().get(id=work_id)
work = models.Work.objects.select_subclasses().get( # type: ignore[no-untyped-call]
id=work_id
)
connector.create_edition_from_data(work, data)


Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/connectors/inventaire.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def get_description(self, links: JsonDict) -> str:
data = get_data(url)
except ConnectorException:
return ""
return data.get("extract", "")
return str(data.get("extract", ""))

def get_remote_id_from_model(self, obj: models.BookDataModel) -> str:
"""use get_remote_id to figure out the link from a model obj"""
Expand Down
13 changes: 4 additions & 9 deletions bookwyrm/importers/calibre_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ class CalibreImporter(Importer):
def __init__(self, *args: Any, **kwargs: Any):
# Add timestamp to row_mappings_guesses for date_added to avoid
# integrity error
row_mappings_guesses = []

for field, mapping in self.row_mappings_guesses:
if field in ("date_added",):
row_mappings_guesses.append((field, mapping + ["timestamp"]))
else:
row_mappings_guesses.append((field, mapping))

self.row_mappings_guesses = row_mappings_guesses
self.row_mappings_guesses = [
(field, mapping + (["timestamp"] if field == "date_added" else []))
for field, mapping in self.row_mappings_guesses
]
super().__init__(*args, **kwargs)

def get_shelf(self, normalized_row: dict[str, Optional[str]]) -> Optional[str]:
Expand Down
10 changes: 4 additions & 6 deletions bookwyrm/middleware/timezone_middleware.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" Makes the app aware of the users timezone """
import pytz
import zoneinfo

from django.utils import timezone

Expand All @@ -12,9 +12,7 @@ def __init__(self, get_response):

def __call__(self, request):
if request.user.is_authenticated:
timezone.activate(pytz.timezone(request.user.preferred_timezone))
timezone.activate(zoneinfo.ZoneInfo(request.user.preferred_timezone))
else:
timezone.activate(pytz.utc)
response = self.get_response(request)
timezone.deactivate()
return response
timezone.deactivate()
return self.get_response(request)
1 change: 1 addition & 0 deletions bookwyrm/migrations/0171_alter_user_preferred_timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Migration(migrations.Migration):
]

operations = [
# The new timezones are "Factory" and "localtime"
migrations.AlterField(
model_name="user",
name="preferred_timezone",
Expand Down
4 changes: 2 additions & 2 deletions bookwyrm/migrations/0193_auto_20240128_0249.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Generated by Django 3.2.23 on 2024-01-28 02:49

import bookwyrm.storage_backends
import django.core.serializers.json
from django.db import migrations, models
import django.db.models.deletion
from django.core.files.storage import storages


class Migration(migrations.Migration):
Expand All @@ -30,7 +30,7 @@ class Migration(migrations.Migration):
name="export_data",
field=models.FileField(
null=True,
storage=bookwyrm.storage_backends.ExportsFileStorage,
storage=storages["exports"],
upload_to="",
),
),
Expand Down
70 changes: 70 additions & 0 deletions bookwyrm/migrations/0199_alter_userblocks_user_object_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Generated by Django 4.2.11 on 2024-03-29 19:25

import bookwyrm.models.fields
from django.conf import settings
from django.db import migrations
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("bookwyrm", "0198_book_search_vector_author_aliases"),
]

operations = [
migrations.AlterField(
model_name="userblocks",
name="user_object",
field=bookwyrm.models.fields.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="%(class)s_user_object",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="userblocks",
name="user_subject",
field=bookwyrm.models.fields.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="%(class)s_user_subject",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="userfollowrequest",
name="user_object",
field=bookwyrm.models.fields.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="%(class)s_user_object",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="userfollowrequest",
name="user_subject",
field=bookwyrm.models.fields.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="%(class)s_user_subject",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="userfollows",
name="user_object",
field=bookwyrm.models.fields.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="%(class)s_user_object",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name="userfollows",
name="user_subject",
field=bookwyrm.models.fields.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
related_name="%(class)s_user_subject",
to=settings.AUTH_USER_MODEL,
),
),
]
Loading
Loading