Bugfix for Countdown
- error when for the next event no displaytime was available - better display when no time or location for the next event is known
This commit is contained in:
parent
c693b7b1e5
commit
4d4c83b0ae
|
@ -61,6 +61,12 @@ class Event ( models.Model ):
|
|||
else:
|
||||
return self.meeting_time
|
||||
|
||||
@property
|
||||
def displaydatetime(self):
|
||||
if not self.displaytime == None:
|
||||
return datetime.combine( self.date, self.displaytime() )
|
||||
else:
|
||||
return datetime.combine( self.date, datetime.min.time())
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
<h4>Der nächste Termin:</h4>
|
||||
<p>
|
||||
{{countdown.event.title}} am {{countdown.event.date | date:"D, d.m.y" }}
|
||||
um {{countdown.event.displaytime | time:"H:i" }} Uhr
|
||||
in <em>{{countdown.event.location}} </em>
|
||||
{% if coundown.event.displaytime %} um {{countdown.event.displaytime | time:"H:i" }} Uhr {% endif %}
|
||||
{% if coundown.event.location %} in <em>{{countdown.event.location}} </em> {% endif %}
|
||||
|
||||
<br/>
|
||||
{% if 'participation' in countdown %}
|
||||
|
|
|
@ -32,7 +32,8 @@ def home_view(request):
|
|||
if ( len(events) > 0 ):
|
||||
i = 0
|
||||
nextEvent = events[0]
|
||||
while datetime.combine( nextEvent.date, nextEvent.time ) < datetime.now():
|
||||
|
||||
while nextEvent.displaydatetime < datetime.now():
|
||||
if len(events ) <= i:
|
||||
return
|
||||
else:
|
||||
|
@ -43,8 +44,7 @@ def home_view(request):
|
|||
part = EventParticipation.objects.filter( user = request.user ).filter( event = nextEvent )
|
||||
countdown['participation'] = part[0].status
|
||||
|
||||
eventTime = datetime( nextEvent.date.year, nextEvent.date.month, nextEvent.date.day,
|
||||
nextEvent.displaytime.hour, nextEvent.displaytime.minute )
|
||||
eventTime = nextEvent.displaydatetime
|
||||
|
||||
countdown['event'] = nextEvent
|
||||
countdown['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
|
||||
|
|
Loading…
Reference in New Issue