Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
649d7608
Commit
649d7608
authored
Nov 17, 2016
by
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
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
go/go/admin.py
View file @
649d7608
...
...
@@ -2,23 +2,33 @@
from
django.contrib
import
admin
from
django.contrib.auth.admin
import
UserAdmin
from
django.contrib.auth.models
import
User
# App Imports
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
):
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
):
model
=
RegisteredUser
can_delete
=
False
# Define a new User admin
"""
Define a new User admin
"""
class
UserAdmin
(
UserAdmin
):
# see above class that we defined
inlines
=
(
RegisteredUserInline
,
)
# Register URLAdmin and modify User to use new UserAdmin
admin
.
site
.
register
(
URL
,
URLAdmin
)
# and modify User to use our new UserAdmin
admin
.
site
.
unregister
(
User
)
admin
.
site
.
register
(
User
,
UserAdmin
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment