From b452816a29791e31c531035c76ff15a8b15de514 Mon Sep 17 00:00:00 2001
From: jonaswinkler
Date: Fri, 11 Dec 2020 17:49:32 +0100
Subject: [PATCH 1/2] fixes #122
---
docs/configuration.rst | 10 ++++++++++
paperless.conf.example | 1 +
src/paperless/settings.py | 6 ++++++
3 files changed, 17 insertions(+)
diff --git a/docs/configuration.rst b/docs/configuration.rst
index 2ec34f803..d3f47215b 100644
--- a/docs/configuration.rst
+++ b/docs/configuration.rst
@@ -152,6 +152,16 @@ PAPERLESS_AUTO_LOGIN_USERNAME=
Defaults to none, which disables this feature.
+
+PAPERLESS_COOKIE_PREFIX=
+ Specify a prefix that is added to the cookies used by paperless to identify
+ the currently logged in user. This is useful for when you're running two
+ instances of paperless on the same host.
+
+ After changing this, you will have to login again.
+
+ Defaults to ``""``, which does not alter the cookie names.
+
.. _configuration-ocr:
OCR settings
diff --git a/paperless.conf.example b/paperless.conf.example
index 32c0e56b4..910fc22a0 100644
--- a/paperless.conf.example
+++ b/paperless.conf.example
@@ -30,6 +30,7 @@
#PAPERLESS_FORCE_SCRIPT_NAME=
#PAPERLESS_STATIC_URL=/static/
#PAPERLESS_AUTO_LOGIN_USERNAME=
+#PAPERLESS_COOKIE_PREFIX=
# OCR settings
diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index cf0c3e28d..1a6b80a0c 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -210,6 +210,12 @@ AUTH_PASSWORD_VALIDATORS = [
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
+COOKIE_PREFIX = os.getenv("PAPERLESS_COOKIE_PREFIX", "")
+
+CSRF_COOKIE_NAME = f"{COOKIE_PREFIX}csrftoken"
+SESSION_COOKIE_NAME = f"{COOKIE_PREFIX}sessionid"
+LANGUAGE_COOKIE_NAME = f"{COOKIE_PREFIX}django_language"
+
###############################################################################
# Database #
###############################################################################
From 0b7ffa31d1f3953a37314555823a396d4241b922 Mon Sep 17 00:00:00 2001
From: jonaswinkler
Date: Fri, 11 Dec 2020 17:57:56 +0100
Subject: [PATCH 2/2] fixes #115
---
src-ui/src/app/app.module.ts | 4 +++-
.../document-card-large.component.html | 2 +-
.../document-card-small.component.html | 2 +-
.../document-list/document-list.component.html | 2 +-
src-ui/src/app/pipes/document-title.pipe.spec.ts | 8 ++++++++
src-ui/src/app/pipes/document-title.pipe.ts | 16 ++++++++++++++++
6 files changed, 30 insertions(+), 4 deletions(-)
create mode 100644 src-ui/src/app/pipes/document-title.pipe.spec.ts
create mode 100644 src-ui/src/app/pipes/document-title.pipe.ts
diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts
index ad12c9c47..675c882a7 100644
--- a/src-ui/src/app/app.module.ts
+++ b/src-ui/src/app/app.module.ts
@@ -48,6 +48,7 @@ import { WidgetFrameComponent } from './components/dashboard/widgets/widget-fram
import { WelcomeWidgetComponent } from './components/dashboard/widgets/welcome-widget/welcome-widget.component';
import { YesNoPipe } from './pipes/yes-no.pipe';
import { FileSizePipe } from './pipes/file-size.pipe';
+import { DocumentTitlePipe } from './pipes/document-title.pipe';
@NgModule({
declarations: [
@@ -88,7 +89,8 @@ import { FileSizePipe } from './pipes/file-size.pipe';
WidgetFrameComponent,
WelcomeWidgetComponent,
YesNoPipe,
- FileSizePipe
+ FileSizePipe,
+ DocumentTitlePipe
],
imports: [
BrowserModule,
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html
index bfc59b526..8f3fced66 100644
--- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html
+++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.html
@@ -12,7 +12,7 @@
{{(document.correspondent$ | async)?.name}}
{{(document.correspondent$ | async)?.name}}:
- {{document.title}}
+ {{document.title | documentTitle}}
#{{document.archive_serial_number}}
diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html
index da469ebc4..86e28442c 100644
--- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html
+++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.html
@@ -17,7 +17,7 @@
{{(document.correspondent$ | async)?.name}}:
- {{document.title}}
+ {{document.title | documentTitle}}