From 765e27f719a1f46343d7a492848b73445a18c341 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Aug 2022 22:05:32 -0700 Subject: [PATCH] Cleanup frontend comment service & other code [ci skip] --- .../document-comments/document-comments.component.html | 7 +++---- .../document-detail/document-detail.component.html | 1 - .../document-detail/document-detail.component.ts | 1 - src-ui/src/app/data/paperless-document-comment.ts | 10 +++++----- src-ui/src/app/data/user-type.ts | 7 ------- src-ui/src/app/data/user.ts | 7 +++++++ .../src/app/services/rest/document-comments.service.ts | 6 ++---- src/documents/views.py | 4 ++-- src/paperless/settings.py | 1 + 9 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 src-ui/src/app/data/user-type.ts create mode 100644 src-ui/src/app/data/user.ts diff --git a/src-ui/src/app/components/document-comments/document-comments.component.html b/src-ui/src/app/components/document-comments/document-comments.component.html index 055c97552..107d02623 100644 --- a/src-ui/src/app/components/document-comments/document-comments.component.html +++ b/src-ui/src/app/components/document-comments/document-comments.component.html @@ -4,11 +4,10 @@

{{comment.comment}}

diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index 8e7176655..8481cad2f 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -174,7 +174,6 @@ - diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index 06fddd41b..ff0a5303b 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -274,7 +274,6 @@ export class DocumentDetailComponent this.suggestions = null }, }) - this.title = this.documentTitlePipe.transform(doc.title) this.documentForm.patchValue(doc) } diff --git a/src-ui/src/app/data/paperless-document-comment.ts b/src-ui/src/app/data/paperless-document-comment.ts index 1b60e6c5c..14085cf32 100644 --- a/src-ui/src/app/data/paperless-document-comment.ts +++ b/src-ui/src/app/data/paperless-document-comment.ts @@ -1,8 +1,8 @@ import { ObjectWithId } from './object-with-id' -import { CommentUser } from './user-type' +import { User } from './user' export interface PaperlessDocumentComment extends ObjectWithId { - created?: Date - comment?: string - user?: CommentUser -} \ No newline at end of file + created?: Date + comment?: string + user?: User +} diff --git a/src-ui/src/app/data/user-type.ts b/src-ui/src/app/data/user-type.ts deleted file mode 100644 index 9324cab43..000000000 --- a/src-ui/src/app/data/user-type.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { ObjectWithId } from './object-with-id' - -export interface CommentUser extends ObjectWithId { - username: string - firstname: string - lastname: string -} \ No newline at end of file diff --git a/src-ui/src/app/data/user.ts b/src-ui/src/app/data/user.ts new file mode 100644 index 000000000..adf00e86b --- /dev/null +++ b/src-ui/src/app/data/user.ts @@ -0,0 +1,7 @@ +import { ObjectWithId } from './object-with-id' + +export interface User extends ObjectWithId { + username: string + firstname: string + lastname: string +} diff --git a/src-ui/src/app/services/rest/document-comments.service.ts b/src-ui/src/app/services/rest/document-comments.service.ts index b105a90d1..a697c0e93 100644 --- a/src-ui/src/app/services/rest/document-comments.service.ts +++ b/src-ui/src/app/services/rest/document-comments.service.ts @@ -21,7 +21,7 @@ export class DocumentCommentsService extends AbstractPaperlessService { return this.http.post( this.getResourceUrl(id, 'comments'), - { payload: comment } + { comment: comment } ) } @@ -29,11 +29,9 @@ export class DocumentCommentsService extends AbstractPaperlessService { - let httpParams = new HttpParams() - httpParams = httpParams.set('commentId', commentId.toString()) return this.http.delete( this.getResourceUrl(documentId, 'comments'), - { params: httpParams } + { params: new HttpParams({ fromString: `id=${commentId}` }) } ) } } diff --git a/src/documents/views.py b/src/documents/views.py index 41f652905..b9c8a1265 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -414,7 +414,7 @@ class DocumentViewSet( try: c = Comment.objects.create( document=doc, - comment=request.data["payload"], + comment=request.data["comment"], user=currentUser, ) c.save() @@ -427,7 +427,7 @@ class DocumentViewSet( }, ) elif request.method == "DELETE": - comment = Comment.objects.get(id=int(request.GET.get("commentId"))) + comment = Comment.objects.get(id=int(request.GET.get("id"))) comment.delete() return Response(self.getComments(doc)) diff --git a/src/paperless/settings.py b/src/paperless/settings.py index bfa498359..2ce99ac0e 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -566,6 +566,7 @@ CONVERT_MEMORY_LIMIT = os.getenv("PAPERLESS_CONVERT_MEMORY_LIMIT") GS_BINARY = os.getenv("PAPERLESS_GS_BINARY", "gs") + # Pre-2.x versions of Paperless stored your documents locally with GPG # encryption, but that is no longer the default. This behaviour is still # available, but it must be explicitly enabled by setting