Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
Merge 70608f7 into c79583d
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaszSolo committed Aug 17, 2018
2 parents c79583d + 70608f7 commit 75f5bca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions paperless.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ PAPERLESS_EMAIL_SECRET=""
# as is "example.com,www.example.com", but NOT " example.com" or "example.com,"
#PAPERLESS_ALLOWED_HOSTS="example.com,www.example.com"

# If you decide to use Paperless APIs in an ajax calls, you need to add your
# servers to the allowed hosts that can do CORS calls. By default Paperless allows
# calls from localhost:8080. The same rules as above how the list should look like.
#PAPERLESS_CORS_ALLOWED_HOSTS="localhost:8080,example.com,localhost:8000"

# To host paperless under a subpath url like example.com/paperless you set
# this value to /paperless. No trailing slash!
#
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ chardet==3.0.4
coverage==4.5.1
coveralls==1.3.0
dateparser==0.7.0
django-cors-headers==2.4.0
django-crispy-forms==1.7.2
django-extensions==2.0.7
django-filter==1.1.0
Expand Down
5 changes: 4 additions & 1 deletion src/documents/filters.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -46,6 +46,9 @@ class DocumentFilterSet(FilterSet):
correspondent__slug = CharFilter(name="correspondent__slug", **CHAR_KWARGS)
tags__name = CharFilter(name="tags__name", **CHAR_KWARGS)
tags__slug = CharFilter(name="tags__slug", **CHAR_KWARGS)
tags__empty = BooleanFilter(name='tags',
lookup_expr='isnull',
distinct=True)

class Meta(object):
model = Document
Expand Down
5 changes: 5 additions & 0 deletions src/paperless/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"django.contrib.messages",
"django.contrib.staticfiles",

"corsheaders",
"django_extensions",

"documents.apps.DocumentsConfig",
Expand All @@ -84,6 +85,7 @@
MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
Expand All @@ -92,6 +94,9 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

# We allow CORS from localhost:8080
CORS_ORIGIN_WHITELIST = tuple(os.getenv("PAPERLESS_CORS_ALLOWED_HOSTS", "localhost:8080").split(","))

# 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")
Expand Down

0 comments on commit 75f5bca

Please sign in to comment.