mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Prepare Paperless for new front end
- enable CORS for localhost calls - add Filter to allow API calls that can select Documents without any tag
This commit is contained in:
parent
c79583dedb
commit
96268655d2
@ -5,6 +5,7 @@ chardet==3.0.4
|
|||||||
coverage==4.5.1
|
coverage==4.5.1
|
||||||
coveralls==1.3.0
|
coveralls==1.3.0
|
||||||
dateparser==0.7.0
|
dateparser==0.7.0
|
||||||
|
django-cors-headers=2.4.0
|
||||||
django-crispy-forms==1.7.2
|
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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from django_filters.rest_framework import CharFilter, FilterSet
|
from django_filters.rest_framework import CharFilter, FilterSet, BooleanFilter
|
||||||
|
|
||||||
from .models import Correspondent, Document, Tag
|
from .models import Correspondent, Document, Tag
|
||||||
|
|
||||||
@ -46,6 +46,7 @@ class DocumentFilterSet(FilterSet):
|
|||||||
correspondent__slug = CharFilter(name="correspondent__slug", **CHAR_KWARGS)
|
correspondent__slug = CharFilter(name="correspondent__slug", **CHAR_KWARGS)
|
||||||
tags__name = CharFilter(name="tags__name", **CHAR_KWARGS)
|
tags__name = CharFilter(name="tags__name", **CHAR_KWARGS)
|
||||||
tags__slug = CharFilter(name="tags__slug", **CHAR_KWARGS)
|
tags__slug = CharFilter(name="tags__slug", **CHAR_KWARGS)
|
||||||
|
tags__empty = BooleanFilter(name='tags', lookup_expr='isnull', distinct=True)
|
||||||
|
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
model = Document
|
model = Document
|
||||||
|
@ -61,6 +61,7 @@ INSTALLED_APPS = [
|
|||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
|
|
||||||
|
"corsheaders",
|
||||||
"django_extensions",
|
"django_extensions",
|
||||||
|
|
||||||
"documents.apps.DocumentsConfig",
|
"documents.apps.DocumentsConfig",
|
||||||
@ -84,6 +85,7 @@ if os.getenv("PAPERLESS_INSTALLED_APPS"):
|
|||||||
MIDDLEWARE_CLASSES = [
|
MIDDLEWARE_CLASSES = [
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
'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',
|
||||||
@ -92,6 +94,9 @@ MIDDLEWARE_CLASSES = [
|
|||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# We allow CORS from localhosts
|
||||||
|
CORS_ORIGIN_REGEX_WHITELIST = (r'^(https?:\/\/)?localhost(:[0-9]{4})?$', )
|
||||||
|
|
||||||
# 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_CLASSES.index("django.contrib.auth.middleware.AuthenticationMiddleware")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user