owner+pole+category-tags
This commit is contained in:
parent
ecdcc0e949
commit
7ab4dcede0
4 changed files with 112 additions and 46 deletions
|
@ -1,7 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from django import forms
|
||||
|
||||
from .models import Equipment, EquipmentRemark, EquipmentRevision
|
||||
from .models import Equipment, EquipmentRemark, EquipmentRevision, EquipmentOwner, EquipmentPole, EquipmentCategory
|
||||
from .fields import IdField, IdWidget
|
||||
|
||||
from shared.admin import admin_site
|
||||
|
@ -34,12 +34,19 @@ class IdFormset(forms.models.BaseInlineFormSet):
|
|||
class EquipmentRevisionExtraInline(admin.TabularInline):
|
||||
model = EquipmentRevision
|
||||
extra = 0
|
||||
form = IdForm
|
||||
formset = IdFormset
|
||||
|
||||
|
||||
class EquipmentRemarkExtraInline(admin.TabularInline):
|
||||
model = EquipmentRemark
|
||||
extra = 0
|
||||
form = IdForm
|
||||
formset = IdFormset
|
||||
|
||||
class CharFieldModelAdmin(admin.ModelAdmin):
|
||||
list_display = ['name']
|
||||
ordering = ['name']
|
||||
|
||||
class EquipmentAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'stock']
|
||||
|
@ -48,4 +55,7 @@ class EquipmentAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
admin_site.register(Equipment, EquipmentAdmin)
|
||||
admin_site.register(EquipmentOwner, CharFieldModelAdmin)
|
||||
admin_site.register(EquipmentPole, CharFieldModelAdmin)
|
||||
admin_site.register(EquipmentCategory, CharFieldModelAdmin)
|
||||
admin.site.register(Equipment, EquipmentAdmin)
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.15 on 2018-08-06 07:51
|
||||
# Generated by Django 1.11.11 on 2018-08-06 15:04
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import equipment.fields
|
||||
import taggit.managers
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -14,7 +12,6 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('taggit', '0002_auto_20150616_2121'),
|
||||
('event', '0001_initial'),
|
||||
]
|
||||
|
||||
|
@ -46,12 +43,45 @@ class Migration(migrations.Migration):
|
|||
'verbose_name_plural': 'attributions de matériel',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EquipmentCategory',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='nom')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'pôle',
|
||||
'verbose_name_plural': 'pôles',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EquipmentOwner',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='nom')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'propriétaire de matériel',
|
||||
'verbose_name_plural': 'propriétaires de matériel',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EquipmentPole',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200, verbose_name='nom')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'catégorie',
|
||||
'verbose_name_plural': 'catégories',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='EquipmentRemark',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('remark', models.TextField(verbose_name='remarque sur le matériel')),
|
||||
('ids', equipment.fields.IdField()),
|
||||
('ide', models.PositiveSmallIntegerField(verbose_name='id')),
|
||||
('is_broken', models.BooleanField()),
|
||||
('is_lost', models.BooleanField()),
|
||||
('equipment', models.ForeignKey(help_text='Matériel concerné par la remarque', on_delete=django.db.models.deletion.CASCADE, related_name='remarks', to='equipment.Equipment')),
|
||||
|
@ -67,7 +97,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('date', models.DateField(default=datetime.date.today, verbose_name='date')),
|
||||
('remark', models.TextField(verbose_name='remarque sur la révision')),
|
||||
('ids', equipment.fields.IdField()),
|
||||
('ide', models.PositiveSmallIntegerField(verbose_name='id')),
|
||||
('equipment', models.ForeignKey(help_text='Matériel concerné par les révisions', on_delete=django.db.models.deletion.CASCADE, related_name='revisions', to='equipment.Equipment')),
|
||||
],
|
||||
options={
|
||||
|
@ -80,6 +110,11 @@ class Migration(migrations.Migration):
|
|||
name='activities',
|
||||
field=models.ManyToManyField(related_name='equipment', through='equipment.EquipmentAttribution', to='event.Activity'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='category',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='equipment.EquipmentCategory'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='event',
|
||||
|
@ -87,7 +122,12 @@ class Migration(migrations.Migration):
|
|||
),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='tags',
|
||||
field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'),
|
||||
name='owner',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='equipment.EquipmentOwner'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipment',
|
||||
name='pole',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='equipment.EquipmentPole'),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.11 on 2018-08-06 14:03
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('equipment', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='equipmentremark',
|
||||
name='ids',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='equipmentrevision',
|
||||
name='ids',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipmentremark',
|
||||
name='ide',
|
||||
field=models.PositiveSmallIntegerField(default=0, verbose_name='id'),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='equipmentrevision',
|
||||
name='ide',
|
||||
field=models.PositiveSmallIntegerField(default=0, verbose_name='id'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
|
@ -9,6 +9,48 @@ from taggit.managers import TaggableManager
|
|||
from datetime import date
|
||||
|
||||
|
||||
class EquipmentOwner(models.Model):
|
||||
name = models.CharField(
|
||||
_("nom"),
|
||||
max_length=200,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("propriétaire de matériel")
|
||||
verbose_name_plural = _("propriétaires de matériel")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class EquipmentPole(models.Model):
|
||||
name = models.CharField(
|
||||
_("nom"),
|
||||
max_length=200,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("catégorie")
|
||||
verbose_name_plural = _("catégories")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class EquipmentCategory(models.Model):
|
||||
name = models.CharField(
|
||||
_("nom"),
|
||||
max_length=200,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("pôle")
|
||||
verbose_name_plural = _("pôles")
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Equipment(EventSpecificMixin, models.Model):
|
||||
name = models.CharField(
|
||||
_("nom du matériel"),
|
||||
|
@ -21,8 +63,17 @@ class Equipment(EventSpecificMixin, models.Model):
|
|||
related_name="equipment",
|
||||
through="EquipmentAttribution",
|
||||
)
|
||||
|
||||
tags = TaggableManager()
|
||||
owner = models.ForeignKey(
|
||||
EquipmentOwner,
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
pole = models.ForeignKey(
|
||||
EquipmentPole,
|
||||
)
|
||||
category = models.ForeignKey(
|
||||
EquipmentCategory,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("matériel")
|
||||
|
|
Loading…
Reference in a new issue