Commit b2c28d2a authored by jocelyn's avatar jocelyn

Enhance items fields choice in admin list view

- better fields ordering
- add a « current borrower » field
- merge « serial » and « MAC » fields
parent 06a285b1
......@@ -59,8 +59,12 @@ class AvailabilityFilter(admin.SimpleListFilter):
@admin.register(Item)
class ItemAdmin(admin.ModelAdmin):
list_display = (
'designation', 'mac_address', 'serial', 'owner',
'buy_date', 'deployed', 'is_available', 'storage')
'designation',
'current_borrower',
'get_mac_and_serial',
'deployed', 'is_available', 'storage',
'buy_date', 'owner',
)
list_filter = (
AvailabilityFilter, 'type', 'storage',
'buy_date', OwnerFilter)
......
......@@ -102,6 +102,14 @@ class Item(models.Model):
is_available.boolean = True
is_available.short_description = 'disponible'
def current_borrower(self):
current_loan = self.loans.running().first()
if current_loan:
return current_loan.user
else:
return None
current_borrower.short_description = 'Prêté à'
def get_mac_and_serial(self):
mac = self.mac_address
serial = self.serial
......@@ -109,6 +117,7 @@ class Item(models.Model):
return "{} / {}".format(mac, serial)
else:
return mac or serial or ''
get_mac_and_serial.short_description = 'Adresse MAC / n° de série'
class Meta:
verbose_name = 'objet'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment