kopia lustrzana https://github.com/wagtail/wagtail
				
				
				
			Include descendants when applying bulk actions to page search results
							rodzic
							
								
									c7e636d4c3
								
							
						
					
					
						commit
						6e7cc93d11
					
				| 
						 | 
				
			
			@ -16,14 +16,22 @@ class PageBulkAction(BulkAction):
 | 
			
		|||
    def get_all_objects_in_listing_query(self, parent_id):
 | 
			
		||||
        listing_objects = self.model.objects.all()
 | 
			
		||||
 | 
			
		||||
        if parent_id is not None:
 | 
			
		||||
            listing_objects = listing_objects.get(id=parent_id).get_children()
 | 
			
		||||
 | 
			
		||||
        listing_objects = listing_objects.values_list("pk", flat=True)
 | 
			
		||||
 | 
			
		||||
        q = None
 | 
			
		||||
        if "q" in self.request.GET:
 | 
			
		||||
            q = self.request.GET.get("q", "")
 | 
			
		||||
 | 
			
		||||
        if parent_id is not None:
 | 
			
		||||
            listing_objects = listing_objects.get(id=parent_id)
 | 
			
		||||
            # If we're searching, include the descendants as well.
 | 
			
		||||
            # Otherwise, just include the direct children.
 | 
			
		||||
            if q:
 | 
			
		||||
                listing_objects = listing_objects.get_descendants()
 | 
			
		||||
            else:
 | 
			
		||||
                listing_objects = listing_objects.get_children()
 | 
			
		||||
 | 
			
		||||
        listing_objects = listing_objects.values_list("pk", flat=True)
 | 
			
		||||
 | 
			
		||||
        if q:
 | 
			
		||||
            listing_objects = page_filter_search(q, listing_objects)[0].results()
 | 
			
		||||
 | 
			
		||||
        return listing_objects
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue