From 89e14fd49bba82f5875cce0399cf5d3b3a4bf5fe Mon Sep 17 00:00:00 2001 From: "otxtan@gmail.com" Date: Wed, 29 May 2024 15:50:06 +0700 Subject: [PATCH 1/2] update model,index --- .env | 16 ++++++++-------- src/documents/index.py | 11 ++++++----- src/documents/models.py | 7 +++++++ src/documents/views.py | 16 +++++++++++----- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/.env b/.env index 475fed8f2..e943f5e33 100644 --- a/.env +++ b/.env @@ -1,15 +1,15 @@ COMPOSE_PROJECT_NAME=paperless PAPERLESS_DEBUG=true -# PAPERLESS_REDIS=redis://localhost:6379 -PAPERLESS_REDIS=redis://:@123bytech@172.16.100.203:9377 +PAPERLESS_REDIS=redis://localhost:6379 +# PAPERLESS_REDIS=redis://:@123bytech@172.16.100.203:9377 -PAPERLESS_DBHOST=172.16.100.203 -PAPERLESS_DBPORT=5432 -PAPERLESS_DBNAME=tc_edoc -PAPERLESS_DBUSER=tc_edoc -PAPERLESS_DBPASS=27M2MV58Re2Y -PAPERLESS_DBSSLMODE=prefer +# PAPERLESS_DBHOST=172.16.100.203 +# PAPERLESS_DBPORT=5432 +# PAPERLESS_DBNAME=tc_edoc +# PAPERLESS_DBUSER=tc_edoc +# PAPERLESS_DBPASS=27M2MV58Re2Y +# PAPERLESS_DBSSLMODE=prefer URL_UPLOAD_FILE=https://ocr-core-api.tcgroup.vn/api/v1/file/upload diff --git a/src/documents/index.py b/src/documents/index.py index 388b994d8..71b9b8097 100644 --- a/src/documents/index.py +++ b/src/documents/index.py @@ -484,9 +484,10 @@ def get_permissions_criterias(user: Optional[User] = None): if user is not None: if user.is_superuser: # superusers see all docs user_criterias = [] - else: - user_criterias.append(query.Term("owner_id", user.id)) - user_criterias.append( - query.Term("viewer_id", str(user.id)), - ) + # else: + # user_criterias.append(query.Term("owner_id", user.id)) + # user_criterias.append( + # query.Term("viewer_id", str(user.id)), + # ) + user_criterias = [] return user_criterias diff --git a/src/documents/models.py b/src/documents/models.py index 515557947..ad39afde8 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -1018,6 +1018,13 @@ class WorkflowTrigger(models.Model): verbose_name=_("has this correspondent"), ) + filter_has_group = models.ManyToManyField( + Group, + null=True, + blank=True, + verbose_name=_("has these groups"), + ) + class Meta: verbose_name = _("workflow trigger") verbose_name_plural = _("workflow triggers") diff --git a/src/documents/views.py b/src/documents/views.py index d7995c5b3..43fe81584 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -562,12 +562,18 @@ class DocumentViewSet( def thumb(self, request, pk=None): try: doc = Document.objects.get(id=pk) - if request.user is not None and not has_perms_owner_aware( - request.user, - "view_document", - doc, - ): + # Allow all users to view thumbnails + if request.user is None: return HttpResponseForbidden("Insufficient permissions") + + # Original + # if request.user is not None and not has_perms_owner_aware( + # request.user, + # "view_document", + # doc, + # ): + # return HttpResponseForbidden("Insufficient permissions") + if doc.storage_type == Document.STORAGE_TYPE_GPG: handle = GnuPG.decrypted(doc.thumbnail_file) else: From f190aaf589c5bc3608db6cb756a659d34e9d6146 Mon Sep 17 00:00:00 2001 From: "otxtan@gmail.com" Date: Wed, 29 May 2024 15:56:39 +0700 Subject: [PATCH 2/2] update config --- .env | 16 ++++++++-------- src/documents/models.py | 7 ------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.env b/.env index e943f5e33..475fed8f2 100644 --- a/.env +++ b/.env @@ -1,15 +1,15 @@ COMPOSE_PROJECT_NAME=paperless PAPERLESS_DEBUG=true -PAPERLESS_REDIS=redis://localhost:6379 -# PAPERLESS_REDIS=redis://:@123bytech@172.16.100.203:9377 +# PAPERLESS_REDIS=redis://localhost:6379 +PAPERLESS_REDIS=redis://:@123bytech@172.16.100.203:9377 -# PAPERLESS_DBHOST=172.16.100.203 -# PAPERLESS_DBPORT=5432 -# PAPERLESS_DBNAME=tc_edoc -# PAPERLESS_DBUSER=tc_edoc -# PAPERLESS_DBPASS=27M2MV58Re2Y -# PAPERLESS_DBSSLMODE=prefer +PAPERLESS_DBHOST=172.16.100.203 +PAPERLESS_DBPORT=5432 +PAPERLESS_DBNAME=tc_edoc +PAPERLESS_DBUSER=tc_edoc +PAPERLESS_DBPASS=27M2MV58Re2Y +PAPERLESS_DBSSLMODE=prefer URL_UPLOAD_FILE=https://ocr-core-api.tcgroup.vn/api/v1/file/upload diff --git a/src/documents/models.py b/src/documents/models.py index ad39afde8..515557947 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -1018,13 +1018,6 @@ class WorkflowTrigger(models.Model): verbose_name=_("has this correspondent"), ) - filter_has_group = models.ManyToManyField( - Group, - null=True, - blank=True, - verbose_name=_("has these groups"), - ) - class Meta: verbose_name = _("workflow trigger") verbose_name_plural = _("workflow triggers")