Add a link to user in host admin, fix #440
This commit is contained in:
parent
daac6aeaee
commit
bcae9584ff
@ -3,6 +3,8 @@ register our models for Django's admin
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from .models import Host, RelatedHost, Domain, BlacklistedHost, ServiceUpdater, ServiceUpdaterHostConfig
|
from .models import Host, RelatedHost, Domain, BlacklistedHost, ServiceUpdater, ServiceUpdaterHostConfig
|
||||||
|
|
||||||
@ -16,10 +18,19 @@ class DomainAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.register(Host)
|
@admin.register(Host)
|
||||||
class HostAdmin(admin.ModelAdmin):
|
class HostAdmin(admin.ModelAdmin):
|
||||||
list_display = ("name", "domain", "created_by", "client_faults", "api_auth_faults", "abuse", "abuse_blocked")
|
list_display = ("name", "domain", "created_by_link", "client_faults", "api_auth_faults", "abuse", "abuse_blocked")
|
||||||
list_filter = ("created", "abuse", "abuse_blocked", "domain")
|
list_filter = ("created", "abuse", "abuse_blocked", "domain")
|
||||||
|
read_only_fields = ('created_by_link',)
|
||||||
|
|
||||||
search_fields = ("name", "created_by__username", "created_by__email")
|
search_fields = ("name", "created_by__username", "created_by__email")
|
||||||
|
|
||||||
|
def created_by_link(self, obj):
|
||||||
|
return mark_safe('<a href="{}">{}</a>'.format(
|
||||||
|
reverse("admin:auth_user_change", args=(obj.created_by.pk,)),
|
||||||
|
obj.created_by.username
|
||||||
|
))
|
||||||
|
created_by_link.short_description = 'created by'
|
||||||
|
|
||||||
|
|
||||||
@admin.register(RelatedHost)
|
@admin.register(RelatedHost)
|
||||||
class RelatedHostAdmin(admin.ModelAdmin):
|
class RelatedHostAdmin(admin.ModelAdmin):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user