Commits

tehfink committed 7605ebc

fixed template module reference & simplified num var check

Comments (0)

Files changed (1)

cmsplugin_photologue/templatetags/cmsplugin_photologue_tags.py

             self.model = get_model('photologue', 'Photo')
 
         #'All' means slicing with [:None] , which returns everything
-        if num == 'All' or num =='all':
+        if num == 'All' or num == 'all':
             num = None
+        else:
+            num = abs(int(num))
         self.num = num
 
-        #ensure the slice is not negative, which might return a DataError
-        try:
-            if int(num) < 0:
-                num = 0
-        except TypeError:
-            num = 0
-
         self.varname = varname
 
     def render(self, context):
     varname = bits[2]
 
     if len(bits) != 3:
-        raise TemplateSyntaxError, "get_latest_galleries tag takes exactly three arguments"
+        raise template.TemplateSyntaxError, "get_latest_galleries tag takes exactly three arguments"
     if bits[1] != 'as':
-        raise TemplateSyntaxError, "second argument to get_latest_galleries tag must be 'as'"
+        raise template.TemplateSyntaxError, "second argument to get_latest_galleries tag must be 'as'"
 
     return LatestPhotologueModelNode(model, num, varname)