From 7608ef928aa22f207be868a9d24c6ece8544dab3 Mon Sep 17 00:00:00 2001 From: winkidney Date: Fri, 17 Jul 2020 13:42:35 +0800 Subject: [PATCH] Fix: Try to migrate middlware to new version --- core/migrations/0001_initial.py | 4 ++-- django_images/migrations/0001_initial.py | 2 +- pinry/middleware.py | 4 ++++ users/middleware.py | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index aa7b8d6..73d3810 100644 --- a/core/migrations/0001_initial.py +++ b/core/migrations/0001_initial.py @@ -36,12 +36,12 @@ class Migration(migrations.Migration): migrations.AddField( model_name='pin', name='image', - field=models.ForeignKey(related_name='pin', to='core.Image'), + field=models.ForeignKey(related_name='pin', to='core.Image', on_delete=models.CASCADE), ), migrations.AddField( model_name='pin', name='submitter', - field=models.ForeignKey(to='users.User'), + field=models.ForeignKey(to='users.User', on_delete=models.CASCADE), ), migrations.AddField( model_name='pin', diff --git a/django_images/migrations/0001_initial.py b/django_images/migrations/0001_initial.py index e3f0f84..ac95ca6 100644 --- a/django_images/migrations/0001_initial.py +++ b/django_images/migrations/0001_initial.py @@ -28,7 +28,7 @@ class Migration(migrations.Migration): ('size', models.CharField(max_length=100)), ('height', models.PositiveIntegerField(default=0, editable=False)), ('width', models.PositiveIntegerField(default=0, editable=False)), - ('original', models.ForeignKey(to='django_images.Image')), + ('original', models.ForeignKey(to='django_images.Image', on_delete=models.CASCADE)), ], ), migrations.AlterUniqueTogether( diff --git a/pinry/middleware.py b/pinry/middleware.py index d3471ef..05e640d 100644 --- a/pinry/middleware.py +++ b/pinry/middleware.py @@ -2,6 +2,10 @@ from django.middleware.csrf import get_token class ForceCSRFCookieMiddleware: + + def __init__(self, get_response): + self.get_response = get_response + def process_request(self, request): if "CSRF_TOKEN" not in request.META: get_token(request) diff --git a/users/middleware.py b/users/middleware.py index 93f5daa..d3eab24 100644 --- a/users/middleware.py +++ b/users/middleware.py @@ -2,12 +2,15 @@ from django.conf import settings from django.http import HttpResponseForbidden -class Public(object): +class Public: acceptable_paths = ( "/api/v2/profile/", ) + def __init__(self, get_response): + self.get_response = get_response + def process_request(self, request): if settings.PUBLIC is False and not request.user.is_authenticated(): for path in self.acceptable_paths: