start equipement

This commit is contained in:
Qwann 2018-07-26 15:53:42 +02:00
parent 328f3d7852
commit 123d524eab
7 changed files with 104 additions and 1 deletions

16
equipment/admin.py Normal file
View file

@ -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)

View file

@ -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,
),
]

View file

@ -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(),
),
]

View file

@ -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()

View file

@ -55,6 +55,7 @@ INSTALLED_APPS = [
'rest_framework',
'bootstrapform',
'widget_tweaks',
'taggit',
'api',
'communication',

View file

@ -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'),
),
]

View file

@ -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