Source

dvd-collection / collection / templatetags / moviedb.py

Kevin Veroneau 80dc35b 

Kevin Veroneau 515d482 
Kevin Veroneau 80dc35b 




Kevin Veroneau 515d482 

Kevin Veroneau 80dc35b 
Kevin Veroneau e145dfb 


from django import template
from collection.models import Movie
import datetime

register = template.Library()

@register.inclusion_tag('collection/fragments/movie_posters.html')
def latest_movies():
    daycheck = datetime.date.today()-datetime.timedelta(days=30)
    movie_list = Movie.objects.filter(added_on__gte=daycheck).order_by('-added_on')
    return {'movie_list':movie_list, 'span':'4'}

@register.simple_tag
def total_movies():
    return Movie.objects.all().count()