From 65fa06bce97390c2667a585e2b0ec5e09287c31b Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 23 Oct 2014 02:11:34 +0200 Subject: [PATCH] begin fixing issue 160 - try to not rely on start/end and other attrs actually be set. Refs #160 --- plone/app/event/base.py | 23 +++++++++++++---------- plone/app/event/browser/event_summary.pt | 4 ++-- plone/app/event/dx/behaviors.py | 4 ++-- plone/app/event/ical/exporter.py | 3 ++- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/plone/app/event/base.py b/plone/app/event/base.py index 438f85e6a..42fcdad2e 100644 --- a/plone/app/event/base.py +++ b/plone/app/event/base.py @@ -788,8 +788,13 @@ def dates_for_display(occurrence): acc = IEventAccessor(occurrence) # this needs to separate date and time as ulocalized_time does - DT_start = DT(acc.start) - DT_end = DT(acc.end) + _start = acc.start + _end = acc.end + _whole_day = acc.whole_day + _open_end = acc.open_end + + DT_start = DT(_start) + DT_end = DT(_end) start_date = ulocalized_time( DT_start, long_format=False, time_only=None, context=occurrence ) @@ -803,19 +808,17 @@ def dates_for_display(occurrence): DT_end, long_format=False, time_only=True, context=occurrence ) - same_day = is_same_day(acc.start, acc.end) - same_time = is_same_time(acc.start, acc.end) + same_day = is_same_day(_start, _end) if _start and _end else None + same_time = is_same_time(_start, _end) if _start and _end else None # set time fields to None for whole day events - if acc.whole_day: + if _whole_day: start_time = end_time = None - if acc.open_end: + if _open_end: end_time = None - start_iso = acc.whole_day and acc.start.date().isoformat()\ - or acc.start.isoformat() - end_iso = acc.whole_day and acc.end.date().isoformat()\ - or acc.end.isoformat() + start_iso = None if not _start else _start.date().isoformat() if _whole_day else _start.isoformat() # noqa + end_iso = None if not _end else _end.date().isoformat() if _whole_day else end.isoformat() # noqa return dict( # Start diff --git a/plone/app/event/browser/event_summary.pt b/plone/app/event/browser/event_summary.pt index bb4d7af68..f7e0ee627 100644 --- a/plone/app/event/browser/event_summary.pt +++ b/plone/app/event/browser/event_summary.pt @@ -26,8 +26,8 @@
When
+ start_utcdelta python:data.start.tzinfo.utcoffset(data.start) if data.start else None; + start_utcoffset python:(start_utcdelta.days*86400+start_utcdelta.seconds)*100/60/60 if start_utcdelta else 0;"> (timezone name / UTC) diff --git a/plone/app/event/dx/behaviors.py b/plone/app/event/dx/behaviors.py index 35163de8d..b3f170a00 100644 --- a/plone/app/event/dx/behaviors.py +++ b/plone/app/event/dx/behaviors.py @@ -667,7 +667,7 @@ def url(self): @property def created(self): - return utc(self.context.creation_date) + return utc(getattr(self.context, 'creation_date', None)) @property def duration(self): @@ -690,7 +690,7 @@ def description(self, value): @property def last_modified(self): - return utc(self.context.modification_date) + return utc(getattr(self.context, 'modification_date', None)) @last_modified.setter def last_modified(self, value): tz = default_timezone(self.context, as_tzinfo=True) diff --git a/plone/app/event/ical/exporter.py b/plone/app/event/ical/exporter.py index 0fcdf019b..8e3c74a9c 100644 --- a/plone/app/event/ical/exporter.py +++ b/plone/app/event/ical/exporter.py @@ -86,7 +86,8 @@ def construct_icalendar(context, events): def add_to_zones_map(tzmap, tzid, dt): - if tzid.lower() == 'utc' or not is_datetime(dt): + + if not tzid or not is_datetime(dt) or tzid.lower() == 'utc': # no need to define UTC nor timezones for date objects. return tzmap null = datetime(1, 1, 1)