Commits

tehfink committed ffc0aed

subtle navigation bug: moved tracking lists inside for loop

  • Participants
  • Parent commits bfcf293
  • Branches cms-2.X

Comments (0)

Files changed (1)

File cmsplugin_photologue/navigation.py

     """ creates mptt style parent-child list for extending django-cms navigation (menu & breadcrumb); structured on photologue.urls """
 
     res = []                                                        #NavigationNode result list
-        
+
     for q in gallery_args, photo_args:                              #get public Galleries & Photos
         if q.has_key('queryset'):                                   #use photologue defaults
             queryset = q['queryset']
             try:                                                    #get the name of the queryset's model
                 model = q['queryset'][0].__class__.__name__.lower()
             except IndexError:                                      #abort if empty
-                return res                
+                return res
         else:
             return res
-        
-        years_done = []                                             #keeps track of published item years
-        months_done = []
-        days_done = []
-        slug_done = []
-        page_done = []
-    
+
+
         #create the base path of the URL ('gallery/' or 'photo/')
         base_node = NavigationNode(model, reverse('pl-%s-archive' % model,))
         base_node.childrens = []
 
         #create NavigationNodes for the queryset
         for item in queryset:
+
+            years_done = []                                             #keeps track of published item years
+            months_done = []
+            days_done = []
+            slug_done = []
+            page_done = []
+
             #get the date for this query object; 'date_added' called 'date published' in photologue admin
             date = item.date_added
-            
+
             if not date.year in years_done:                         #if this year is not in the years_done list
                 years_done.append(date.year)                        #add it to years_done list
                 #name the navigation node with the item's year, reverse to a named url, and pass the value captured by url regex
                 year_node = NavigationNode(date.year, reverse('pl-%s-archive-year' % model, kwargs=dict(year=date.year)))
                 year_node.childrens = []                            #create childrens sublist for this year
-                months_done = []                                    #keeps track of published item months for this year 
+                months_done = []                                    #keeps track of published item months for this year
                 base_node.childrens.append(year_node)                               #add this NavigationNode to the main list
-            
+
             if not date.month in months_done:
                 months_done.append(date.month)
                 month_node = NavigationNode(date.strftime('%b').lower(), reverse('pl-%s-archive-month' % model, kwargs=dict(year=date.year, month=date.strftime('%b').lower())))
                 month_node.childrens = []
                 days_done = []
                 year_node.childrens.append(month_node)
-            
+
             if not date.day in days_done:
                 days_done.append(date.day)
                 day_node = NavigationNode(date.day, reverse('pl-%s-archive-day' % model, kwargs=dict(year=date.year, month=date.strftime('%b').lower(), day=date.day)))
                 day_node.childrens = []
                 slug_done = []
                 month_node.childrens.append(day_node)
-                
+
             if not item.title_slug in slug_done:
                 slug_done.append(item.title_slug)
                 #one node child for the day node
                 base_node.childrens.append(item_node)
 
         res.append(base_node)
+
     return res