admin.py 948 Bytes
Newer Older
1
2
3
# Future Imports
from __future__ import unicode_literals, absolute_import, print_function, division

4
# Django Imports
5
from django.contrib import admin
6
7
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
David Haynes's avatar
David Haynes committed
8

9
# App Imports
10
from go.models import URL, RegisteredUser
11

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

David Haynes's avatar
David Haynes committed
18
19
20
21
22
23
# Register URLAdmin
admin.site.register(URL, URLAdmin)

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

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

David Haynes's avatar
David Haynes committed
35
# and modify User to use our new UserAdmin
36
37
admin.site.unregister(User)
admin.site.register(User, UserAdmin)