regluit/marc/admin.py

33 lines
897 B
Python
Raw Normal View History

2016-07-26 14:34:45 +00:00
from django.apps import apps
from django.contrib.admin import ModelAdmin, site
from django.forms import ModelForm
from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField
from .models import MARCRecord, EDITION_MODEL
from .lookups import EditionLookup, OwnerLookup
class MARCRecordAdminForm(ModelForm):
edition = AutoCompleteSelectField(
EditionLookup,
widget=AutoCompleteSelectWidget(EditionLookup),
required=True,
)
user = AutoCompleteSelectField(
OwnerLookup,
widget=AutoCompleteSelectWidget(OwnerLookup),
required=True,
)
class Meta(object):
model = MARCRecord
exclude = ()
class MARCRecordAdmin(ModelAdmin):
list_display = ('edition', 'user')
date_hierarchy = 'created'
form = MARCRecordAdminForm
site.register(MARCRecord, MARCRecordAdmin)