add storage to equipment
This commit is contained in:
parent
2a0113412a
commit
177ecdc541
4 changed files with 77 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from django import forms
|
||||
|
||||
from .models import Equipment, EquipmentDefault, EquipmentRevision, EquipmentCategory, EquipmentLost, EquipmentAttributeValue, EquipmentAttribute
|
||||
from .models import Equipment, EquipmentDefault, EquipmentRevision, EquipmentCategory, EquipmentLost, EquipmentAttributeValue, EquipmentAttribute, EquipmentStorage
|
||||
from .fields import IdField, IdWidget
|
||||
|
||||
|
||||
|
@ -69,6 +69,11 @@ class CategoryAdmin(admin.ModelAdmin):
|
|||
search_fields = ['name',]
|
||||
autocomplete_fields = ['parent', ]
|
||||
|
||||
class StorageAdmin(admin.ModelAdmin):
|
||||
list_display = ['name']
|
||||
ordering = ['name']
|
||||
search_fields = ['name']
|
||||
|
||||
|
||||
class EquipmentAttributeAdmin(admin.ModelAdmin):
|
||||
list_display = ['name']
|
||||
|
@ -79,7 +84,7 @@ class EquipmentAttributeAdmin(admin.ModelAdmin):
|
|||
class EquipmentAdmin(admin.ModelAdmin):
|
||||
save_as_continue = True
|
||||
save_on_top = True
|
||||
autocomplete_fields = ['category', ]
|
||||
autocomplete_fields = ['category', 'storage', ]
|
||||
readonly_fields = ['full_category_p',
|
||||
'added_at',
|
||||
'modified_at',
|
||||
|
@ -88,7 +93,7 @@ class EquipmentAdmin(admin.ModelAdmin):
|
|||
'stock_lost_p',
|
||||
'ids_lost_p',
|
||||
]
|
||||
list_display = ['name', 'stock', 'owner', 'category', 'modified_at']
|
||||
list_display = ['name', 'stock', 'owner', 'category', 'storage', 'modified_at']
|
||||
fieldsets = (
|
||||
('Général', {
|
||||
'fields': ('name', 'owner', 'stock', )
|
||||
|
@ -102,8 +107,8 @@ class EquipmentAdmin(admin.ModelAdmin):
|
|||
'ids_lost_p',
|
||||
),
|
||||
}),
|
||||
('Catégorie', {
|
||||
'fields': ('category', 'full_category_p'),
|
||||
('Attributs', {
|
||||
'fields': ('category', 'full_category_p', 'storage'),
|
||||
}),
|
||||
('Description', {
|
||||
'fields': ('description', 'added_at', 'modified_at',),
|
||||
|
@ -119,9 +124,10 @@ class EquipmentAdmin(admin.ModelAdmin):
|
|||
EquipmentLostExtraInline,
|
||||
EquipmentRevisionExtraInline]
|
||||
search_fields = ['name', 'description',]
|
||||
list_filter = ['owner', 'category' ]
|
||||
list_filter = ['owner', 'category', 'storage', ]
|
||||
|
||||
|
||||
admin.site.register(Equipment, EquipmentAdmin)
|
||||
admin.site.register(EquipmentCategory, CategoryAdmin)
|
||||
admin.site.register(EquipmentStorage, StorageAdmin)
|
||||
admin.site.register(EquipmentAttribute, EquipmentAttributeAdmin)
|
||||
|
|
26
equipment/migrations/0015_auto_20190318_1245.py
Normal file
26
equipment/migrations/0015_auto_20190318_1245.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 2.1.5 on 2019-03-18 11:45
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('equipment', '0014_auto_20180827_0005'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='EquipmentStorage',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='nom')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='storage',
|
||||
field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='equipment.EquipmentStorage', verbose_name='stockage'),
|
||||
),
|
||||
]
|
17
equipment/migrations/0016_auto_20190318_1247.py
Normal file
17
equipment/migrations/0016_auto_20190318_1247.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 2.1.5 on 2019-03-18 11:47
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('equipment', '0015_auto_20190318_1245'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='equipmentstorage',
|
||||
options={'verbose_name': 'stockage', 'verbose_name_plural': 'stockages'},
|
||||
),
|
||||
]
|
|
@ -10,6 +10,20 @@ from .fields import IdField
|
|||
from datetime import date
|
||||
|
||||
|
||||
class EquipmentStorage(models.Model):
|
||||
name = models.CharField(
|
||||
_("nom"),
|
||||
max_length=200,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("stockage")
|
||||
verbose_name_plural = _("stockages")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class EquipmentCategory(models.Model):
|
||||
name = models.CharField(
|
||||
_("nom"),
|
||||
|
@ -108,6 +122,14 @@ class Equipment(EventSpecificMixin, models.Model):
|
|||
verbose_name=_("catégorie"),
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
storage = models.ForeignKey(
|
||||
EquipmentStorage,
|
||||
blank=True,
|
||||
null=True,
|
||||
default=None,
|
||||
verbose_name=_("stockage"),
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
|
||||
added_at = models.DateTimeField(
|
||||
_("ajouté le"),
|
||||
|
|
Loading…
Reference in a new issue