diff --git a/eventplanner/models.py b/eventplanner/models.py index 1ac8dab..8bd01aa 100644 --- a/eventplanner/models.py +++ b/eventplanner/models.py @@ -61,8 +61,14 @@ 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()) - + class EventParticipation( models.Model ): OPTIONS = ( ('?' , _('?' )), diff --git a/website/templates/website/event_countdown.html b/website/templates/website/event_countdown.html index 164048d..ae63648 100644 --- a/website/templates/website/event_countdown.html +++ b/website/templates/website/event_countdown.html @@ -39,8 +39,8 @@

Der nächste Termin:

{{countdown.event.title}} am {{countdown.event.date | date:"D, d.m.y" }} - um {{countdown.event.displaytime | time:"H:i" }} Uhr - in {{countdown.event.location}} + {% if coundown.event.displaytime %} um {{countdown.event.displaytime | time:"H:i" }} Uhr {% endif %} + {% if coundown.event.location %} in {{countdown.event.location}} {% endif %}
{% if 'participation' in countdown %} diff --git a/website/views.py b/website/views.py index f193f43..4d091e7 100644 --- a/website/views.py +++ b/website/views.py @@ -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 )