Skip to content

Commit

Permalink
Update to Django 4.2 LTS (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp authored Nov 14, 2023
1 parent af0b4c0 commit 17de32d
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 43 deletions.
3 changes: 0 additions & 3 deletions devproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True


Expand Down Expand Up @@ -264,7 +262,6 @@
"debug_toolbar.panels.templates.TemplatesPanel",
"debug_toolbar.panels.cache.CachePanel",
"debug_toolbar.panels.signals.SignalsPanel",
"debug_toolbar.panels.logging.LoggingPanel",
]


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.7 on 2023-11-13 19:08

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("misago_categories", "0009_auto_20221101_2111"),
]

operations = [
migrations.AlterField(
model_name="rolecategoryacl",
name="category_role",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="misago_categories.categoryrole",
),
),
]
2 changes: 1 addition & 1 deletion misago/conf/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(
f"{misago.__version__}{misago.__released__}"
f"{settings.LANGUAGE_CODE}{settings.SECRET_KEY}"
).encode("utf-8")
).encode()
).hexdigest()


Expand Down
2 changes: 1 addition & 1 deletion misago/faker/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_fake_username(fake):


def get_fake_avatars(email):
email_hash = hashlib.md5(email.lower().encode("utf-8")).hexdigest()
email_hash = hashlib.md5(email.lower().encode()).hexdigest()

return [
{"size": size, "url": GRAVATAR_URL % (email_hash, size)}
Expand Down
2 changes: 1 addition & 1 deletion misago/markup/checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def make_checksum(parsed, unique_values=None):
unique_values = unique_values or []
seeds = [parsed] + [str(v) for v in unique_values]

return sha256("+".join(seeds).encode("utf-8")).hexdigest()
return sha256("+".join(seeds).encode()).hexdigest()


def is_checksum_valid(parsed, checksum, unique_values=None):
Expand Down
2 changes: 1 addition & 1 deletion misago/themes/admin/css.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def rebuild_css(media_map, css):
css.build_file.delete(save=False)

css_source = css.source_file.read().decode("utf-8")
build_source = change_css_source(media_map, css_source).encode("utf-8")
build_source = change_css_source(media_map, css_source).encode()

build_file_name = css.name
if css.source_hash in build_file_name:
Expand Down
2 changes: 1 addition & 1 deletion misago/themes/admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def clean(self):

def save(self):
name = self.cleaned_data["name"]
source = self.cleaned_data["source"].encode("utf-8")
source = self.cleaned_data["source"].encode()
source_file = ContentFile(source, name)

self.instance.name = name
Expand Down
2 changes: 1 addition & 1 deletion misago/themes/admin/tests/test_getting_remote_css_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@responses.activate
def test_task_uses_response_body_to_set_css_size(css_link):
content = "html {}"
content_bytes = content.encode("utf-8")
content_bytes = content.encode()

responses.add(
responses.GET,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by Django 4.2.7 on 2023-11-13 19:08

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("misago_acl", "0004_cache_version"),
("misago_threads", "0012_set_dj_partial_indexes"),
]

operations = [
migrations.RenameIndex(
model_name="pollvote",
new_name="misago_thre_poll_id_c3e8fe_idx",
old_fields=("poll", "voter_name"),
),
migrations.RenameIndex(
model_name="post",
new_name="misago_thre_thread__4e5114_idx",
old_fields=("thread", "id"),
),
migrations.RenameIndex(
model_name="post",
new_name="misago_thre_poster__eefeb2_idx",
old_fields=("poster", "posted_on"),
),
migrations.RenameIndex(
model_name="post",
new_name="misago_thre_is_even_d29c90_idx",
old_fields=("is_event", "is_hidden"),
),
migrations.RenameIndex(
model_name="subscription",
new_name="misago_thre_send_em_da8b99_idx",
old_fields=("send_email", "last_read_on"),
),
migrations.RenameIndex(
model_name="thread",
new_name="misago_thre_categor_6cb52c_idx",
old_fields=("category", "id"),
),
migrations.RenameIndex(
model_name="thread",
new_name="misago_thre_categor_7ec8b0_idx",
old_fields=("category", "last_post_on"),
),
migrations.RenameIndex(
model_name="thread",
new_name="misago_thre_categor_c5eaf1_idx",
old_fields=("category", "replies"),
),
migrations.AlterField(
model_name="attachmenttype",
name="limit_downloads_to",
field=models.ManyToManyField(
blank=True, related_name="+", to="misago_acl.role"
),
),
migrations.AlterField(
model_name="attachmenttype",
name="limit_uploads_to",
field=models.ManyToManyField(
blank=True, related_name="+", to="misago_acl.role"
),
),
]
4 changes: 3 additions & 1 deletion misago/threads/models/pollvote.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ class PollVote(models.Model):
choice_hash = models.CharField(max_length=12, db_index=True)

class Meta:
index_together = [["poll", "voter_name"]]
indexes = [
models.Index(fields=["poll", "voter_name"]),
]
10 changes: 4 additions & 6 deletions misago/threads/models/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ class Meta:
condition=Q(is_event=True),
),
GinIndex(fields=["search_vector"]),
]

index_together = [
("thread", "id"), # speed up threadview for team members
("is_event", "is_hidden"),
("poster", "posted_on"),
# Speed up threadview for team members
models.Index(fields=["thread", "id"]),
models.Index(fields=["is_event", "is_hidden"]),
models.Index(fields=["poster", "posted_on"]),
]

