PyInventory/inventory/admin/item.py

73 wiersze
2.0 KiB
Python
Czysty Zwykły widok Historia

2020-10-17 16:34:05 +00:00
import tagulous
from adminsortable2.admin import SortableInlineAdminMixin
2020-10-16 15:54:34 +00:00
from django.contrib import admin
2020-10-17 16:34:05 +00:00
from django.utils.translation import ugettext_lazy as _
2020-10-16 15:54:34 +00:00
from inventory.admin.base import BaseUserAdmin
2020-10-17 16:34:05 +00:00
from inventory.models import ItemLinkModel, ItemModel
class ItemLinkModelInline(SortableInlineAdminMixin, admin.TabularInline):
model = ItemLinkModel
extra = 1
2020-10-16 15:54:34 +00:00
@admin.register(ItemModel)
class ItemModelAdmin(BaseUserAdmin):
2020-10-17 16:34:05 +00:00
date_hierarchy = 'create_dt'
list_display = (
'kind', 'producer',
2020-10-17 17:00:39 +00:00
'name',
'parent', 'location',
'received_date', 'update_dt'
2020-10-17 16:34:05 +00:00
)
2020-10-17 17:00:39 +00:00
ordering = ('kind', 'producer', 'name')
2020-10-17 16:34:05 +00:00
list_display_links = ('name',)
list_filter = ('kind', 'location', 'producer', 'tags')
search_fields = ('name', 'description')
fieldsets = (
(_('Internals'), {
'classes': ('collapse',),
'fields': (
'id',
'user',
)
}),
(_('Meta'), {
'classes': ('collapse',),
'fields': (
'create_dt', 'update_dt'
)
}),
(_('Basic'), {'fields': (
'kind',
('producer', 'name'),
'description',
'tags',
'fcc_id',
'parent',
'location',
)}),
(_('Lent'), {
'classes': ('collapse',),
'fields': (
'lent_to',
('lent_from_date', 'lent_until_date',)
)}),
(_('Received'), {
'classes': ('collapse',),
'fields': (
('received_from', 'received_date', 'received_price'),
)}),
(_('Handed over'), {
'classes': ('collapse',),
'fields': (
('handed_over_to', 'handed_over_date', 'handed_over_price'),
)}),
)
readonly_fields = ('id', 'create_dt', 'update_dt', 'user')
inlines = (ItemLinkModelInline,)
tagulous.admin.enhance(ItemModel, ItemModelAdmin)