From fe824e0faafef142fe12fc86dd36a0d31e4c6f11 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 6 Apr 2024 18:19:59 -0700 Subject: [PATCH 01/14] Reset dev version string --- src-ui/src/environments/environment.prod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ui/src/environments/environment.prod.ts b/src-ui/src/environments/environment.prod.ts index ce63fcc6e..d64651388 100644 --- a/src-ui/src/environments/environment.prod.ts +++ b/src-ui/src/environments/environment.prod.ts @@ -5,7 +5,7 @@ export const environment = { apiBaseUrl: document.baseURI + 'api/', apiVersion: '5', appTitle: 'Paperless-ngx', - version: '2.7.1', + version: '2.7.1-dev', webSocketHost: window.location.host, webSocketProtocol: window.location.protocol == 'https:' ? 'wss:' : 'ws:', webSocketBaseUrl: base_url.pathname + 'ws/', From 974dd24e693e0ed71c8efacb3d558b12555f56b8 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 08:16:33 -0700 Subject: [PATCH 02/14] Fix: dont initialize page numbers, allow split with browser pdf viewer (#6314) --- .../components/document-detail/document-detail.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 5c5efdc9f..c86976e5f 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 @@ -148,8 +148,8 @@ export class DocumentDetailComponent custom_fields: new FormArray([]), }) - previewCurrentPage: number = 1 - previewNumPages: number = 1 + previewCurrentPage: number + previewNumPages: number previewZoomSetting: ZoomSetting = ZoomSetting.One previewZoomScale: ZoomSetting = ZoomSetting.PageWidth From 654cc05f0e9bfc6b21657aba2556a0779d527c3f Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 10:47:27 -0700 Subject: [PATCH 03/14] Fix: also clear select all checkbox in tasks view --- src-ui/src/app/components/admin/tasks/tasks.component.html | 2 +- src-ui/src/app/components/admin/tasks/tasks.component.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.html b/src-ui/src/app/components/admin/tasks/tasks.component.html index dd5f84d06..4178bb2c8 100644 --- a/src-ui/src/app/components/admin/tasks/tasks.component.html +++ b/src-ui/src/app/components/admin/tasks/tasks.component.html @@ -29,7 +29,7 @@
- +
diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.ts b/src-ui/src/app/components/admin/tasks/tasks.component.ts index b6b5ec590..f1fa56d56 100644 --- a/src-ui/src/app/components/admin/tasks/tasks.component.ts +++ b/src-ui/src/app/components/admin/tasks/tasks.component.ts @@ -18,6 +18,7 @@ export class TasksComponent { public activeTab: string public selectedTasks: Set = new Set() + public togggleAll: boolean = false public expandedTask: number public pageSize: number = 25 @@ -120,6 +121,7 @@ export class TasksComponent } clearSelection() { + this.togggleAll = false this.selectedTasks.clear() } From 622fcf96a02c318abbf03eb1e91da98921cbd6f7 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 11:15:49 -0700 Subject: [PATCH 04/14] Fix: initialize current page to 1 --- .../app/components/document-detail/document-detail.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c86976e5f..16d921e8d 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 @@ -148,7 +148,7 @@ export class DocumentDetailComponent custom_fields: new FormArray([]), }) - previewCurrentPage: number + previewCurrentPage: number = 1 previewNumPages: number previewZoomSetting: ZoomSetting = ZoomSetting.One previewZoomScale: ZoomSetting = ZoomSetting.PageWidth From 1d85caa8d0f0ef0db9f7fa1eb76687dbc1e923aa Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 11:50:40 -0700 Subject: [PATCH 05/14] Fix: disable invalid create endpoints (#6320) --- src/documents/serialisers.py | 23 ++++++++++++++++++----- src/documents/tests/test_api_documents.py | 8 ++++++++ src/documents/views.py | 9 ++++----- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index 777edca6f..f8537726f 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -163,14 +163,23 @@ class SetPermissionsMixin: set_permissions_for_object(permissions, object) -class OwnedObjectSerializer(serializers.ModelSerializer, SetPermissionsMixin): +class SerializerWithPerms(serializers.Serializer): def __init__(self, *args, **kwargs): self.user = kwargs.pop("user", None) - full_perms = kwargs.pop("full_perms", False) + self.full_perms = kwargs.pop("full_perms", False) + super().__init__(*args, **kwargs) + + +class OwnedObjectSerializer( + SerializerWithPerms, + serializers.ModelSerializer, + SetPermissionsMixin, +): + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) try: - if full_perms: + if self.full_perms: self.fields.pop("user_can_change") self.fields.pop("is_shared_by_requester") else: @@ -857,7 +866,11 @@ class DocumentListSerializer(serializers.Serializer): return documents -class BulkEditSerializer(DocumentListSerializer, SetPermissionsMixin): +class BulkEditSerializer( + SerializerWithPerms, + DocumentListSerializer, + SetPermissionsMixin, +): method = serializers.ChoiceField( choices=[ "set_correspondent", @@ -1356,7 +1369,7 @@ class ShareLinkSerializer(OwnedObjectSerializer): return super().create(validated_data) -class BulkEditObjectsSerializer(serializers.Serializer, SetPermissionsMixin): +class BulkEditObjectsSerializer(SerializerWithPerms, SetPermissionsMixin): objects = serializers.ListField( required=True, allow_empty=False, diff --git a/src/documents/tests/test_api_documents.py b/src/documents/tests/test_api_documents.py index 4798fef95..0a94a5677 100644 --- a/src/documents/tests/test_api_documents.py +++ b/src/documents/tests/test_api_documents.py @@ -815,6 +815,14 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase): self.assertIsNone(overrides.document_type_id) self.assertIsNone(overrides.tag_ids) + def test_create_wrong_endpoint(self): + response = self.client.post( + "/api/documents/", + {}, + ) + + self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) + def test_upload_empty_metadata(self): self.consume_file_mock.return_value = celery.result.AsyncResult( id=str(uuid.uuid4()), diff --git a/src/documents/views.py b/src/documents/views.py index 3fcc54023..655108f05 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -55,7 +55,6 @@ from rest_framework.exceptions import NotFound from rest_framework.filters import OrderingFilter from rest_framework.filters import SearchFilter from rest_framework.generics import GenericAPIView -from rest_framework.mixins import CreateModelMixin from rest_framework.mixins import DestroyModelMixin from rest_framework.mixins import ListModelMixin from rest_framework.mixins import RetrieveModelMixin @@ -201,7 +200,7 @@ class IndexView(TemplateView): return context -class PassUserMixin(CreateModelMixin): +class PassUserMixin(GenericAPIView): """ Pass a user object to serializer """ @@ -873,7 +872,7 @@ class SavedViewViewSet(ModelViewSet, PassUserMixin): serializer.save(owner=self.request.user) -class BulkEditView(GenericAPIView, PassUserMixin): +class BulkEditView(PassUserMixin): permission_classes = (IsAuthenticated,) serializer_class = BulkEditSerializer parser_classes = (parsers.JSONParser,) @@ -1450,7 +1449,7 @@ def serve_file(doc: Document, use_archive: bool, disposition: str): return response -class BulkEditObjectsView(GenericAPIView, PassUserMixin): +class BulkEditObjectsView(PassUserMixin): permission_classes = (IsAuthenticated,) serializer_class = BulkEditObjectsSerializer parser_classes = (parsers.JSONParser,) @@ -1582,7 +1581,7 @@ class CustomFieldViewSet(ModelViewSet): queryset = CustomField.objects.all().order_by("-created") -class SystemStatusView(GenericAPIView, PassUserMixin): +class SystemStatusView(PassUserMixin): permission_classes = (IsAuthenticated,) def get(self, request, format=None): From e46f6b11567c16ec2cd13cf3144e8e2ae1d2914c Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 11:55:27 -0700 Subject: [PATCH 06/14] Fix frontend tests warning --- src-ui/src/app/components/admin/tasks/tasks.component.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts b/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts index e452aa0d3..2bed5930c 100644 --- a/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts +++ b/src-ui/src/app/components/admin/tasks/tasks.component.spec.ts @@ -29,6 +29,7 @@ import { PageHeaderComponent } from '../../common/page-header/page-header.compon import { TasksComponent } from './tasks.component' import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' +import { FormsModule } from '@angular/forms' const tasks: PaperlessTask[] = [ { @@ -140,6 +141,7 @@ describe('TasksComponent', () => { HttpClientTestingModule, RouterTestingModule.withRoutes(routes), NgxBootstrapIconsModule.pick(allIcons), + FormsModule, ], }).compileComponents() From 954912cac39eec40ff8b065fbcb0ea6d0e7b820d Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 12:41:08 -0700 Subject: [PATCH 07/14] Update translation strings --- src-ui/messages.xlf | 26 +++++++++---------- .../document-detail.component.ts | 2 +- .../bulk-editor/bulk-editor.component.ts | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 58b0b4ef4..9a709fd83 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -1714,7 +1714,7 @@ src/app/components/admin/tasks/tasks.component.ts - 67 + 68 @@ -1770,56 +1770,56 @@ Dismiss selected src/app/components/admin/tasks/tasks.component.ts - 30 + 31 Dismiss all src/app/components/admin/tasks/tasks.component.ts - 31 + 32 Confirm Dismiss All src/app/components/admin/tasks/tasks.component.ts - 64 + 65 Dismiss all tasks? src/app/components/admin/tasks/tasks.component.ts - 65 + 66 queued src/app/components/admin/tasks/tasks.component.ts - 133 + 135 started src/app/components/admin/tasks/tasks.component.ts - 135 + 137 completed src/app/components/admin/tasks/tasks.component.ts - 137 + 139 failed src/app/components/admin/tasks/tasks.component.ts - 139 + 141 @@ -5508,8 +5508,8 @@ 661 - - This operation will permanently rotate the current document. + + This operation will permanently rotate the original version of the current document. src/app/components/document-detail/document-detail.component.ts 1088 @@ -5808,8 +5808,8 @@ 629 - - This operation will permanently rotate selected document(s). + + This operation will permanently rotate the original version of document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts 662 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 16d921e8d..d8f63faf2 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 @@ -1085,7 +1085,7 @@ export class DocumentDetailComponent backdrop: 'static', }) modal.componentInstance.title = $localize`Rotate confirm` - modal.componentInstance.messageBold = $localize`This operation will permanently rotate the current document.` + modal.componentInstance.messageBold = $localize`This operation will permanently rotate the original version of the current document.` modal.componentInstance.message = $localize`This will alter the original copy.` modal.componentInstance.btnCaption = $localize`Proceed` modal.componentInstance.documentID = this.document.id diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts index 46a4980a6..556a1ff13 100644 --- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts +++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts @@ -659,7 +659,7 @@ export class BulkEditorComponent }) const rotateDialog = modal.componentInstance as RotateConfirmDialogComponent rotateDialog.title = $localize`Rotate confirm` - rotateDialog.messageBold = $localize`This operation will permanently rotate ${this.list.selected.size} selected document(s).` + rotateDialog.messageBold = $localize`This operation will permanently rotate the original version of ${this.list.selected.size} document(s).` rotateDialog.message = $localize`This will alter the original copy.` rotateDialog.btnClass = 'btn-danger' rotateDialog.btnCaption = $localize`Proceed` From 7afc91e7b1c01dec3d2c88ffc650c4fc69e94269 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 13:50:31 -0700 Subject: [PATCH 08/14] Fix: spacing in reset and incorrect display in saved views (#6324) --- .../app/components/document-list/document-list.component.html | 2 +- .../src/app/components/document-list/document-list.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src-ui/src/app/components/document-list/document-list.component.html b/src-ui/src/app/components/document-list/document-list.component.html index 5a52c39c1..1cfa4fff9 100644 --- a/src-ui/src/app/components/document-list/document-list.component.html +++ b/src-ui/src/app/components/document-list/document-list.component.html @@ -99,7 +99,7 @@ @if (list.selected.size === 0) { {list.collectionSize, plural, =1 {One document} other {{{list.collectionSize || 0}} documents}} } @if (isFiltered) { - (filtered) +  (filtered) } } @if (!list.isReloading && isFiltered) { diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts index 147c0272f..fde92973d 100644 --- a/src-ui/src/app/components/document-list/document-list.component.ts +++ b/src-ui/src/app/components/document-list/document-list.component.ts @@ -86,7 +86,7 @@ export class DocumentListComponent } get isFiltered() { - return this.list.filterRules?.length > 0 + return this.filterEditor.rulesModified } getTitle() { From 0b34e70f6cf7d91939f15422212d7ed8ec343d38 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 14:03:15 -0700 Subject: [PATCH 09/14] Fix: select dropdown background colors not visible in light mode (#6323) --- src-ui/src/styles.scss | 5 +++-- src-ui/src/theme.scss | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src-ui/src/styles.scss b/src-ui/src/styles.scss index 5dcf2bf9e..967b416ad 100644 --- a/src-ui/src/styles.scss +++ b/src-ui/src/styles.scss @@ -262,13 +262,14 @@ a.btn-link:focus-visible, } .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-marked { - background-color: var(--pngx-bg-alt) !important; + background-color: var(--pngx-bg-darker) !important; color: var(--pngx-body-color-accent) !important; } .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-selected, .ng-dropdown-panel .ng-dropdown-panel-items .ng-option.ng-option-selected.ng-option-marked { - background: none; + font-weight: bold; + background-color: var(--pngx-bg-alt2) !important; } } diff --git a/src-ui/src/theme.scss b/src-ui/src/theme.scss index 3596f002a..806966ec7 100644 --- a/src-ui/src/theme.scss +++ b/src-ui/src/theme.scss @@ -24,6 +24,7 @@ $color-mode-type: data; --pngx-success-darken-10: hsl(152, 69%, 11%); // based on success #198754 --pngx-bg-alt: #fff; --pngx-bg-darker: var(--bs-gray-100); + --pngx-bg-alt2: var(--bs-gray-200); --pngx-focus-alpha: 0.3; } @@ -78,6 +79,7 @@ $form-check-radio-checked-bg-image-dark: url("data:image/svg+xml, Date: Sun, 7 Apr 2024 15:21:13 -0700 Subject: [PATCH 10/14] Fix navbar-brand width on large screens --- src-ui/src/app/components/app-frame/app-frame.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index 38e4e75a8..b79f99cc0 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -5,7 +5,7 @@ From 579c35a3fe29989a3d1a263417af71ecea8ea5ad Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 15:38:38 -0700 Subject: [PATCH 11/14] Fix: isFiltered check before filter editor init --- .../src/app/components/document-list/document-list.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-ui/src/app/components/document-list/document-list.component.ts b/src-ui/src/app/components/document-list/document-list.component.ts index fde92973d..537e24601 100644 --- a/src-ui/src/app/components/document-list/document-list.component.ts +++ b/src-ui/src/app/components/document-list/document-list.component.ts @@ -86,7 +86,7 @@ export class DocumentListComponent } get isFiltered() { - return this.filterEditor.rulesModified + return !!this.filterEditor?.rulesModified } getTitle() { From 4e5135fe703f81b6284573ead3ee498b8b7f17e3 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 7 Apr 2024 15:41:45 -0700 Subject: [PATCH 12/14] Fix: hide page chooser if not loaded yet --- .../document-detail/document-detail.component.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 82db17edb..aed4d67da 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 @@ -1,10 +1,12 @@ @if (contentRenderType === ContentRenderType.PDF && !useNativePdfViewer) { -
-
Page
- -
of {{previewNumPages}}
-
+ @if (previewNumPages) { +
+
Page
+ +
of {{previewNumPages}}
+
+ }