Updated the admin interface to use the simple-history admin support for Person history.
- Legacy-Id: 15097
This commit is contained in:
parent
c7d31b44c3
commit
61a16856ad
|
@ -1,7 +1,7 @@
|
|||
from django.contrib import admin
|
||||
import simple_history
|
||||
|
||||
|
||||
from ietf.person.models import Email, Alias, Person, PersonalApiKey, PersonEvent, PersonApiKeyEvent, HistoricalPerson
|
||||
from ietf.person.models import Email, Alias, Person, PersonalApiKey, PersonEvent, PersonApiKeyEvent
|
||||
from ietf.person.name import name_parts
|
||||
|
||||
class EmailAdmin(admin.ModelAdmin):
|
||||
|
@ -22,7 +22,7 @@ admin.site.register(Alias, AliasAdmin)
|
|||
class AliasInline(admin.StackedInline):
|
||||
model = Alias
|
||||
|
||||
class PersonAdmin(admin.ModelAdmin):
|
||||
class PersonAdmin(simple_history.admin.SimpleHistoryAdmin):
|
||||
def plain_name(self, obj):
|
||||
prefix, first, middle, last, suffix = name_parts(obj.name)
|
||||
return "%s %s" % (first, last)
|
||||
|
@ -53,12 +53,3 @@ class PersonApiKeyEventAdmin(admin.ModelAdmin):
|
|||
admin.site.register(PersonApiKeyEvent, PersonApiKeyEventAdmin)
|
||||
|
||||
|
||||
class HistoricalPersonAdmin(admin.ModelAdmin):
|
||||
def plain_name(self, obj):
|
||||
prefix, first, middle, last, suffix = name_parts(obj.name)
|
||||
return "%s %s" % (first, last)
|
||||
list_display = ["history_date", "name", "plain_name", "time", "history_user", "history_change_reason", ]
|
||||
search_fields = ["name", "ascii"]
|
||||
raw_id_fields = ["user", "history_user", ]
|
||||
# actions = None
|
||||
admin.site.register(HistoricalPerson, HistoricalPersonAdmin)
|
||||
|
|
|
@ -307,8 +307,11 @@ class AdminTestCase(TestCase):
|
|||
#
|
||||
model_list = apps.get_app_config(name).get_models()
|
||||
for model in model_list:
|
||||
self.assertContains(r, model._meta.model_name,
|
||||
msg_prefix="There doesn't seem to be any admin API for model %s.models.%s"%(app.__name__,model.__name__,))
|
||||
if model.__name__.startswith('Historical') and hasattr(model, "get_history_type_display"):
|
||||
continue
|
||||
else:
|
||||
self.assertContains(r, model._meta.model_name,
|
||||
msg_prefix="There doesn't seem to be any admin API for model %s.models.%s"%(app.__name__,model.__name__,))
|
||||
|
||||
## One might think that the code below would work, but it doesn't ...
|
||||
|
||||
|
|
Loading…
Reference in a new issue