Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from hecrogon/bannertags
banner_tags as a inclusion tag
- Loading branch information
Showing
1 changed file
with
8 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
### -*- coding: utf-8 -*- #################################################### | ||
|
||
from django.conf import settings | ||
from native_tags.decorators import function | ||
from django import template | ||
from banner.models import Banner | ||
|
||
from ..models import Banner | ||
register = template.Library() | ||
|
||
@register.inclusion_tag('banner_source.html') | ||
def get_banner(slug, width, height, queryset=Banner.objects.all()): | ||
banner = queryset.get_or_create(slug=slug.encode('utf-8'))[0] | ||
return "banner_source.html", { | ||
'banner': banner, 'size': "%ix%i" % (width, height), | ||
'width': width, 'height': height, | ||
'STATIC_URL': settings.STATIC_URL, | ||
return { | ||
'banner': banner, 'size': "%ix%i" % (width, height), | ||
'width': width, 'height': height, | ||
'STATIC_URL': settings.STATIC_URL, | ||
} | ||
|
||
get_banner = function(get_banner, inclusion=True, cache=60) |