summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-08-23 14:12:13 -0400
committerThomas Bruederli <bruederli@kolabsys.com>2014-08-23 14:12:13 -0400
commit62df71a225fc2dbc2351a9e8ac211546c6af4ac8 (patch)
tree2f2993d2122c6053c8e6bc39f3da9194463cf610
parentd9f0b4336e151e5cb29b911f1e823289c3dc78bf (diff)
downloadpykolab-62df71a225fc2dbc2351a9e8ac211546c6af4ac8.tar.gz
Store confidential iTip invitation events in a dedicated folder - if exists (#3639)
-rw-r--r--tests/functional/test_wallace/test_007_invitationpolicy.py25
-rw-r--r--wallace/module_invitationpolicy.py14
2 files changed, 36 insertions, 3 deletions
diff --git a/tests/functional/test_wallace/test_007_invitationpolicy.py b/tests/functional/test_wallace/test_007_invitationpolicy.py
index c3be462..4807313 100644
--- a/tests/functional/test_wallace/test_007_invitationpolicy.py
+++ b/tests/functional/test_wallace/test_007_invitationpolicy.py
@@ -261,6 +261,7 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
'mailbox': 'user/jane.manager@example.org',
'kolabcalendarfolder': 'user/jane.manager/Calendar@example.org',
'kolabtasksfolder': 'user/jane.manager/Tasks@example.org',
+ 'kolabconfidentialcalendar': 'user/jane.manager/Calendar/Confidential@example.org',
'kolabinvitationpolicy': ['ACT_ACCEPT_IF_NO_CONFLICT','ACT_REJECT_IF_CONFLICT','TASK_ACCEPT','ACT_UPDATE']
}
@@ -301,6 +302,20 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
from tests.functional.synchronize import synchronize_once
synchronize_once()
+ # create confidential calendar folder for jane
+ imap = IMAP()
+ imap.connect(domain='example.org') # sets self.domain
+ imap.user_mailbox_create_additional_folders(self.jane['mail'], {
+ 'Calendar/Confidential': {
+ 'annotations': {
+ '/shared/vendor/kolab/folder-type': "event",
+ '/private/vendor/kolab/folder-type': "event.confidential"
+ }
+ }
+ })
+ imap.disconnect()
+
+
def send_message(self, itip_payload, to_addr, from_addr=None, method="REQUEST"):
if from_addr is None:
from_addr = self.john['mail']
@@ -933,6 +948,16 @@ class TestWallaceInvitationpolicy(unittest.TestCase):
self.assertEqual(notification, None)
+ def test_012_confidential_invitation(self):
+ start = datetime.datetime(2014,9,21, 9,30,0)
+ uid = self.send_itip_invitation(self.jane['mail'], start, summary='confidential', template=itip_invitation.replace("DESCRIPTION:test", "CLASS:CONFIDENTIAL"))
+
+ # check event being stored in the folder annotared with event.confidential
+ event = self.check_user_calendar_event(self.jane['kolabconfidentialcalendar'], uid)
+ self.assertIsInstance(event, pykolab.xml.Event)
+ self.assertEqual(event.get_summary(), "confidential")
+
+
def test_020_task_assignment_accept(self):
start = datetime.datetime(2014,9,10, 19,0,0)
uid = self.send_itip_invitation(self.jane['mail'], start, summary='work', template=itip_todo)
diff --git a/wallace/module_invitationpolicy.py b/wallace/module_invitationpolicy.py
index 5c187c5..753547c 100644
--- a/wallace/module_invitationpolicy.py
+++ b/wallace/module_invitationpolicy.py
@@ -728,9 +728,14 @@ def list_user_folders(user_rec, type):
or metadata[folder].has_key('/private' + FOLDER_TYPE_ANNOTATION) and metadata[folder]['/private' + FOLDER_TYPE_ANNOTATION].startswith(type)):
result.append(folder)
- # store default folder folder in user record
- if metadata[folder].has_key('/private' + FOLDER_TYPE_ANNOTATION) and metadata[folder]['/private' + FOLDER_TYPE_ANNOTATION].endswith('.default'):
- user_rec['_default_folder'] = folder
+ if metadata[folder].has_key('/private' + FOLDER_TYPE_ANNOTATION):
+ # store default folder in user record
+ if metadata[folder]['/private' + FOLDER_TYPE_ANNOTATION].endswith('.default'):
+ user_rec['_default_folder'] = folder
+
+ # store confidential folder in user record
+ if metadata[folder]['/private' + FOLDER_TYPE_ANNOTATION].endswith('.confidential') and not user_rec.has_key('_confidential_folder'):
+ user_rec['_confidential_folder'] = folder
# cache with user record
user_rec['_imap_folders'] = result
@@ -908,6 +913,9 @@ def store_object(object, user_rec, targetfolder=None):
targetfolder = list_user_folders(user_rec, object.type)[0]
if user_rec.has_key('_default_folder'):
targetfolder = user_rec['_default_folder']
+ # use *.confidential folder for invitations classified as confidential
+ if object.get_classification() == kolabformat.ClassConfidential and user_rec.has_key('_confidential_folder'):
+ targetfolder = user_rec['_confidential_folder']
if not targetfolder:
log.error(_("Failed to save %s: no target folder found for user %r") % (object.type, user_rec['mail']))