futurecolors/moscowdjango — pull request #70 by st4lk (2013-02-28 23:23:20+00:00)
Title: Planning events are never shown on index page.

Currently, on index page `main_event` has always status 'active'. So planning event and corresponding subscription form are never shown on index page.

Check it out.
models.py:

class EventQuerySet(models.query.QuerySet):
def upcoming(self):
try:
return self.filter(status=Event.STATUS.active).latest()
except Event.DoesNotExist:
return None

views.py:

context.update({
'main_event': Event.objects.upcoming(),
})

index.html:

{% if main_event %}
...
{% if main_event.status == 'planning' %}
{% include 'blocks/message.html' with event=main_event %}
{% include 'blocks/subscription.html' %}
...
{% endif %}
...
{% endif %}