Commits

Bela Hausmann committed d3944bd

Fixed bug in tempalte tags

  • Participants
  • Parent commits 0490355

Comments (0)

Files changed (1)

File licenses/templatetags/licensing.py

+# -*- coding: utf-8 -*-
 from django import template
 from django.template.loader import render_to_string
 from django.utils.safestring import mark_safe
         if len(tokens) == 4:
             if tokens[2] != 'as':
                 raise template.TemplateSyntaxError("Second argument in %s must be 'as'" % tokens[0])
-            return cls(query=tokens[1], varname=tokens[3], field=field)
+            lookup = tokens[1]
+            # trim quotation marks
+            if (lookup[0]=='"' and lookup[-1]=='"') or (lookup[0]=="'" and lookup[-1]=="'"): lookup = lookup[1:-1]
+            return cls(lookup=lookup, varname=tokens[3], field=field)
         else:
             raise template.TemplateSyntaxError("%r tag requires 3 arguments" % tokens[0])
     handle_token = classmethod(handle_token)
 
-    def __init__(self, query=None, varname=None, field=None):
+    def __init__(self, lookup=None, varname=None, field=None):
         self.varname = varname
         self.lookup = lookup
         self.field = field
 
     def render(self, context):
         try:
-            lookup_dict = {self.field: self.query}
+            lookup_dict = {self.field: self.lookup}
             license = License.objects.filter(**lookup_dict)[0]
         except IndexError:
             license = None