forked from mayan-edms/Mayan-EDMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix layer exclusion for priority value of 0
This fixes the preview layer priority when editing the redactions of pages that also contain transformations in other layers. Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
- Loading branch information
Roberto Rosario
committed
Aug 4, 2021
1 parent
ed3f53d
commit 9f6151a
Showing
8 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+335 Bytes
mayan/apps/redactions/tests/contrib/sample_documents/black_upper_left_corner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,12 @@ | ||
import os | ||
|
||
from django.conf import settings | ||
|
||
TEST_REDACTION_ARGUMENT = "{'left': 10, 'top': 10, 'right': 10, 'bottom': 10}" | ||
TEST_REDACTION_ARGUMENT_EDITED = "{'left': 20, 'top': 20, 'right': 20, 'bottom': 20}" | ||
|
||
TEST_REDACTION_DOCUMENT_FILENAME = 'black_upper_left_corner.png' | ||
TEST_REDACTION_DOCUMENT_PATH = os.path.join( | ||
settings.BASE_DIR, 'apps', 'redactions', 'tests', 'contrib', | ||
'sample_documents', TEST_REDACTION_DOCUMENT_FILENAME | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from ..layers import layer_redactions | ||
|
||
|
||
class LayerMaximumOrderAPIViewTestMixin: | ||
def _request_document_file_page_image_api_view_with_maximum_layer_order(self): | ||
return self.get( | ||
viewname='rest_api:documentfilepage-image', kwargs={ | ||
'document_id': self.test_document.pk, | ||
'document_file_id': self.test_document_file.pk, | ||
'document_file_page_id': self.test_document_file_page.pk, | ||
}, query={'maximum_layer_order': layer_redactions.order} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from io import BytesIO | ||
|
||
from PIL import Image | ||
|
||
from rest_framework import status | ||
|
||
from mayan.apps.rest_api.tests.base import BaseAPITestCase | ||
|
||
from mayan.apps.converter.layers import layer_saved_transformations | ||
from mayan.apps.converter.transformations import TransformationRotate270 | ||
from mayan.apps.documents.permissions import permission_document_file_view | ||
from mayan.apps.documents.tests.mixins.document_mixins import DocumentTestMixin | ||
|
||
from .literals import TEST_REDACTION_DOCUMENT_PATH | ||
from .mixins import LayerMaximumOrderAPIViewTestMixin | ||
|
||
|
||
class LayerMaximumOrderAPIViewTestCase( | ||
LayerMaximumOrderAPIViewTestMixin, DocumentTestMixin, BaseAPITestCase | ||
): | ||
test_document_path = TEST_REDACTION_DOCUMENT_PATH | ||
|
||
def test_redaction_maximum_layer_order(self): | ||
self.grant_access( | ||
obj=self.test_document, permission=permission_document_file_view | ||
) | ||
|
||
layer_saved_transformations.add_transformation_to( | ||
obj=self.test_document_file_page, | ||
transformation_class=TransformationRotate270 | ||
) | ||
|
||
self._clear_events() | ||
|
||
response = self._request_document_file_page_image_api_view_with_maximum_layer_order() | ||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
|
||
image_buffer = BytesIO(response.content) | ||
image = Image.open(fp=image_buffer) | ||
|
||
self.assertEqual(image.getpixel(xy=(0, 0)), (0, 0, 0)) | ||
|
||
events = self._get_test_events() | ||
self.assertEqual(events.count(), 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters