Browse Source

Add serial field on items

Jocelyn Delande 9 years ago
parent
commit
3a756b52ac

+ 3 - 2
hardware_provisioning/admin.py

@@ -13,8 +13,9 @@ admin.site.register(ItemType)
 
 @admin.register(Item)
 class ItemAdmin(admin.ModelAdmin):
-    list_display = ('designation', 'type', 'mac_address', 'owner',
-                    'buy_date', 'is_available')
+    list_display = (
+        'designation', 'type', 'mac_address', 'serial', 'owner',
+        'buy_date', 'is_available')
     list_filter = ('type__name', 'buy_date', 'owner')
     search_fields = ('designation', 'owner')
     actions = ['give_back']

+ 27 - 0
hardware_provisioning/migrations/0005_auto_20160405_1841.py

@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+import hardware_provisioning.fields
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('hardware_provisioning', '0004_auto_20160405_1816'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='item',
+            name='serial',
+            field=models.CharField(help_text='ou toute autre r\xe9f\xe9rence unique)', max_length=250, verbose_name='N\xb0 de s\xe9rie', blank=True),
+            preserve_default=True,
+        ),
+        migrations.AlterField(
+            model_name='item',
+            name='mac_address',
+            field=hardware_provisioning.fields.MACAddressField(help_text='pr\xe9f\xe9rable au n\xb0 de s\xe9rie si possible', max_length=17, null=True, verbose_name='addresse MAC', blank=True),
+            preserve_default=True,
+        ),
+    ]

+ 8 - 2
hardware_provisioning/models.py

@@ -22,8 +22,14 @@ class Item(models.Model):
     type = models.ForeignKey(ItemType, verbose_name='type de matériel',
                              related_name='items')
     designation = models.CharField(max_length=100, verbose_name='désignation')
-    mac_address = MACAddressField(verbose_name='addresse MAC', blank=True,
-                                  null=True)
+    mac_address = MACAddressField(
+        verbose_name='addresse MAC',
+        blank=True, null=True,
+        help_text="préférable au n° de série si possible")
+    serial = models.CharField(
+        verbose_name='N° de série',
+        max_length=250, blank=True,
+        help_text='ou toute autre référence unique)')
     buy_date = models.DateField(verbose_name='date d’achat')
     owner = models.ForeignKey(
         settings.AUTH_USER_MODEL,