From 123d524eab413f449325967aee0b8a7158bed434 Mon Sep 17 00:00:00 2001 From: Qwann Date: Thu, 26 Jul 2018 15:53:42 +0200 Subject: [PATCH] start equipement --- equipment/admin.py | 16 ++++++++++ .../migrations/0002_auto_20180713_1321.py | 32 +++++++++++++++++++ .../migrations/0003_auto_20180713_1358.py | 21 ++++++++++++ equipment/models.py | 9 +++++- evenementiel/settings/common.py | 1 + event/migrations/0002_auto_20180713_1321.py | 25 +++++++++++++++ requirements.txt | 1 + 7 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 equipment/admin.py create mode 100644 equipment/migrations/0002_auto_20180713_1321.py create mode 100644 equipment/migrations/0003_auto_20180713_1358.py create mode 100644 event/migrations/0002_auto_20180713_1321.py diff --git a/equipment/admin.py b/equipment/admin.py new file mode 100644 index 0000000..cd665f5 --- /dev/null +++ b/equipment/admin.py @@ -0,0 +1,16 @@ +from django.contrib import admin +from .models import Equipment, EquipmentRemark + + +class EquipmentRemarkExtraInline(admin.TabularInline): + model = EquipmentRemark + extra = 0 + + +class EquipmentAdmin(admin.ModelAdmin): + list_display = ['name', 'stock'] + ordering = ['name'] + inlines = [EquipmentRemarkExtraInline] + + +admin.site.register(Equipment, EquipmentAdmin) diff --git a/equipment/migrations/0002_auto_20180713_1321.py b/equipment/migrations/0002_auto_20180713_1321.py new file mode 100644 index 0000000..47d614a --- /dev/null +++ b/equipment/migrations/0002_auto_20180713_1321.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.14 on 2018-07-13 13:21 +from __future__ import unicode_literals + +from django.db import migrations, models +import taggit.managers + + +class Migration(migrations.Migration): + + dependencies = [ + ('taggit', '0002_auto_20150616_2121'), + ('equipment', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='equipmentremark', + name='amount', + ), + 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'), + ), + migrations.AddField( + model_name='equipmentremark', + name='ids', + field=models.PositiveIntegerField(default=0, verbose_name='Identifiants'), + preserve_default=False, + ), + ] diff --git a/equipment/migrations/0003_auto_20180713_1358.py b/equipment/migrations/0003_auto_20180713_1358.py new file mode 100644 index 0000000..ff94d29 --- /dev/null +++ b/equipment/migrations/0003_auto_20180713_1358.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.14 on 2018-07-13 13:58 +from __future__ import unicode_literals + +from django.db import migrations +import equipment.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('equipment', '0002_auto_20180713_1321'), + ] + + operations = [ + migrations.AlterField( + model_name='equipmentremark', + name='ids', + field=equipment.models.IdField(), + ), + ] diff --git a/equipment/models.py b/equipment/models.py index 6498756..5e91386 100644 --- a/equipment/models.py +++ b/equipment/models.py @@ -3,6 +3,8 @@ from django.core.exceptions import ValidationError from django.utils.translation import ugettext_lazy as _ from event.models import Activity, EventSpecificMixin +from taggit.managers import TaggableManager + class Equipment(EventSpecificMixin, models.Model): name = models.CharField( @@ -17,6 +19,8 @@ class Equipment(EventSpecificMixin, models.Model): through="EquipmentAttribution", ) + tags = TaggableManager() + class Meta: verbose_name = _("matériel") verbose_name_plural = _("matériels") @@ -25,6 +29,9 @@ class Equipment(EventSpecificMixin, models.Model): return self.name +class IdField(models.PositiveIntegerField): + pass + class EquipmentAttribution(models.Model): equipment = models.ForeignKey(Equipment) activity = models.ForeignKey(Activity) @@ -54,7 +61,7 @@ class EquipmentRemark(models.Model): related_name="remarks", help_text=_("Matériel concerné par la remarque"), ) - amount = models.PositiveSmallIntegerField(_("quantité concernée")) + ids = IdField() is_broken = models.BooleanField() is_lost = models.BooleanField() diff --git a/evenementiel/settings/common.py b/evenementiel/settings/common.py index 966a57f..5c7025f 100644 --- a/evenementiel/settings/common.py +++ b/evenementiel/settings/common.py @@ -55,6 +55,7 @@ INSTALLED_APPS = [ 'rest_framework', 'bootstrapform', 'widget_tweaks', + 'taggit', 'api', 'communication', diff --git a/event/migrations/0002_auto_20180713_1321.py b/event/migrations/0002_auto_20180713_1321.py new file mode 100644 index 0000000..02ff589 --- /dev/null +++ b/event/migrations/0002_auto_20180713_1321.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.14 on 2018-07-13 13:21 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('event', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='event', + name='beginning_date', + field=models.DateTimeField(help_text="date publique de l'évènement", verbose_name='date de début'), + ), + migrations.AlterField( + model_name='event', + name='ending_date', + field=models.DateTimeField(help_text="date publique de l'évènement", verbose_name='date de fin'), + ), + ] diff --git a/requirements.txt b/requirements.txt index 3a54f43..f3bd984 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,7 @@ djangorestframework==3.6.3 drf-nested-routers==0.90.0 django-notifications django-contrib-comments +django-taggit # Production specific daphne==1.3.0