Commit 992ff410 authored by Jérome Perrin's avatar Jérome Perrin

some improvements to iCalendar export of task module.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10901 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fa70b6e0
......@@ -70,7 +70,9 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
# bypass CookieCrumbler\n
"""Export the current selection in task report module in iCalendar format.\n
"""\n
# XXX bypass CookieCrumbler\n
if context.REQUEST.AUTHENTICATED_USER.getUserName() == \'Anonymous User\': \n
if context.REQUEST.get(\'disable_cookie_login__\', 0) \\\n
or context.REQUEST.get(\'no_infinite_loop\', 0) :\n
......@@ -79,13 +81,17 @@ if context.REQUEST.AUTHENTICATED_USER.getUserName() == \'Anonymous User\': \n
\n
def formatDate(date):\n
d = "%04d%02d%02d" % (date.year(), date.month(), date.day())\n
if date.hour() is not None :\n
d += "T%02d%02d" % (date.hour(), date.minute())\n
if date.hour() and date.minute():\n
d += "T%02d%02d%02d" % (date.hour(), date.minute(), date.second())\n
return d\n
\n
def foldContent(s) : \n
def foldContent(s):\n
""" fold a content line (cf RFC 2445) """\n
# TODO \n
s = s.replace(\',\', \'\\\\,\')\n
s = s.replace(\'/\', \'\\\\/\')\n
s = s.replace(\'"\', \'\\\\"\')\n
s = s.replace(\'\\n\', \'\\\\n\')\n
# FIXME: really fold, for now we return a big line, it works for most clients\n
return s\n
\n
def printTask(task) :\n
......@@ -98,8 +104,8 @@ SUMMARY:%(title)s\n
STATUS:%(status)s\n
PRIORITY:%(priority)s""" % ( {\n
\'creation_date\': formatDate(task.getCreationDate()),\n
\'uid\': task.getUid(),\n
\'title\': task.getTitle(),\n
\'uid\': task.getPath(),\n
\'title\': foldContent(task.getTitle()),\n
\'modification_date\': formatDate(task.getModificationDate()),\n
\'status\': task.getSimulationState() == \'delivered\' and \'COMPLETED\' or \'NEEDS_ACTION\',\n
\'priority\': task.getProperty(\'int_index\', 3),\n
......@@ -107,28 +113,30 @@ PRIORITY:%(priority)s""" % ( {\n
if task.hasComment():\n
print "DESCRIPTION:" + foldContent(task.getComment())\n
if task.hasStartDate():\n
print "DTSTART;VALUE=DATE::" + formatDate(task.getStartDate())\n
print "DTSTART;VALUE=DATE:" + formatDate(task.getStartDate())\n
if task.hasStopDate():\n
print "DUE:" + formatDate(task.getStopDate())\n
print "DUE;VALUE=DATE:" + formatDate(task.getStopDate())\n
organizer = task.getDestinationValue(portal_type=\'Person\')\n
if organizer:\n
print "ORGANIZER;CN=%s:MAILTO:%s" % (organizer.getTitle(), organizer.getDefaultEmailText())\n
print "X-ORGANIZER:MAILTO:%s" % (organizer.getDefaultEmailText())\n
for attendee in task.getSourceValueList( portal_type = \'Person\') :\n
print "ATTENDEE;CN=%s:MAILTO:%s" % (attendee.getTitle(), attendee.getDefaultEmailText())\n
\n
print "ATTACH;FMTTYPE=text/html:%s/%s/view" % (context.ERP5Site_getAbsoluteUrl(), task.getRelativeUrl())\n
\n
print "END:VTODO"\n
return printed\n
\n
print """BEGIN:VCALENDAR\n
PRODID:-//ERP5//NONSGML Task Module Report//EN \n
VERSION:1.0"""\n
PRODID:-//ERP5//NONSGML Task Report Module//EN \n
VERSION:2.0"""\n
obj_list = context.getPortalObject().portal_selections.callSelectionFor("task_report_selection")\n
for obj in obj_list : \n
print printTask(obj.getObject())\n
print "END:VCALENDAR"\n
\n
context.REQUEST.RESPONSE.setHeader(\'Content-Type\', \'text/calendar\')\n
context.REQUEST.RESPONSE.setHeader(\'Content-disposition\', \'attachment;; filename=ERP5.ics\')\n
return printed\n
......
124
\ No newline at end of file
126
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment