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,8 +61,14 @@ class Event ( models.Model ):
|
||||||
else:
|
else:
|
||||||
return self.meeting_time
|
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())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EventParticipation( models.Model ):
|
class EventParticipation( models.Model ):
|
||||||
OPTIONS = ( ('?' , _('?' )),
|
OPTIONS = ( ('?' , _('?' )),
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
<h4>Der nächste Termin:</h4>
|
<h4>Der nächste Termin:</h4>
|
||||||
<p>
|
<p>
|
||||||
{{countdown.event.title}} am {{countdown.event.date | date:"D, d.m.y" }}
|
{{countdown.event.title}} am {{countdown.event.date | date:"D, d.m.y" }}
|
||||||
um {{countdown.event.displaytime | time:"H:i" }} Uhr
|
{% if coundown.event.displaytime %} um {{countdown.event.displaytime | time:"H:i" }} Uhr {% endif %}
|
||||||
in <em>{{countdown.event.location}} </em>
|
{% if coundown.event.location %} in <em>{{countdown.event.location}} </em> {% endif %}
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
{% if 'participation' in countdown %}
|
{% if 'participation' in countdown %}
|
||||||
|
|
|
@ -32,7 +32,8 @@ def home_view(request):
|
||||||
if ( len(events) > 0 ):
|
if ( len(events) > 0 ):
|
||||||
i = 0
|
i = 0
|
||||||
nextEvent = events[0]
|
nextEvent = events[0]
|
||||||
while datetime.combine( nextEvent.date, nextEvent.time ) < datetime.now():
|
|
||||||
|
while nextEvent.displaydatetime < datetime.now():
|
||||||
if len(events ) <= i:
|
if len(events ) <= i:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -43,8 +44,7 @@ def home_view(request):
|
||||||
part = EventParticipation.objects.filter( user = request.user ).filter( event = nextEvent )
|
part = EventParticipation.objects.filter( user = request.user ).filter( event = nextEvent )
|
||||||
countdown['participation'] = part[0].status
|
countdown['participation'] = part[0].status
|
||||||
|
|
||||||
eventTime = datetime( nextEvent.date.year, nextEvent.date.month, nextEvent.date.day,
|
eventTime = nextEvent.displaydatetime
|
||||||
nextEvent.displaytime.hour, nextEvent.displaytime.minute )
|
|
||||||
|
|
||||||
countdown['event'] = nextEvent
|
countdown['event'] = nextEvent
|
||||||
countdown['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
|
countdown['epoch'] = int( (eventTime - datetime.now() ).total_seconds() * 1000 )
|
||||||
|
|
Loading…
Reference in New Issue