Skip to content

Commit

Permalink
begin fixing issue 160 - try to not rely on start/end and other attrs…
Browse files Browse the repository at this point in the history
… actually be set. Refs #160
  • Loading branch information
thet committed Oct 23, 2014
1 parent 33943ff commit 65fa06b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
23 changes: 13 additions & 10 deletions plone/app/event/base.py
Expand Up @@ -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
)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions plone/app/event/browser/event_summary.pt
Expand Up @@ -26,8 +26,8 @@
<tal:cond condition="python:'date' not in excludes">
<dt i18n:translate="event_when">When</dt>
<dd tal:define="start_tzname data/timezone;
start_utcdelta python:data.start.tzinfo.utcoffset(data.start);
start_utcoffset python:(start_utcdelta.days*86400+start_utcdelta.seconds)*100/60/60;">
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;">
<tal:date replace="structure python:view.formatted_date(context)" />
<span class="timezone" tal:condition="start_tzname">
(<tal:tzname replace="start_tzname">timezone name</tal:tzname> / UTC<tal:tzoffset replace="start_utcoffset" />)
Expand Down
4 changes: 2 additions & 2 deletions plone/app/event/dx/behaviors.py
Expand Up @@ -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):
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion plone/app/event/ical/exporter.py
Expand Up @@ -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)
Expand Down

0 comments on commit 65fa06b

Please sign in to comment.