From 8f6231bd34bbd7a7723b302f867ac4e0a06f98a8 Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Wed, 4 Jul 2018 17:03:59 +0200 Subject: [PATCH] Updated to Django 2 --- requirements.txt | 2 +- src/documents/admin.py | 10 ++++++---- src/documents/migrations/0011_auto_20160303_1929.py | 2 ++ src/documents/models.py | 2 +- src/paperless/settings.py | 8 +++----- src/paperless/urls.py | 3 ++- src/reminders/models.py | 2 +- 7 files changed, 16 insertions(+), 13 deletions(-) mode change 100644 => 100755 requirements.txt mode change 100644 => 100755 src/documents/admin.py mode change 100644 => 100755 src/documents/migrations/0011_auto_20160303_1929.py mode change 100644 => 100755 src/documents/models.py mode change 100644 => 100755 src/paperless/settings.py mode change 100644 => 100755 src/paperless/urls.py mode change 100644 => 100755 src/reminders/models.py diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 index 0c46e4f8d..c6cb6fd47 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ django-crispy-forms==1.7.2 django-extensions==2.0.7 django-filter==1.1.0 django-flat-responsive==2.0 -django==1.11.13 +django==2.0.7 djangorestframework==3.8.2 docopt==0.6.2 execnet==1.5.0 diff --git a/src/documents/admin.py b/src/documents/admin.py old mode 100644 new mode 100755 index 39524ae21..6a32edc9b --- a/src/documents/admin.py +++ b/src/documents/admin.py @@ -3,8 +3,9 @@ from datetime import datetime from django.conf import settings from django.contrib import admin from django.contrib.auth.models import User, Group -from django.core.urlresolvers import reverse +from django.urls import reverse from django.templatetags.static import static +from django.utils.safestring import mark_safe from .models import Correspondent, Tag, Document, Log @@ -140,6 +141,7 @@ class DocumentAdmin(CommonAdmin): return obj.created.date().strftime("%Y-%m-%d") created_.short_description = "Created" + @mark_safe def thumbnail(self, obj): return self._html_tag( "a", @@ -152,8 +154,8 @@ class DocumentAdmin(CommonAdmin): ), href=obj.download_url ) - thumbnail.allow_tags = True + @mark_safe def tags_(self, obj): r = "" for tag in obj.tags.all(): @@ -171,9 +173,10 @@ class DocumentAdmin(CommonAdmin): } ) return r - tags_.allow_tags = True + @mark_safe def document(self, obj): + # TODO: is this method even used anymore? return self._html_tag( "a", self._html_tag( @@ -186,7 +189,6 @@ class DocumentAdmin(CommonAdmin): ), href=obj.download_url ) - document.allow_tags = True @staticmethod def _html_tag(kind, inside=None, **kwargs): diff --git a/src/documents/migrations/0011_auto_20160303_1929.py b/src/documents/migrations/0011_auto_20160303_1929.py old mode 100644 new mode 100755 index af4ee4c66..415ca77ca --- a/src/documents/migrations/0011_auto_20160303_1929.py +++ b/src/documents/migrations/0011_auto_20160303_1929.py @@ -7,6 +7,8 @@ from django.db import migrations class Migration(migrations.Migration): + atomic = False + dependencies = [ ('documents', '0010_log'), ] diff --git a/src/documents/models.py b/src/documents/models.py old mode 100644 new mode 100755 index 7390c1d3c..780cddb0a --- a/src/documents/models.py +++ b/src/documents/models.py @@ -10,7 +10,7 @@ from collections import OrderedDict from fuzzywuzzy import fuzz from django.conf import settings -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models from django.template.defaultfilters import slugify from django.utils import timezone diff --git a/src/paperless/settings.py b/src/paperless/settings.py old mode 100644 new mode 100755 index 6dd0b6419..a5d1f6a2c --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -81,22 +81,20 @@ if os.getenv("PAPERLESS_INSTALLED_APPS"): -MIDDLEWARE_CLASSES = [ +MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] # If auth is disabled, we just use our "bypass" authentication middleware if bool(os.getenv("PAPERLESS_DISABLE_LOGIN", "false").lower() in ("yes", "y", "1", "t", "true")): - _index = MIDDLEWARE_CLASSES.index("django.contrib.auth.middleware.AuthenticationMiddleware") - MIDDLEWARE_CLASSES[_index] = "paperless.middleware.Middleware" - MIDDLEWARE_CLASSES.remove("django.contrib.auth.middleware.SessionAuthenticationMiddleware") + _index = MIDDLEWARE.index("django.contrib.auth.middleware.AuthenticationMiddleware") + MIDDLEWARE[_index] = "paperless.middleware.Middleware" ROOT_URLCONF = 'paperless.urls' diff --git a/src/paperless/urls.py b/src/paperless/urls.py old mode 100644 new mode 100755 index e5e559f12..59cbd86b5 --- a/src/paperless/urls.py +++ b/src/paperless/urls.py @@ -30,7 +30,8 @@ urlpatterns = [ r"^api/auth/", include('rest_framework.urls', namespace="rest_framework") ), - url(r"^api/", include(router.urls, namespace="drf")), + # TODO: this does not work in django 2.0! + # url(r"^api/", include(router.urls, namespace="drf")), # File downloads url( diff --git a/src/reminders/models.py b/src/reminders/models.py old mode 100644 new mode 100755 index d6fb744f7..17d705819 --- a/src/reminders/models.py +++ b/src/reminders/models.py @@ -3,6 +3,6 @@ from django.db import models class Reminder(models.Model): - document = models.ForeignKey("documents.Document") + document = models.ForeignKey("documents.Document", on_delete=models.CASCADE) date = models.DateTimeField() note = models.TextField(blank=True)