mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f68fa8b45d
commit
9c19aff7c7
@@ -7,32 +7,33 @@ from django.contrib.auth.models import User
|
||||
from django.http import HttpResponse
|
||||
from django.urls import path
|
||||
|
||||
from . import admin as base_admin, forms, models
|
||||
from . import admin as base_admin
|
||||
from . import forms, models
|
||||
|
||||
|
||||
class Admin2(admin.AdminSite):
|
||||
app_index_template = 'custom_admin/app_index.html'
|
||||
app_index_template = "custom_admin/app_index.html"
|
||||
login_form = forms.CustomAdminAuthenticationForm
|
||||
login_template = 'custom_admin/login.html'
|
||||
logout_template = 'custom_admin/logout.html'
|
||||
index_template = ['custom_admin/index.html'] # a list, to test fix for #18697
|
||||
password_change_template = 'custom_admin/password_change_form.html'
|
||||
password_change_done_template = 'custom_admin/password_change_done.html'
|
||||
login_template = "custom_admin/login.html"
|
||||
logout_template = "custom_admin/logout.html"
|
||||
index_template = ["custom_admin/index.html"] # a list, to test fix for #18697
|
||||
password_change_template = "custom_admin/password_change_form.html"
|
||||
password_change_done_template = "custom_admin/password_change_done.html"
|
||||
|
||||
# A custom index view.
|
||||
def index(self, request, extra_context=None):
|
||||
return super().index(request, {'foo': '*bar*'})
|
||||
return super().index(request, {"foo": "*bar*"})
|
||||
|
||||
def get_urls(self):
|
||||
return [
|
||||
path('my_view/', self.admin_view(self.my_view), name='my_view'),
|
||||
path("my_view/", self.admin_view(self.my_view), name="my_view"),
|
||||
] + super().get_urls()
|
||||
|
||||
def my_view(self, request):
|
||||
return HttpResponse("Django is a magical pony!")
|
||||
|
||||
def password_change(self, request, extra_context=None):
|
||||
return super().password_change(request, {'spam': 'eggs'})
|
||||
return super().password_change(request, {"spam": "eggs"})
|
||||
|
||||
|
||||
class UserLimitedAdmin(UserAdmin):
|
||||
@@ -43,19 +44,23 @@ class UserLimitedAdmin(UserAdmin):
|
||||
|
||||
|
||||
class CustomPwdTemplateUserAdmin(UserAdmin):
|
||||
change_user_password_template = ['admin/auth/user/change_password.html'] # a list, to test fix for #18697
|
||||
change_user_password_template = [
|
||||
"admin/auth/user/change_password.html"
|
||||
] # a list, to test fix for #18697
|
||||
|
||||
|
||||
class BookAdmin(admin.ModelAdmin):
|
||||
def get_deleted_objects(self, objs, request):
|
||||
return ['a deletable object'], {'books': 1}, set(), []
|
||||
return ["a deletable object"], {"books": 1}, set(), []
|
||||
|
||||
|
||||
site = Admin2(name="admin2")
|
||||
|
||||
site.register(models.Article, base_admin.ArticleAdmin)
|
||||
site.register(models.Book, BookAdmin)
|
||||
site.register(models.Section, inlines=[base_admin.ArticleInline], search_fields=['name'])
|
||||
site.register(
|
||||
models.Section, inlines=[base_admin.ArticleInline], search_fields=["name"]
|
||||
)
|
||||
site.register(models.Thing, base_admin.ThingAdmin)
|
||||
site.register(models.Fabric, base_admin.FabricAdmin)
|
||||
site.register(models.ChapterXtra1, base_admin.ChapterXtra1Admin)
|
||||
@@ -63,5 +68,5 @@ site.register(User, UserLimitedAdmin)
|
||||
site.register(models.UndeletableObject, base_admin.UndeletableObjectAdmin)
|
||||
site.register(models.Simple, base_admin.AttributeErrorRaisingAdmin)
|
||||
|
||||
simple_site = Admin2(name='admin4')
|
||||
simple_site = Admin2(name="admin4")
|
||||
simple_site.register(User, CustomPwdTemplateUserAdmin)
|
||||
|
||||
Reference in New Issue
Block a user