Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5549fde5
authored
Feb 27, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: more detailed User admin
parent
7d1cfe97
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
one/admin.py
+15
-2
No files found.
one/admin.py
View file @
5549fde5
...
...
@@ -23,17 +23,30 @@ class DetailsInline(contrib.admin.StackedInline):
can_delete
=
False
class
MyUserAdmin
(
contrib
.
auth
.
admin
.
UserAdmin
):
list_display
=
(
'username'
,
'full_name'
,
'email'
,
'date_joined'
,
'instance_count'
)
list_display
=
(
'username'
,
'full_name'
,
'email'
,
'date_joined'
,
'instance_count'
,
'course_groups'
)
list_filter
=
(
'is_superuser'
,
'is_active'
,
'groups'
,
'person__course_groups'
,
)
try
:
inlines
=
inlines
+
(
PersonInline
,
SshKeyInline
,
DetailsInline
)
except
NameError
:
inlines
=
(
PersonInline
,
SshKeyInline
,
DetailsInline
)
def
instance_count
(
self
,
obj
):
return
obj
.
instance_set
.
count
()
return
_
(
"
%
d (
%
d active)"
)
%
(
obj
.
instance_set
.
count
(),
obj
.
instance_set
.
filter
(
state
=
'ACTIVE'
)
.
count
(),
)
def
course_groups
(
self
,
obj
):
try
:
return
", "
.
join
(
obj
.
person_set
.
all
()[
0
]
.
course_groups
.
all
())
except
:
return
None
def
full_name
(
self
,
obj
):
return
u"
%
s
%
s"
%
(
obj
.
last_name
,
obj
.
first_name
)
full_name
.
admin_order_field
=
'last_name'
ordering
=
[
"-date_joined"
]
contrib
.
admin
.
site
.
unregister
(
contrib
.
auth
.
models
.
User
)
...
...
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