diff --git a/conservancy/podjango/templatetags/podjango.py b/conservancy/podjango/templatetags/podjango.py new file mode 100644 index 0000000000000000000000000000000000000000..fccede626441e5dcdad4c9fb649413fb73c402c7 --- /dev/null +++ b/conservancy/podjango/templatetags/podjango.py @@ -0,0 +1,26 @@ +from django import template +from django.urls import reverse + +register = template.Library() + + +@register.simple_tag +def tag_url(podcast, tag): + return '{base_url}?tag={tag_slug}'.format( + base_url=reverse('podjango:cast', kwargs={'podcast_slug': podcast.slug}), + tag_slug=tag.slug + ) + + +@register.simple_tag +def episode_url(podcast, cast): + return reverse( + 'podjango:detail', + kwargs={ + 'podcast_slug': podcast.slug, + 'year': cast.pub_date.year, + 'month': cast.pub_date.strftime('%b').lower(), + 'day': cast.pub_date.day, + 'slug': cast.slug, + } + )