mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Updated to Django 2
This commit is contained in:
parent
f3654310bd
commit
8f6231bd34
2
requirements.txt
Normal file → Executable file
2
requirements.txt
Normal file → Executable file
@ -9,7 +9,7 @@ django-crispy-forms==1.7.2
|
|||||||
django-extensions==2.0.7
|
django-extensions==2.0.7
|
||||||
django-filter==1.1.0
|
django-filter==1.1.0
|
||||||
django-flat-responsive==2.0
|
django-flat-responsive==2.0
|
||||||
django==1.11.13
|
django==2.0.7
|
||||||
djangorestframework==3.8.2
|
djangorestframework==3.8.2
|
||||||
docopt==0.6.2
|
docopt==0.6.2
|
||||||
execnet==1.5.0
|
execnet==1.5.0
|
||||||
|
10
src/documents/admin.py
Normal file → Executable file
10
src/documents/admin.py
Normal file → Executable file
@ -3,8 +3,9 @@ from datetime import datetime
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.models import User, Group
|
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.templatetags.static import static
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from .models import Correspondent, Tag, Document, Log
|
from .models import Correspondent, Tag, Document, Log
|
||||||
|
|
||||||
@ -140,6 +141,7 @@ class DocumentAdmin(CommonAdmin):
|
|||||||
return obj.created.date().strftime("%Y-%m-%d")
|
return obj.created.date().strftime("%Y-%m-%d")
|
||||||
created_.short_description = "Created"
|
created_.short_description = "Created"
|
||||||
|
|
||||||
|
@mark_safe
|
||||||
def thumbnail(self, obj):
|
def thumbnail(self, obj):
|
||||||
return self._html_tag(
|
return self._html_tag(
|
||||||
"a",
|
"a",
|
||||||
@ -152,8 +154,8 @@ class DocumentAdmin(CommonAdmin):
|
|||||||
),
|
),
|
||||||
href=obj.download_url
|
href=obj.download_url
|
||||||
)
|
)
|
||||||
thumbnail.allow_tags = True
|
|
||||||
|
|
||||||
|
@mark_safe
|
||||||
def tags_(self, obj):
|
def tags_(self, obj):
|
||||||
r = ""
|
r = ""
|
||||||
for tag in obj.tags.all():
|
for tag in obj.tags.all():
|
||||||
@ -171,9 +173,10 @@ class DocumentAdmin(CommonAdmin):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
return r
|
return r
|
||||||
tags_.allow_tags = True
|
|
||||||
|
|
||||||
|
@mark_safe
|
||||||
def document(self, obj):
|
def document(self, obj):
|
||||||
|
# TODO: is this method even used anymore?
|
||||||
return self._html_tag(
|
return self._html_tag(
|
||||||
"a",
|
"a",
|
||||||
self._html_tag(
|
self._html_tag(
|
||||||
@ -186,7 +189,6 @@ class DocumentAdmin(CommonAdmin):
|
|||||||
),
|
),
|
||||||
href=obj.download_url
|
href=obj.download_url
|
||||||
)
|
)
|
||||||
document.allow_tags = True
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _html_tag(kind, inside=None, **kwargs):
|
def _html_tag(kind, inside=None, **kwargs):
|
||||||
|
2
src/documents/migrations/0011_auto_20160303_1929.py
Normal file → Executable file
2
src/documents/migrations/0011_auto_20160303_1929.py
Normal file → Executable file
@ -7,6 +7,8 @@ from django.db import migrations
|
|||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
atomic = False
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('documents', '0010_log'),
|
('documents', '0010_log'),
|
||||||
]
|
]
|
||||||
|
2
src/documents/models.py
Normal file → Executable file
2
src/documents/models.py
Normal file → Executable file
@ -10,7 +10,7 @@ from collections import OrderedDict
|
|||||||
from fuzzywuzzy import fuzz
|
from fuzzywuzzy import fuzz
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.urlresolvers import reverse
|
from django.urls import reverse
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
8
src/paperless/settings.py
Normal file → Executable file
8
src/paperless/settings.py
Normal file → Executable file
@ -81,22 +81,20 @@ if os.getenv("PAPERLESS_INSTALLED_APPS"):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = [
|
MIDDLEWARE = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
# If auth is disabled, we just use our "bypass" authentication middleware
|
# 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")):
|
if bool(os.getenv("PAPERLESS_DISABLE_LOGIN", "false").lower() in ("yes", "y", "1", "t", "true")):
|
||||||
_index = MIDDLEWARE_CLASSES.index("django.contrib.auth.middleware.AuthenticationMiddleware")
|
_index = MIDDLEWARE.index("django.contrib.auth.middleware.AuthenticationMiddleware")
|
||||||
MIDDLEWARE_CLASSES[_index] = "paperless.middleware.Middleware"
|
MIDDLEWARE[_index] = "paperless.middleware.Middleware"
|
||||||
MIDDLEWARE_CLASSES.remove("django.contrib.auth.middleware.SessionAuthenticationMiddleware")
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'paperless.urls'
|
ROOT_URLCONF = 'paperless.urls'
|
||||||
|
|
||||||
|
3
src/paperless/urls.py
Normal file → Executable file
3
src/paperless/urls.py
Normal file → Executable file
@ -30,7 +30,8 @@ urlpatterns = [
|
|||||||
r"^api/auth/",
|
r"^api/auth/",
|
||||||
include('rest_framework.urls', namespace="rest_framework")
|
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
|
# File downloads
|
||||||
url(
|
url(
|
||||||
|
2
src/reminders/models.py
Normal file → Executable file
2
src/reminders/models.py
Normal file → Executable file
@ -3,6 +3,6 @@ from django.db import models
|
|||||||
|
|
||||||
class Reminder(models.Model):
|
class Reminder(models.Model):
|
||||||
|
|
||||||
document = models.ForeignKey("documents.Document")
|
document = models.ForeignKey("documents.Document", on_delete=models.CASCADE)
|
||||||
date = models.DateTimeField()
|
date = models.DateTimeField()
|
||||||
note = models.TextField(blank=True)
|
note = models.TextField(blank=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user