Skip to content

Commit

Permalink
Merge pull request #7971 from 4teamwork/amo/TI/Fix_document_date_afte…
Browse files Browse the repository at this point in the history
…r_drag_and_drop

Fix Document date after drag and drop from E-Mail
  • Loading branch information
Abdu-moustafa authored Jul 11, 2024
2 parents 239e128 + f52a74a commit 2425ba2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/TI-458.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix document_date when uploading mails with DnD, use mail header date. [amo]
13 changes: 13 additions & 0 deletions opengever/api/tests/test_tus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from ftw.builder import create
from ftw.testbrowser import browsing
from opengever.document.behaviors.customproperties import IDocumentCustomProperties
from opengever.mail.mail import OGMail
from opengever.mail.tests import MAIL_DATA
from opengever.private.interfaces import IPrivateFolderQuotaSettings
from opengever.propertysheets.storage import PropertySheetSchemaStorage
from opengever.testing import IntegrationTestCase
Expand Down Expand Up @@ -331,3 +333,14 @@ def test_tus_replace_does_not_update_document_date(self, browser):
upload_metadata = UPLOAD_METADATA + ',document_date MjAxNS0wOC0yMQ=='
self.assert_tus_replace_succeeds(self.document, browser, headers={"Upload-Metadata": upload_metadata})
self.assertEqual(current_date, self.document.document_date)

@browsing
def test_add_additional_metadata_for_ogmail(self, browser):
self.login(self.regular_user, browser)
mail = create(Builder('mail').with_message(MAIL_DATA))
mail_document_date_b64 = b64encode(mail.document_date.isoformat().encode()).decode()
upload_metadata = UPLOAD_METADATA + ',document_date {}'.format(mail_document_date_b64)
doc = self.assert_tus_upload_succeeds(
self.dossier, browser, upload_metadata=upload_metadata
)
self.assertEqual(mail.document_date, doc.document_date)
9 changes: 7 additions & 2 deletions opengever/api/tus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from opengever.base.interfaces import IDuringContentCreation
from opengever.document import _
from opengever.document.interfaces import ICheckinCheckoutManager
from opengever.mail.mail import OGMail
from opengever.meeting.proposaltemplate import IProposalTemplate
from opengever.propertysheets.creation_defaults import initialize_customproperties_defaults
from opengever.quota.exceptions import ForbiddenByQuota
Expand Down Expand Up @@ -70,9 +71,13 @@ def fix_content_type(self, tus_upload):
def add_additional_metadata(self, metadata, obj):
if not metadata.get("mode", "create") == 'create':
return

data = {}
document_date = metadata.get('document_date')
document_date = None
if isinstance(obj, OGMail):
document_date = obj.document_date
else:
document_date = metadata.get('document_date')

if document_date:
data['document_date'] = document_date

Expand Down

0 comments on commit 2425ba2

Please sign in to comment.