Merge branch 'dev' into feature-workflows
This commit is contained in:
@@ -222,7 +222,7 @@ def generate_filename(
|
||||
).strip()
|
||||
|
||||
if settings.FILENAME_FORMAT_REMOVE_NONE:
|
||||
path = path.replace("-none-/", "") # remove empty directories
|
||||
path = path.replace("/-none-/", "/") # remove empty directories
|
||||
path = path.replace(" -none-", "") # remove when spaced, with space
|
||||
path = path.replace("-none-", "") # remove rest of the occurences
|
||||
|
||||
|
||||
@@ -568,6 +568,9 @@ class CustomFieldInstanceSerializer(serializers.ModelSerializer):
|
||||
value_document_ids=[document.id],
|
||||
),
|
||||
)
|
||||
elif target_doc_field_instance.value is None:
|
||||
target_doc_field_instance.value_document_ids = [document.id]
|
||||
custom_field_instances_to_update.append(target_doc_field_instance)
|
||||
elif document.id not in target_doc_field_instance.value:
|
||||
target_doc_field_instance.value_document_ids.append(document.id)
|
||||
custom_field_instances_to_update.append(target_doc_field_instance)
|
||||
|
||||
@@ -37,6 +37,11 @@ body {
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
#inputUsername:focus {
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
#inputPassword,
|
||||
#inputPassword2 {
|
||||
border-top-left-radius: 0;
|
||||
|
||||
@@ -530,7 +530,7 @@ class TestCustomField(DirectoriesMixin, APITestCase):
|
||||
|
||||
self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
def test_bidirectional_doclink_fields(self):
|
||||
def test_symmetric_doclink_fields(self):
|
||||
"""
|
||||
GIVEN:
|
||||
- Existing document
|
||||
@@ -637,3 +637,28 @@ class TestCustomField(DirectoriesMixin, APITestCase):
|
||||
self.assertEqual(doc2.custom_fields.first().value, [])
|
||||
self.assertEqual(doc3.custom_fields.first().value, [4])
|
||||
self.assertEqual(doc4.custom_fields.first().value, [3])
|
||||
|
||||
# If field exists on target doc but value is None
|
||||
doc5 = Document.objects.create(
|
||||
title="WOW5",
|
||||
content="the content4",
|
||||
checksum="5",
|
||||
mime_type="application/pdf",
|
||||
)
|
||||
CustomFieldInstance.objects.create(document=doc5, field=custom_field_doclink)
|
||||
|
||||
resp = self.client.patch(
|
||||
f"/api/documents/{doc1.id}/",
|
||||
data={
|
||||
"custom_fields": [
|
||||
{
|
||||
"field": custom_field_doclink.id,
|
||||
"value": [doc5.id],
|
||||
},
|
||||
],
|
||||
},
|
||||
format="json",
|
||||
)
|
||||
|
||||
self.assertEqual(resp.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(doc5.custom_fields.first().value, [1])
|
||||
|
||||
@@ -1007,6 +1007,9 @@ class TestFilenameGeneration(DirectoriesMixin, TestCase):
|
||||
self.assertEqual(generate_filename(doc_a), "ThisIsAFolder/4/2020-06-25.pdf")
|
||||
self.assertEqual(generate_filename(doc_b), "SomeImportantNone/2020-07-25.pdf")
|
||||
|
||||
@override_settings(
|
||||
FILENAME_FORMAT=None,
|
||||
)
|
||||
def test_no_path_fallback(self):
|
||||
"""
|
||||
GIVEN:
|
||||
@@ -1157,3 +1160,28 @@ class TestFilenameGeneration(DirectoriesMixin, TestCase):
|
||||
|
||||
self.assertEqual(generate_filename(text_doc), "logs.txt")
|
||||
self.assertEqual(generate_filename(text_doc, archive_filename=True), "logs.pdf")
|
||||
|
||||
@override_settings(
|
||||
FILENAME_FORMAT="XX{correspondent}/{title}",
|
||||
FILENAME_FORMAT_REMOVE_NONE=True,
|
||||
)
|
||||
def test_remove_none_not_dir(self):
|
||||
"""
|
||||
GIVEN:
|
||||
- A document with & filename format that includes correspondent as part of directory name
|
||||
- FILENAME_FORMAT_REMOVE_NONE is True
|
||||
WHEN:
|
||||
- the filename is generated for the document
|
||||
THEN:
|
||||
- the missing correspondent is removed but directory structure retained
|
||||
"""
|
||||
document = Document.objects.create(
|
||||
title="doc1",
|
||||
mime_type="application/pdf",
|
||||
)
|
||||
document.storage_type = Document.STORAGE_TYPE_UNENCRYPTED
|
||||
document.save()
|
||||
|
||||
# Ensure that filename is properly generated
|
||||
document.filename = generate_filename(document)
|
||||
self.assertEqual(document.filename, "XX/doc1.pdf")
|
||||
|
||||
@@ -56,11 +56,7 @@ class StandardPagination(PageNumberPagination):
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
for obj in self.page.paginator.object_list:
|
||||
if hasattr(obj, "id"):
|
||||
ids.append(obj.id)
|
||||
elif hasattr(obj, "fields"):
|
||||
ids.append(obj.fields()["id"])
|
||||
ids = self.page.paginator.object_list.values_list("pk", flat=True)
|
||||
return ids
|
||||
|
||||
def get_paginated_response_schema(self, schema):
|
||||
|
||||
Reference in New Issue
Block a user