admin.py 847 Bytes
Newer Older
1
# Django Imports
2
from django.contrib import admin
3
4
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
David Haynes's avatar
David Haynes committed
5

6
# App Imports
7
from go.models import URL, RegisteredUser
8

David Haynes's avatar
David Haynes committed
9
10
11
"""
    Define what attributes display in the URL Admin
"""
12
13
14
class URLAdmin(admin.ModelAdmin):
    list_display = ("target", "short", "owner", "clicks", "date_created", "expires")

David Haynes's avatar
David Haynes committed
15
16
17
18
19
20
# Register URLAdmin
admin.site.register(URL, URLAdmin)

"""
    Define an inline admin descriptor for User model
"""
21
class RegisteredUserInline(admin.StackedInline):
David Haynes's avatar
David Haynes committed
22
23
    model = RegisteredUser
    can_delete = False
24

David Haynes's avatar
David Haynes committed
25
26
27
"""
    Define a new User admin
"""
28
class UserAdmin(UserAdmin):
David Haynes's avatar
David Haynes committed
29
30
    # see above class that we defined
    inlines = (RegisteredUserInline, )
31

David Haynes's avatar
David Haynes committed
32
# and modify User to use our new UserAdmin
33
34
admin.site.unregister(User)
admin.site.register(User, UserAdmin)