Browse Source

added admin classes for hardware provisioning

Damien Nicolas 9 years ago
parent
commit
3acf67cbf4

+ 1 - 0
hardware_provisioning/__init__.py

@@ -0,0 +1 @@
+default_app_config = 'hardware_provisioning.app.HardwareProvisioningConfig'

+ 21 - 1
hardware_provisioning/admin.py

@@ -1,3 +1,23 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
 from django.contrib import admin
+from .models import ItemType, Item, Loan
+
+
+admin.site.register(ItemType)
+
+
+@admin.register(Item)
+class ItemAdmin(admin.ModelAdmin):
+    list_display = ('type', 'designation', 'mac_address', 'user_in_charge',
+                    'buy_date', 'is_available')
+    list_filter = ('type__name', 'buy_date')
+    search_fields = ('designation', 'user_in_charge')
+
 
-# Register your models here.
+@admin.register(Loan)
+class LoanAdmin(admin.ModelAdmin):
+    list_display = ('item', 'user', 'loan_date', 'loan_date_end', 'location')
+    list_filter = ('item__designation', 'user__username')
+    search_fields = ('item', 'user')

+ 9 - 0
hardware_provisioning/app.py

@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+
+from __future__ import unicode_literals
+from django.apps import AppConfig
+
+
+class HardwareProvisioningConfig(AppConfig):
+    name = 'hardware_provisioning'
+    verbose_name = 'prêt de matériel'

+ 2 - 0
hardware_provisioning/models.py

@@ -50,6 +50,8 @@ class Item(models.Model):
         if self.loans.filter(loan_date_end__isnull=True).count():
             return False
         return True
+    is_available.boolean = True
+    is_available.short_description = 'disponible'
 
     class Meta:
         verbose_name = 'objet'