def test_changelist_items(self): admin = self._get_guys(True) first_level_page = create_page('level1', 'nav_playground.html', 'en') second_level_page_top = create_page('level21', "nav_playground.html", "en", created_by=admin, published=True, parent= first_level_page) second_level_page_bottom = create_page('level22', "nav_playground.html", "en", created_by=admin, published=True, parent= self.reload(first_level_page)) third_level_page = create_page('level3', "nav_playground.html", "en", created_by=admin, published=True, parent= second_level_page_top) self.assertEquals(Page.objects.all().count(), 4) url = reverse('admin:cms_%s_changelist' % Page._meta.module_name) request = self.request_factory.get(url) request.session = {} request.user = admin page_admin = site._registry[Page] cl = CMSChangeList(request, page_admin.model, page_admin.list_display, page_admin.list_display_links, page_admin.list_filter, page_admin.date_hierarchy, page_admin.search_fields, page_admin.list_select_related, page_admin.list_per_page, page_admin.list_editable, page_admin) cl.set_items(request) root_page = cl.get_items()[0] self.assertEqual(root_page, first_level_page) self.assertEqual(root_page.get_children()[0], second_level_page_top) self.assertEqual(root_page.get_children()[1], second_level_page_bottom) self.assertEqual(root_page.get_children()[0].get_children()[0], third_level_page)
def test_changelist_items(self): admin = self._get_guys(True) first_level_page = create_page('level1', 'nav_playground.html', 'en') second_level_page_top = create_page('level21', "nav_playground.html", "en", created_by=admin, published=True, parent=first_level_page) second_level_page_bottom = create_page( 'level22', "nav_playground.html", "en", created_by=admin, published=True, parent=self.reload(first_level_page)) third_level_page = create_page('level3', "nav_playground.html", "en", created_by=admin, published=True, parent=second_level_page_top) self.assertEquals(Page.objects.all().count(), 4) url = reverse('admin:cms_%s_changelist' % Page._meta.module_name) request = self.request_factory.get(url) request.session = {} request.user = admin page_admin = site._registry[Page] cl = CMSChangeList(request, page_admin.model, page_admin.list_display, page_admin.list_display_links, page_admin.list_filter, page_admin.date_hierarchy, page_admin.search_fields, page_admin.list_select_related, page_admin.list_per_page, page_admin.list_editable, page_admin) cl.set_items(request) root_page = cl.get_items()[0] self.assertEqual(root_page, first_level_page) self.assertEqual(root_page.get_children()[0], second_level_page_top) self.assertEqual(root_page.get_children()[1], second_level_page_bottom) self.assertEqual(root_page.get_children()[0].get_children()[0], third_level_page)
def changelist_view(self, request, extra_context=None): "The 'change list' admin view for this model." from django.contrib.admin.views.main import ERROR_FLAG opts = self.model._meta app_label = opts.app_label if not self.has_change_permission(request, None): raise PermissionDenied try: if hasattr(self, 'list_editable'):# django 1.1 cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self) else:# django 1.0.2 cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self) except IncorrectLookupParameters: # Wacky lookup parameters were given, so redirect to the main # changelist page, without parameters, and pass an 'invalid=1' # parameter via the query string. If wacky parameters were given and # the 'invalid=1' parameter was already in the query string, something # is screwed up with the database, so display an error page. if ERROR_FLAG in request.GET.keys(): return render_to_response('admin/invalid_setup.html', {'title': _('Database error')}) return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1') cl.set_items(request) context = { 'title': cl.title, 'is_popup': cl.is_popup, 'cl': cl, 'opts':opts, 'has_add_permission': self.has_add_permission(request), 'root_path': self.admin_site.root_path, 'app_label': app_label, 'CMS_MEDIA_URL': settings.CMS_MEDIA_URL, 'softroot': settings.CMS_SOFTROOT, 'CMS_PERMISSION': settings.CMS_PERMISSION, 'CMS_MODERATOR': settings.CMS_MODERATOR, 'has_recover_permission': self.has_recover_permission(request), 'DEBUG': settings.DEBUG, } if 'reversion' in settings.INSTALLED_APPS: context['has_change_permission'] = self.has_change_permission(request) context.update(extra_context or {}) return render_to_response(self.change_list_template or [ 'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), 'admin/%s/change_list.html' % app_label, 'admin/change_list.html' ], context, context_instance=RequestContext(request))
def changelist_view(self, request, extra_context=None): "The 'change list' admin view for this model." from django.contrib.admin.views.main import ERROR_FLAG opts = self.model._meta app_label = opts.app_label if not self.has_change_permission(request, None): raise PermissionDenied try: if hasattr(self, 'list_editable'): # django 1.1 cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self) else: # django 1.0.2 cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self) except IncorrectLookupParameters: # Wacky lookup parameters were given, so redirect to the main # changelist page, without parameters, and pass an 'invalid=1' # parameter via the query string. If wacky parameters were given and # the 'invalid=1' parameter was already in the query string, something # is screwed up with the database, so display an error page. if ERROR_FLAG in request.GET.keys(): return render_to_response('admin/invalid_setup.html', {'title': _('Database error')}) return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1') cl.set_items(request) context = { 'title': cl.title, 'is_popup': cl.is_popup, 'cl': cl, 'opts': opts, 'has_add_permission': self.has_add_permission(request), 'root_path': self.admin_site.root_path, 'app_label': app_label, 'CMS_MEDIA_URL': settings.CMS_MEDIA_URL, 'softroot': settings.CMS_SOFTROOT, 'CMS_PERMISSION': settings.CMS_PERMISSION, 'CMS_MODERATOR': settings.CMS_MODERATOR, 'has_recover_permission': self.has_recover_permission(request), 'DEBUG': settings.DEBUG, } if 'reversion' in settings.INSTALLED_APPS: context['has_change_permission'] = self.has_change_permission( request) context.update(extra_context or {}) return render_to_response(self.change_list_template or [ 'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), 'admin/%s/change_list.html' % app_label, 'admin/change_list.html' ], context, context_instance=RequestContext(request))
def changelist_view(self, request, extra_context=None): "The 'change list' admin view for this model." from django.contrib.admin.views.main import ERROR_FLAG opts = self.model._meta app_label = opts.app_label if not self.has_change_permission(request, None): raise PermissionDenied try: if hasattr(self, "list_editable"): # django 1.1 cl = CMSChangeList( request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self, ) else: # django 1.0.2 cl = CMSChangeList( request, self.model, self.list_display, self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self, ) except IncorrectLookupParameters: # Wacky lookup parameters were given, so redirect to the main # changelist page, without parameters, and pass an 'invalid=1' # parameter via the query string. If wacky parameters were given and # the 'invalid=1' parameter was already in the query string, something # is screwed up with the database, so display an error page. if ERROR_FLAG in request.GET.keys(): return render_to_response("admin/invalid_setup.html", {"title": _("Database error")}) return HttpResponseRedirect(request.path + "?" + ERROR_FLAG + "=1") cl.set_items(request) context = { "title": cl.title, "is_popup": cl.is_popup, "cl": cl, "opts": opts, "has_add_permission": self.has_add_permission(request), "root_path": self.admin_site.root_path, "app_label": app_label, "CMS_MEDIA_URL": settings.CMS_MEDIA_URL, "softroot": settings.CMS_SOFTROOT, "CMS_PERMISSION": settings.CMS_PERMISSION, "CMS_MODERATOR": settings.CMS_MODERATOR, "has_recover_permission": self.has_recover_permission(request), "DEBUG": settings.DEBUG, } if "reversion" in settings.INSTALLED_APPS: context["has_change_permission"] = self.has_change_permission(request) context.update(extra_context or {}) return render_to_response( self.change_list_template or [ "admin/%s/%s/change_list.html" % (app_label, opts.object_name.lower()), "admin/%s/change_list.html" % app_label, "admin/change_list.html", ], context, context_instance=RequestContext(request), )