Test coverage report: multilingual_events.views

# multilingual_events.views: 18 total statements, 100.0% covered

Generated: Thu 2013-02-28 16:32 SGT

Source file: /Users/martin/Repos/django-multilingual-events/multilingual_events/views.py

Stats: 14 executed, 0 missed, 4 excluded, 16 ignored

1. `"""Views for the ``multilingual_events`` app."""`
2. `from django.views.generic import DetailView, TemplateView`
3. `from django.utils import timezone`
4. ``
5. `from simple_translation.middleware import filter_queryset_language`
6. ``
7. `from .models import Event`
8. ``
9. ``
10. `class EventListView(TemplateView):`
11. `"""A view that lists all upcoming events for the current language."""`
12. `template_name = 'multilingual_events/event_list.html'`
13. ``
14. `def get_context_data(self, **kwargs):`
15. `ctx = super(EventListView, self).get_context_data(**kwargs)`
16. ``
17. `yesterday = timezone.now().date() - timezone.timedelta(1)`
18. ``
19. `qs = Event.objects.filter(is_published=True)`
20. `qs = qs.filter(start_date__gte=yesterday)`
21. `upcoming = filter_queryset_language(self.request, qs)`
22. ``
23. `qs = Event.objects.filter(is_published=True)`
24. `qs = qs.filter(start_date__lt=yesterday)`
25. `archived = filter_queryset_language(self.request, qs)`
26. `return {`
27. `'upcoming_events': upcoming,`
28. `'archived_events': archived,`
29. `}`
30. ``
31. ``
32. `class EventDetailView(DetailView):`
33. `"""A view that displays detailed information about an event."""`
34. `model = Event`