Removed some dead code, simplified TimeSlot *_start_time() and *_end_time() methods, and added TimeSlot.local_date().
- Legacy-Id: 18784
This commit is contained in:
parent
a708bdf895
commit
d9ad8b8616
|
@ -245,7 +245,7 @@ class Meeting(models.Model):
|
||||||
for ts in self.timeslot_set.all():
|
for ts in self.timeslot_set.all():
|
||||||
if ts.location_id is None:
|
if ts.location_id is None:
|
||||||
continue
|
continue
|
||||||
ymd = ts.time.date()
|
ymd = ts.local_date()
|
||||||
if ymd not in time_slices:
|
if ymd not in time_slices:
|
||||||
time_slices[ymd] = []
|
time_slices[ymd] = []
|
||||||
slots[ymd] = []
|
slots[ymd] = []
|
||||||
|
@ -474,9 +474,6 @@ class TimeSlot(models.Model):
|
||||||
t = self.local_start_time()
|
t = self.local_start_time()
|
||||||
return "%s-%s" % (t.strftime("%H%M"), (t + self.duration).strftime("%H%M"))
|
return "%s-%s" % (t.strftime("%H%M"), (t + self.duration).strftime("%H%M"))
|
||||||
|
|
||||||
def meeting_date(self):
|
|
||||||
return self.time.date()
|
|
||||||
|
|
||||||
def registration(self):
|
def registration(self):
|
||||||
# below implements a object local cache
|
# below implements a object local cache
|
||||||
# it tries to find a timeslot of type registration which starts at the same time as this slot
|
# it tries to find a timeslot of type registration which starts at the same time as this slot
|
||||||
|
@ -541,28 +538,21 @@ class TimeSlot(models.Model):
|
||||||
return self._cached_tz
|
return self._cached_tz
|
||||||
|
|
||||||
def tzname(self):
|
def tzname(self):
|
||||||
if self.tz():
|
tz = self.tz()
|
||||||
return self.tz().tzname(self.time.replace(tzinfo=None))
|
return tz.tzname(self.time.replace(tzinfo=None)) if tz else None
|
||||||
def utc_start_time(self):
|
def utc_start_time(self):
|
||||||
if self.tz():
|
return self.time.astimezone(pytz.utc)
|
||||||
return self.time.astimezone(pytz.utc)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
def utc_end_time(self):
|
def utc_end_time(self):
|
||||||
if self.tz():
|
return self.end_time().astimezone(pytz.utc)
|
||||||
return self.end_time().astimezone(pytz.utc)
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
def local_start_time(self):
|
def local_start_time(self):
|
||||||
if self.tz():
|
tz = self.tz()
|
||||||
return self.time.astimezone(self.tz())
|
return self.time.astimezone(tz) if tz else None
|
||||||
else:
|
|
||||||
return None
|
|
||||||
def local_end_time(self):
|
def local_end_time(self):
|
||||||
if self.tz():
|
tz = self.tz()
|
||||||
return self.end_time().astimezone(self.tz())
|
return self.end_time().astimezone(tz) if tz else None
|
||||||
else:
|
def local_date(self):
|
||||||
return None
|
tz = self.tz()
|
||||||
|
return self.time.astimezone(tz).date() if tz else None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def js_identifier(self):
|
def js_identifier(self):
|
||||||
|
|
Loading…
Reference in a new issue