Test coverage report: calendarium.templatetags.calendarium_tags

# calendarium.templatetags.calendarium_tags: 16 total statements, 100.0% covered

Generated: Thu 2013-05-02 12:21 SGT

Source file: /Users/martin/Repos/django-calendarium/calendarium/templatetags/calendarium_tags.py

Stats: 12 executed, 0 missed, 4 excluded, 22 ignored

1. `"""Templatetags for the ``calendarium`` project."""`
2. `from django.core.urlresolvers import reverse`
3. `from django import template`
4. `from django.utils.timezone import datetime, now, timedelta, utc`
5. ``
6. `from ..models import Event, EventCategory`
7. ``
8. `register = template.Library()`
9. ``
10. ``
11. `@register.filter`
12. `def get_week_URL(date, day=0):`
13. `"""`
14. `Returns the week view URL for a given date.`
15. ``
16. `:param date: A date instance.`
17. `:param day: Day number in a month.`
18. ``
19. `"""`
20. `if day < 1:`
21. `day = 1`
22. `date = datetime(year=date.year, month=date.month, day=day, tzinfo=utc)`
23. `return reverse('calendar_week', kwargs={'year': date.isocalendar()[0],`
24. `'week': date.isocalendar()[1]})`
25. ``
26. ``
27. `@register.inclusion_tag('calendarium/upcoming_events.html')`
28. `def render_upcoming_events(event_amount=5, category=None):`
29. `"""Template tag to render a list of upcoming events."""`
30. `if not isinstance(category, EventCategory):`
31. `category = None`
32. `return {`
33. `'occurrences': Event.objects.get_occurrences(`
34. `now(),`
35. `now() + timedelta(days=100),`
36. `category,`
37. `)[:event_amount]`
38. `}`