Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use E-Mail address in ics header instead of userid for the INDIVIDUAL property #49

Merged
merged 3 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Changelog
1.6.3 (unreleased)
------------------

- Drop Plone 4.2 support. [mathias.leimgruber]

- Use E-Mail address in ics header instead of userid for the INDIVIDUAL property. [mathias.leimgruber]

- Drop Plone 4.1 support. [jone]

- An older ftw.calendar is required because of breaking changes in
Expand Down
7 changes: 5 additions & 2 deletions ftw/meeting/browser/export_ics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from plone import api
from plone.memoize import ram
from Products.ATContentTypes.lib import calendarsupport as cs
from Products.ATContentTypes.browser.calendar import CalendarView, cachekey
from Products.ATContentTypes.lib import calendarsupport as cs


class ExportICS(CalendarView):
Expand All @@ -18,9 +19,11 @@ def attendees(self, brain):
info = voc.getValue(attendee['contact'])
if not info:
continue

user = api.user.get(userid=attendee['contact'])
value += 'ATTENDEE;CN="%s";CUTYPE=INDIVIDUAL:%s\n' % (
info.decode('utf8'),
attendee['contact'])
user.getProperty('email'))
return value.encode('utf8')
return ''

Expand Down
47 changes: 33 additions & 14 deletions ftw/meeting/tests/test_ics_attachment.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
from ftw.meeting.testing import FTW_MEETING_INTEGRATION_TESTING
from ftw.builder import Builder
from ftw.builder import create
from ftw.meeting.attachment import ICSAttachmentCreator
import unittest2 as unittest
from plone.app.testing import TEST_USER_ID, TEST_USER_NAME
from ftw.meeting.testing import FTW_MEETING_INTEGRATION_TESTING
from plone.app.testing import setRoles, login
from plone.app.testing import TEST_USER_ID, TEST_USER_NAME
import DateTime
import unittest2 as unittest


class TestIcsAttachmentView(unittest.TestCase):

layer = FTW_MEETING_INTEGRATION_TESTING


def setUp(self):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
login(self.portal, TEST_USER_NAME)
self.portal.invokeFactory('Folder', 'test')
self.test = self.portal['test']

def test_ics_attachment(self):
portal = self.layer['portal']
setRoles(portal, TEST_USER_ID, ['Manager'])
login(portal, TEST_USER_NAME)
portal.invokeFactory('Folder', 'test')
test = portal['test']
test.invokeFactory('Meeting', 'meeting')
meeting = test['meeting']
self.test.invokeFactory('Meeting', 'meeting')
meeting = self.test['meeting']
meeting.title = "TheMeeting"
meeting.start_date = DateTime.DateTime()
meeting.end_date = meeting.start_date + 1
creator = ICSAttachmentCreator(meeting)
ics = creator(meeting)
ics_data = ics[0][0].read()
self.assertEqual("SUMMARY:TheMeeting" in ics_data, True)
self.assertEqual("URL:http://nohost/plone/test/meeting" in ics_data, True)
self.assertEqual("BEGIN:VALARM\r\nTRIGGER:-PT30M\r\nACTION:DISPLAY\r\nDESCRIPTION:Reminder\r\nEND:VALARM" in ics_data, True)
self.assertIn("URL:http://nohost/plone/test/meeting", ics_data)
self.assertIn("BEGIN:VALARM\r\nTRIGGER:-PT30M\r\nACTION:DISPLAY\r\nDESCRIPTION:Reminder\r\nEND:VALARM",
ics_data)

def test_attendee_email_address_in_ics(self):
user = create(Builder('user').named('User', 'Test')
.with_userid('test.user')
.having(email='test@example.com'))
meeting = create(Builder('meeting')
.having(attendees=[{'contact': user.getId(),
'present': 'present'}],
start_date=DateTime.DateTime(),
end_date=DateTime.DateTime() + 10))

ics = ICSAttachmentCreator(meeting)(meeting)
ics_data = ics[0][0].read()
self.assertIn('INDIVIDUAL:test@example.com', ics_data)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
# http://www.python.org/pypi?%3Aaction=list_classifiers
classifiers=[
'Framework :: Plone',
'Framework :: Plone :: 4.2',
'Framework :: Plone :: 4.3',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Programming Language :: Python',
Expand All @@ -64,6 +63,7 @@
'ftw.calendarwidget',
'plone.principalsource',
'ftw.upgrade',
'plone.api',
],

tests_require=tests_require,
Expand Down
6 changes: 0 additions & 6 deletions test-plone-4.2.x.cfg

This file was deleted.