1.1 --- a/imipweb/data.py Wed Jul 29 18:41:11 2015 +0200
1.2 +++ b/imipweb/data.py Thu Jul 30 18:28:43 2015 +0200
1.3 @@ -89,7 +89,7 @@
1.4 dt, attr
1.5 )
1.6
1.7 -class FormPeriod:
1.8 +class FormPeriod(RecurringPeriod):
1.9
1.10 "A period whose information originates from a form."
1.11
1.12 @@ -107,36 +107,6 @@
1.13 def __repr__(self):
1.14 return "FormPeriod(%r)" % (self.as_tuple(),)
1.15
1.16 - def _get_start(self):
1.17 - return self.start.as_datetime(self.times_enabled), self.start.get_attributes(self.times_enabled)
1.18 -
1.19 - def _get_end(self):
1.20 -
1.21 - # Handle specified end datetimes.
1.22 -
1.23 - if self.end_enabled:
1.24 - dtend = self.end.as_datetime(self.times_enabled)
1.25 - dtend_attr = self.end.get_attributes(self.times_enabled)
1.26 - if not dtend:
1.27 - return None, None
1.28 -
1.29 - # Otherwise, treat the end date as the start date. Datetimes are
1.30 - # handled by making the event occupy the rest of the day.
1.31 -
1.32 - else:
1.33 - dtstart, dtstart_attr = self._get_start()
1.34 - if dtstart:
1.35 - dtend_attr = dtstart_attr
1.36 -
1.37 - if isinstance(dtstart, datetime):
1.38 - dtend = get_end_of_day(dtstart, dtstart_attr["TZID"])
1.39 - else:
1.40 - dtend = dtstart
1.41 - else:
1.42 - return None, None
1.43 -
1.44 - return dtend, dtend_attr
1.45 -
1.46 def as_event_period(self, index=None):
1.47
1.48 """
1.49 @@ -164,18 +134,37 @@
1.50 # Period data methods.
1.51
1.52 def get_start(self):
1.53 - dtstart, dtstart_attr = self._get_start()
1.54 - return dtstart
1.55 + return self.start.as_datetime(self.times_enabled)
1.56
1.57 def get_end(self):
1.58 - dtend, dtend_attr = self._get_end()
1.59 +
1.60 + # Handle specified end datetimes.
1.61 +
1.62 + if self.end_enabled:
1.63 + dtend = self.end.as_datetime(self.times_enabled)
1.64 + if not dtend:
1.65 + return None
1.66 +
1.67 + # Otherwise, treat the end date as the start date. Datetimes are
1.68 + # handled by making the event occupy the rest of the day.
1.69 +
1.70 + else:
1.71 + dtstart, dtstart_attr = self.get_start_item()
1.72 + if dtstart:
1.73 + if isinstance(dtstart, datetime):
1.74 + dtend = get_end_of_day(dtstart, dtstart_attr["TZID"])
1.75 + else:
1.76 + dtend = dtstart
1.77 + else:
1.78 + return None
1.79 +
1.80 return dtend
1.81
1.82 - def get_start_item(self):
1.83 - return self._get_start()
1.84 + def get_start_attr(self):
1.85 + return self.start.get_attributes(self.times_enabled)
1.86
1.87 - def get_end_item(self):
1.88 - return self._get_end()
1.89 + def get_end_attr(self):
1.90 + return self.end.get_attributes(self.times_enabled)
1.91
1.92 # Form data methods.
1.93