diff options
| author | adontz <adontz@gmail.com> | 2022-03-05 20:09:42 +0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-25 10:33:44 +0100 |
| commit | 2bee0b4328319eaf6a0d1686677d629f2ecf6dec (patch) | |
| tree | 116b7dea4223da88dc24b422a08bb9bad8d7d05f /tests/admin_views | |
| parent | d44951b36ef2e698f32a8e1352671689e44c4d62 (diff) | |
| download | django-2bee0b4328319eaf6a0d1686677d629f2ecf6dec.tar.gz | |
Fixed #7497 -- Allowed overriding the order of apps and models in admin.
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/customadmin.py | 8 | ||||
| -rw-r--r-- | tests/admin_views/tests.py | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/admin_views/customadmin.py b/tests/admin_views/customadmin.py index f9e1f6fe1a..e3429ec4bc 100644 --- a/tests/admin_views/customadmin.py +++ b/tests/admin_views/customadmin.py @@ -35,6 +35,14 @@ class Admin2(admin.AdminSite): def password_change(self, request, extra_context=None): return super().password_change(request, {"spam": "eggs"}) + def get_app_list(self, request, app_label=None): + app_list = super().get_app_list(request, app_label=app_label) + # Reverse order of apps and models. + app_list = list(reversed(app_list)) + for app in app_list: + app["models"].sort(key=lambda x: x["name"], reverse=True) + return app_list + class UserLimitedAdmin(UserAdmin): # used for testing password change on a user not in queryset diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index acad97923a..185c1bff26 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1358,6 +1358,17 @@ class AdminViewBasicTest(AdminViewBasicTestCase): models = [model["name"] for model in response.context["app_list"][0]["models"]] self.assertSequenceEqual(models, sorted(models)) + def test_app_index_context_reordered(self): + self.client.force_login(self.superuser) + response = self.client.get(reverse("admin2:app_list", args=("admin_views",))) + self.assertContains( + response, + "<title>Admin_Views administration | Django site admin</title>", + ) + # Models are in reverse order. + models = [model["name"] for model in response.context["app_list"][0]["models"]] + self.assertSequenceEqual(models, sorted(models, reverse=True)) + def test_change_view_subtitle_per_object(self): response = self.client.get( reverse("admin:admin_views_article_change", args=(self.a1.pk,)), |
