Skip to content

Commit

Permalink
Django upgrade; migrate from whitenoise to servestatic
Browse files Browse the repository at this point in the history
  • Loading branch information
brianglass committed Aug 8, 2024
1 parent 6a1a180 commit 15a166a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 34 deletions.
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# This has to be pinned to Bullseye until oscrypto is updated
# See https://github.com/wbond/oscrypto/issues/78
FROM python:3.12-slim

WORKDIR /orthocal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Generated by Django 4.1.4 on 2023-01-24 00:43
# Generated by Django 5.0.7 on 2024-08-08 13:32

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


class Migration(migrations.Migration):

replaces = [('calendarium', '0001_initial'), ('calendarium', '0002_alter_pericope_unique_together'), ('calendarium', '0003_rename_day_month_day_calendarium_month_f3d07a_idx_and_more')]

initial = True

dependencies = [
Expand Down Expand Up @@ -35,6 +37,9 @@ class Migration(migrations.Migration):
('suffix', models.CharField(max_length=255)),
('flag', models.SmallIntegerField()),
],
options={
'unique_together': {('pericope', 'book')},
},
),
migrations.CreateModel(
name='Day',
Expand All @@ -55,7 +60,7 @@ class Migration(migrations.Migration):
('flag', models.SmallIntegerField()),
],
options={
'index_together': {('month', 'day')},
'indexes': [models.Index(fields=['month', 'day'], name='calendarium_month_f3d07a_idx')],
},
),
migrations.CreateModel(
Expand All @@ -72,7 +77,7 @@ class Migration(migrations.Migration):
('pericope', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='calendarium.pericope')),
],
options={
'index_together': {('month', 'day')},
'indexes': [models.Index(fields=['month', 'day'], name='calendarium_month_f02834_idx')],
},
),
]
17 changes: 0 additions & 17 deletions calendarium/migrations/0002_alter_pericope_unique_together.py

This file was deleted.

4 changes: 2 additions & 2 deletions calendarium/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def full_title(self):
return f'{self.title}: {self.subtitle}' if self.subtitle else self.title

class Meta:
index_together = 'month', 'day'
indexes = [models.Index(fields=('month', 'day'))]


class Reading(models.Model):
Expand Down Expand Up @@ -63,7 +63,7 @@ class Reading(models.Model):
flag = models.SmallIntegerField()

class Meta:
index_together = 'month', 'day'
indexes = [models.Index(fields=('month', 'day'))]

async def aget_pericope(self):
# Using self.pericope only works synchronously.
Expand Down
6 changes: 3 additions & 3 deletions orthocal/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
if TESTING:
RATELIMIT_ENABLE = False

WHITENOISE_MAX_AGE = ORTHOCAL_MAX_AGE
SERVESTATIC_MAX_AGE = ORTHOCAL_MAX_AGE
GOOGLE_FONTS = ['EB Garamond:ital@0;1']

# Application definition
Expand Down Expand Up @@ -89,7 +89,7 @@
MIDDLEWARE = [
'orthocal.middleware.request_queueing',
'corsheaders.middleware.CorsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'servestatic.middleware.ServeStaticMiddleware',
'django.middleware.gzip.GZipMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
Expand Down Expand Up @@ -241,7 +241,7 @@

STORAGES = {
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
"BACKEND": "servestatic.storage.CompressedStaticFilesStorage",
},
}

Expand Down
9 changes: 3 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@ django-cors-headers==4.4.0
django-fullurl==1.4
django-google-fonts==0.0.3
django-ninja==1.2.2
django==5.0.7
django==5.1
google-cloud-logging==3.11.0
icalendar==5.0.13
jdcal==1.4.1
Jinja2==3.1.4 # Typogrify imports this even though we're not using it
newrelic==9.12.0
python-dateutil==2.9.0.post0
requests==2.32.3
servestatic[brotli]==1.0.0
typogrify==2.0.7
#uvicorn[standard]==0.29.0 # 0.30.3 new process manager doesn't work with Django
uvicorn[standard]==0.30.5 # 0.30.3 new process manager doesn't work with Django
# We can go back to mainline whitenoise once
# https://github.com/evansd/whitenoise/pull/359 is merged
whitenoise[brotli] @ https://github.com/Archmonger/whitenoise/zipball/asgi-compat
uvicorn[standard]==0.30.5
# oscrypto is a dependency of one of the above packages.
# We can go back to mainline oscrypto once
# https://github.com/wbond/oscrypto/issues/78 is fixed
Expand Down

0 comments on commit 15a166a

Please sign in to comment.