Parcourir la source

Turns user_in_charge into an optional owner field.

Jocelyn Delande il y a 9 ans
Parent
commit
b5b532e370

+ 3 - 3
hardware_provisioning/admin.py

@@ -13,10 +13,10 @@ admin.site.register(ItemType)
 
 @admin.register(Item)
 class ItemAdmin(admin.ModelAdmin):
-    list_display = ('designation', 'type', 'mac_address', 'user_in_charge',
+    list_display = ('designation', 'type', 'mac_address', 'owner',
                     'buy_date', 'is_available')
-    list_filter = ('type__name', 'buy_date')
-    search_fields = ('designation', 'user_in_charge')
+    list_filter = ('type__name', 'buy_date', 'owner')
+    search_fields = ('designation', 'owner')
     actions = ['give_back']
 
     def give_back(self, request, queryset):

+ 15 - 0
hardware_provisioning/migrations/0003_auto_20160405_1812.py

@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('hardware_provisioning', '0002_auto_20150625_2313'),
+    ]
+
+    operations = [
+        migrations.RenameField('item', 'user_in_charge', 'owner')
+    ]

+ 21 - 0
hardware_provisioning/migrations/0004_auto_20160405_1816.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+from django.conf import settings
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('hardware_provisioning', '0003_auto_20160405_1812'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='item',
+            name='owner',
+            field=models.ForeignKey(related_name='items', blank=True, to=settings.AUTH_USER_MODEL, help_text="dans le cas de mat\xe9riel n'appartenant pas \xe0 l'association", null=True, verbose_name='Propri\xe9taire'),
+            preserve_default=True,
+        ),
+    ]

+ 6 - 3
hardware_provisioning/models.py

@@ -25,9 +25,12 @@ class Item(models.Model):
     mac_address = MACAddressField(verbose_name='addresse MAC', blank=True,
                                   null=True)
     buy_date = models.DateField(verbose_name='date d’achat')
-    user_in_charge = models.ForeignKey(settings.AUTH_USER_MODEL,
-                                       verbose_name='membre responsable',
-                                       related_name='items')
+    owner = models.ForeignKey(
+        settings.AUTH_USER_MODEL,
+        verbose_name='Propriétaire',
+        related_name='items',
+        null=True, blank=True,
+        help_text="dans le cas de matériel n'appartenant pas à l'association")
     comment = models.TextField(verbose_name='commentaire', blank=True,
                                null=True)