Commit 649d7608 authored by David Haynes's avatar David Haynes
Browse files

Comments in admin.py

- so I used to know why I did things this way
parent 07e4a9bd
Pipeline #489 passed with stage
in 6 minutes and 51 seconds
...@@ -2,23 +2,33 @@ ...@@ -2,23 +2,33 @@
from django.contrib import admin from django.contrib import admin
from django.contrib.auth.admin import UserAdmin from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User from django.contrib.auth.models import User
# App Imports # App Imports
from go.models import URL, RegisteredUser from go.models import URL, RegisteredUser
# Define what attributes display in the URL Admin """
Define what attributes display in the URL Admin
"""
class URLAdmin(admin.ModelAdmin): class URLAdmin(admin.ModelAdmin):
list_display = ("target", "short", "owner", "clicks", "date_created", "expires") list_display = ("target", "short", "owner", "clicks", "date_created", "expires")
# Define an inline admin descriptor for User model # Register URLAdmin
admin.site.register(URL, URLAdmin)
"""
Define an inline admin descriptor for User model
"""
class RegisteredUserInline(admin.StackedInline): class RegisteredUserInline(admin.StackedInline):
model = RegisteredUser model = RegisteredUser
can_delete = False can_delete = False
# Define a new User admin """
Define a new User admin
"""
class UserAdmin(UserAdmin): class UserAdmin(UserAdmin):
# see above class that we defined
inlines = (RegisteredUserInline, ) inlines = (RegisteredUserInline, )
# Register URLAdmin and modify User to use new UserAdmin # and modify User to use our new UserAdmin
admin.site.register(URL, URLAdmin)
admin.site.unregister(User) admin.site.unregister(User)
admin.site.register(User, UserAdmin) admin.site.register(User, UserAdmin)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment