update model,index

This commit is contained in:
otxtan@gmail.com
2024-05-29 15:50:06 +07:00
parent 8a4f809d83
commit 89e14fd49b
4 changed files with 32 additions and 18 deletions

16
.env
View File

@@ -1,15 +1,15 @@
COMPOSE_PROJECT_NAME=paperless COMPOSE_PROJECT_NAME=paperless
PAPERLESS_DEBUG=true PAPERLESS_DEBUG=true
# PAPERLESS_REDIS=redis://localhost:6379 PAPERLESS_REDIS=redis://localhost:6379
PAPERLESS_REDIS=redis://:@123bytech@172.16.100.203:9377 # PAPERLESS_REDIS=redis://:@123bytech@172.16.100.203:9377
PAPERLESS_DBHOST=172.16.100.203 # PAPERLESS_DBHOST=172.16.100.203
PAPERLESS_DBPORT=5432 # PAPERLESS_DBPORT=5432
PAPERLESS_DBNAME=tc_edoc # PAPERLESS_DBNAME=tc_edoc
PAPERLESS_DBUSER=tc_edoc # PAPERLESS_DBUSER=tc_edoc
PAPERLESS_DBPASS=27M2MV58Re2Y # PAPERLESS_DBPASS=27M2MV58Re2Y
PAPERLESS_DBSSLMODE=prefer # PAPERLESS_DBSSLMODE=prefer
URL_UPLOAD_FILE=https://ocr-core-api.tcgroup.vn/api/v1/file/upload URL_UPLOAD_FILE=https://ocr-core-api.tcgroup.vn/api/v1/file/upload

View File

@@ -484,9 +484,10 @@ def get_permissions_criterias(user: Optional[User] = None):
if user is not None: if user is not None:
if user.is_superuser: # superusers see all docs if user.is_superuser: # superusers see all docs
user_criterias = [] user_criterias = []
else: # else:
user_criterias.append(query.Term("owner_id", user.id)) # user_criterias.append(query.Term("owner_id", user.id))
user_criterias.append( # user_criterias.append(
query.Term("viewer_id", str(user.id)), # query.Term("viewer_id", str(user.id)),
) # )
user_criterias = []
return user_criterias return user_criterias

View File

@@ -1018,6 +1018,13 @@ class WorkflowTrigger(models.Model):
verbose_name=_("has this correspondent"), verbose_name=_("has this correspondent"),
) )
filter_has_group = models.ManyToManyField(
Group,
null=True,
blank=True,
verbose_name=_("has these groups"),
)
class Meta: class Meta:
verbose_name = _("workflow trigger") verbose_name = _("workflow trigger")
verbose_name_plural = _("workflow triggers") verbose_name_plural = _("workflow triggers")

View File

@@ -562,12 +562,18 @@ class DocumentViewSet(
def thumb(self, request, pk=None): def thumb(self, request, pk=None):
try: try:
doc = Document.objects.get(id=pk) doc = Document.objects.get(id=pk)
if request.user is not None and not has_perms_owner_aware( # Allow all users to view thumbnails
request.user, if request.user is None:
"view_document",
doc,
):
return HttpResponseForbidden("Insufficient permissions") 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: if doc.storage_type == Document.STORAGE_TYPE_GPG:
handle = GnuPG.decrypted(doc.thumbnail_file) handle = GnuPG.decrypted(doc.thumbnail_file)
else: else: