Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-sshkey
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
a2c39f38
authored
Oct 09, 2014
by
Paul Kilgo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a set of ModelAdmin classes
parent
1fc70d80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
6 deletions
+45
-6
django_sshkey/admin.py
+45
-6
No files found.
django_sshkey/admin.py
View file @
a2c39f38
...
@@ -27,26 +27,65 @@
...
@@ -27,26 +27,65 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django_sshkey.models
import
UserKey
from
django.core.urlresolvers
import
reverse
from
django_sshkey.models
import
UserKey
,
Key
class
User
KeyAdmin
(
admin
.
ModelAdmin
):
class
KeyAdmin
(
admin
.
ModelAdmin
):
list_display
=
[
list_display
=
[
'__unicode__'
,
'__unicode__'
,
'user'
,
'created'
,
'name'
,
'last_modified'
,
'last_used'
,
]
readonly_fields
=
[
'fingerprint'
,
'fingerprint'
,
'created'
,
'created'
,
'last_modified'
,
'last_modified'
,
'last_used'
,
'last_used'
,
]
]
search_fields
=
[
search_fields
=
[
'
user__username
'
,
'
fingerprint
'
,
]
]
class
ApplicationKeyAdmin
(
KeyAdmin
):
list_display
=
[
'__unicode__'
,
'basekey'
,
'created'
,
'last_modified'
,
'last_used'
,
]
search_fields
=
[]
# would be quite slow to search on fingerprint
readonly_fields
=
[
readonly_fields
=
[
'fingerprint'
,
'created'
,
'created'
,
'last_modified'
,
'last_modified'
,
'last_used'
,
'last_used'
,
'basekey_link'
,
]
def
basekey_link
(
self
,
obj
):
url
=
reverse
(
'admin:django_sshkey_key_change'
,
args
=
(
obj
.
basekey
.
id
,))
return
'<a href="
%
s">
%
s</a>'
%
(
url
,
obj
.
basekey
)
basekey_link
.
allow_tags
=
True
class
NamedKeyAdmin
(
ApplicationKeyAdmin
):
search_fields
=
[
'name'
,
]
class
UserKeyAdmin
(
NamedKeyAdmin
):
list_display
=
[
'__unicode__'
,
'user'
,
'basekey'
,
'created'
,
'last_modified'
,
'last_used'
,
]
search_fields
=
[
'name'
,
'user__username'
,
]
]
admin
.
site
.
register
(
Key
,
KeyAdmin
)
admin
.
site
.
register
(
UserKey
,
UserKeyAdmin
)
admin
.
site
.
register
(
UserKey
,
UserKeyAdmin
)
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