Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

consolidate back to a single sponsors tag, remove raw sql for now

  • Loading branch information...
commit 34a706dff71e28331dcbb07213726b749173315a 1 parent d004b8d
Luke Hatcher lukeman authored
Showing with 21 additions and 22 deletions.
  1. +21 −22 symposion/sponsors_pro/templatetags/sponsors_pro_tags.py
43 symposion/sponsors_pro/templatetags/sponsors_pro_tags.py
View
@@ -9,40 +9,39 @@
class SponsorsNode(template.Node):
@classmethod
- def handle_token(cls, parser, token, web_only=True):
+ def handle_token(cls, parser, token):
bits = token.split_contents()
- if len(bits) != 3:
- raise template.TemplateSyntaxError("%r takes exactly two arguments "
- "(first argument must be 'as')" % bits[0])
- if bits[1] != "as":
- raise template.TemplateSyntaxError("First argument to %r must be "
+ section = "all"
+ if len(bits) != 3 and len(bits) != 4:
+ raise template.TemplateSyntaxError("%r takes two to three arguments "
+ "(second to last argument must be 'as')" % bits[0])
+ if bits[-2] != "as":
+ raise template.TemplateSyntaxError("Second to last argument to %r must be "
"'as'" % bits[0])
- return cls(bits[2], web_only)
+ if len(bits) == 4:
+ section = bits[1]
+ print section
+ return cls(bits[-1], section)
- def __init__(self, context_var, web_only):
- self.web_only = web_only
+ def __init__(self, context_var, section):
+ self.section = section
self.context_var = context_var
def render(self, context):
- if self.web_only:
- queryset = Sponsor.objects.with_weblogo()
- else:
- queryset = Sponsor.objects.active()
+ queryset = Sponsor.objects.active()
+ if self.section == "header":
+ queryset = queryset.filter(level__in=[1])
+ if self.section == "scroll":
+ queryset = queryset.filter(level__in=[2, 3])
+ if self.section == "footer":
+ queryset = queryset.filter(level__in=[4, 10])
context[self.context_var] = queryset
return u""
@register.tag
-def web_sponsors(parser, token):
- """
- {% web_sponsors as sponsors %}
- """
- return SponsorsNode.handle_token(parser, token, web_only=True)
-
-
-@register.tag
def sponsors(parser, token):
"""
- {% sponsors as sponsors %}
+ {% sponsors [header, scroll, footer, all] as sponsors %}
"""
return SponsorsNode.handle_token(parser, token)
Please sign in to comment.
Something went wrong with that request. Please try again.