Browse Source

Merge branch 'mac_serial_loan' of Sim/coin into master

daimrod 7 years ago
parent
commit
697bb03c67
2 changed files with 11 additions and 1 deletions
  1. 1 1
      hardware_provisioning/admin.py
  2. 10 0
      hardware_provisioning/models.py

+ 1 - 1
hardware_provisioning/admin.py

@@ -121,7 +121,7 @@ class BorrowerFilter(admin.SimpleListFilter):
 
 @admin.register(Loan)
 class LoanAdmin(admin.ModelAdmin):
-    list_display = ('item', 'user', 'loan_date', 'loan_date_end')
+    list_display = ('item', 'get_mac_or_serial', 'user', 'loan_date', 'loan_date_end')
     list_filter = (StatusFilter, BorrowerFilter, 'item__designation')
     search_fields = (
         'item__designation',

+ 10 - 0
hardware_provisioning/models.py

@@ -128,6 +128,16 @@ class Loan(models.Model):
         return 'prêt de {item} à {user}'.format(
             item=self.item, user=self.user)
 
+    def get_mac_or_serial(self):
+        mac = self.item.mac_address
+        serial = self.item.serial
+        if mac and serial:
+            return "{} / {}".format(mac, serial)
+        else:
+            return mac or serial or ''
+
+    get_mac_or_serial.short_description = "Adresse MAC / n° de série"
+
     def user_can_close(self, user):
         return (not self.item.is_available()) and (self.user == user)