admin.py 975 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

12
class URLAdmin(admin.ModelAdmin):
13
    """
David Haynes's avatar
David Haynes committed
14
    Define what attributes display in the URL Admin
15
16
    """

17
18
    list_display = ("target", "short", "owner", "clicks", "date_created", "expires")

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

22
class RegisteredUserInline(admin.StackedInline):
23
    """
David Haynes's avatar
David Haynes committed
24
    Define an inline admin descriptor for User model
25
26
    """

David Haynes's avatar
David Haynes committed
27
28
    model = RegisteredUser
    can_delete = False
29

30
class UserAdmin(UserAdmin):
31
    """
David Haynes's avatar
David Haynes committed
32
    Define a new User admin
33
34
    """

David Haynes's avatar
David Haynes committed
35
36
    # see above class that we defined
    inlines = (RegisteredUserInline, )
37

David Haynes's avatar
David Haynes committed
38
# and modify User to use our new UserAdmin
39
40
admin.site.unregister(User)
admin.site.register(User, UserAdmin)