def __str__(self):
Expand Down
4 changes: 3 additions & 1 deletion misago/threads/models/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ class Subscription(models.Model):
send_email = models.BooleanField(default=False)

class Meta:
index_together = [["send_email", "last_read_on"]]
indexes = [
models.Index(fields=["send_email", "last_read_on"]),
]
9 changes: 3 additions & 6 deletions misago/threads/models/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,9 @@ class Meta:
fields=["is_hidden"],
condition=Q(is_hidden=False),
),
]

index_together = [
["category", "id"],
["category", "last_post_on"],
["category", "replies"],
models.Index(fields=["category", "id"]),
models.Index(fields=["category", "last_post_on"]),
models.Index(fields=["category", "replies"]),
]

def __str__(self):
Expand Down
6 changes: 3 additions & 3 deletions misago/users/admin/tests/test_django_admin_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ def test_login(self):

def test_logout(self):
"""its possible to sign out from django admin"""
response = self.client.get(reverse("admin:index"))
response = self.client.post(reverse("admin:index"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, self.user.username)

# assert there's no showstopper on signout page
response = self.client.get(reverse("admin:logout"))
response = self.client.post(reverse("admin:logout"))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, self.user.username)

# user was signed out
response = self.client.get(reverse("admin:index"))
response = self.client.post(reverse("admin:index"))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, self.user.username)
23 changes: 23 additions & 0 deletions misago/users/migrations/0025_alter_user_rank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.7 on 2023-11-13 19:08

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
dependencies = [
("misago_users", "0024_user_notifications"),
]

operations = [
migrations.AlterField(
model_name="user",
name="rank",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="misago_users.rank",
),
),
]
2 changes: 1 addition & 1 deletion misago/users/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def hash_email(email: str) -> str:
return hashlib.md5(email.lower().encode("utf-8")).hexdigest()
return hashlib.md5(email.lower().encode()).hexdigest()


def slugify_username(username: str) -> str:
Expand Down
4 changes: 2 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ariadne_django
black
celery[redis]
coveralls
django<4
django~=4.2
djangorestframework
django-debug-toolbar
django-mptt
Expand All @@ -14,7 +14,7 @@ markdown
social-auth-app-django
pyjwt
pillow
psycopg2-binary
psycopg[binary]
pytest
pytest-cov
pytest-django
Expand Down
31 changes: 17 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ amqp==5.2.0
# via kombu
anyio==4.0.0
# via starlette
ariadne==0.20.1
ariadne==0.21
# via
# -r requirements.in
# ariadne-django
Expand All @@ -18,9 +18,9 @@ asgiref==3.7.2
# via django
billiard==4.2.0
# via celery
black==23.10.1
black==23.11.0
# via -r requirements.in
celery[redis]==5.3.4
celery[redis]==5.3.5
# via -r requirements.in
certifi==2023.7.22
# via requests
Expand Down Expand Up @@ -53,7 +53,7 @@ defusedxml==0.8.0rc2
# via
# python3-openid
# social-auth-core
django==3.2.23
django==4.2.7
# via
# -r requirements.in
# ariadne-django
Expand All @@ -75,7 +75,7 @@ djangorestframework==3.14.0
# via -r requirements.in
docopt==0.6.2
# via coveralls
faker==19.13.0
faker==20.0.0
# via -r requirements.in
graphql-core==3.2.3
# via ariadne
Expand Down Expand Up @@ -109,14 +109,16 @@ pathspec==0.11.2
# via black
pillow==10.1.0
# via -r requirements.in
platformdirs==3.11.0
platformdirs==4.0.0
# via black
pluggy==1.3.0
# via pytest
prompt-toolkit==3.0.39
prompt-toolkit==3.0.40
# via click-repl
psycopg2-binary==2.9.9
psycopg[binary]==3.1.12
# via -r requirements.in
psycopg-binary==3.1.12
# via psycopg
pycparser==2.21
# via cffi
pyjwt==2.8.0
Expand All @@ -132,7 +134,7 @@ pytest==7.4.3
# syrupy
pytest-cov==4.1.0
# via -r requirements.in
pytest-django==4.6.0
pytest-django==4.7.0
# via -r requirements.in
pytest-mock==3.12.0
# via -r requirements.in
Expand All @@ -145,11 +147,10 @@ python3-openid==3.2.0
pytz==2023.3.post1
# via
# -r requirements.in
# django
# djangorestframework
pyyaml==6.0.1
# via responses
redis==4.6.0
redis==5.0.1
# via celery
requests==2.31.0
# via
Expand All @@ -163,7 +164,7 @@ requests-oauthlib==1.3.1
# via social-auth-core
responses==0.24.0
# via -r requirements.in
ruff==0.1.4
ruff==0.1.5
# via -r requirements.in
six==1.16.0
# via
Expand All @@ -184,12 +185,14 @@ starlette==0.32.0.post1
syrupy==4.6.0
# via -r requirements.in
typing-extensions==4.8.0
# via ariadne
# via
# ariadne
# psycopg
tzdata==2023.3
# via celery
unidecode==1.3.7
# via -r requirements.in
urllib3==2.0.7
urllib3==2.1.0
# via
# requests
# responses
Expand Down

0 comments on commit 17de32d

Please sign in to comment.