Models #8
7 changed files with 3 additions and 87 deletions
|
@ -1,3 +0,0 @@
|
||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
|
@ -1,5 +0,0 @@
|
||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class EquipementConfig(AppConfig):
|
|
||||||
name = 'equipement'
|
|
|
@ -1,73 +0,0 @@
|
||||||
from django.db import models
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
|
|
||||||
from event.models import Event, Activity
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractEquipement(models.Model):
|
|
||||||
name = models.CharField(
|
|
||||||
_("Nom du matériel"),
|
|
||||||
max_length=200,
|
|
||||||
)
|
|
||||||
stock = models.PositieSmallIntegerField(_("Quantité disponible"))
|
|
||||||
description = models.TextField(_("Description"))
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _("matériel abstrait")
|
|
||||||
verbose_name_plural = _("matériels abstraits")
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
class Equipement(AbstractEquipement):
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _("matériel permanent")
|
|
||||||
verbose_name_plural = _("matériels permanents")
|
|
||||||
|
|
||||||
|
|
||||||
class TemporaryEquipement(AbstractEquipement):
|
|
||||||
event = models.ForeignKey(
|
|
||||||
Event,
|
|
||||||
related_name="specific_equipement",
|
|
||||||
help_text=_("Évènement pour lequel le matériel "
|
|
||||||
"a été loué ou empreinté ou apporté"),
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _("matériel temporaire")
|
|
||||||
verbose_name_plural = _("matériels temporaires")
|
|
||||||
|
|
||||||
|
|
||||||
class EquipementAttribution(models.Model):
|
|
||||||
equipement = models.ForeignKey(AbstractEquipement)
|
|
||||||
activity = models.ForeignKey(Activity)
|
|
||||||
amount = models.PositiveSmallIntegerField(_("Quantité attribuée"))
|
|
||||||
remarks = models.TextField("Remarques concernant l'attribution")
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _("attribution de matériel")
|
|
||||||
verbose_name_plural = _("attributions de matériel")
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.equipement.name +\
|
|
||||||
" (" + self.amout + ") " +\
|
|
||||||
" -> " + self.activity.get_herited('title')
|
|
||||||
|
|
||||||
|
|
||||||
class EquipementRemark(models.Model):
|
|
||||||
remark = models.TextField("Remarque sur le matériel")
|
|
||||||
equipement = models.ForeignKey(
|
|
||||||
AbstractEquipement,
|
|
||||||
related_name="remarks",
|
|
||||||
help_text=_("Matériel concerné par la remarque"),
|
|
||||||
)
|
|
||||||
is_broken = models.BooleanField()
|
|
||||||
is_lost = models.BooleanField()
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
verbose_name = _("remarque sur matériel")
|
|
||||||
verbose_name_plural = _("remarques sur le matériel")
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.equipement.name + " : " + self.remark
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
|
@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'equipment.apps.EquipmentConfig',
|
||||||
'event.apps.EventConfig',
|
'event.apps.EventConfig',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
|
@ -43,6 +44,7 @@ INSTALLED_APPS = [
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = [
|
MIDDLEWARE_CLASSES = [
|
||||||
|
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
@ -131,6 +133,7 @@ USE_TZ = True
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
|
||||||
def show_toolbar(request):
|
def show_toolbar(request):
|
||||||
"""
|
"""
|
||||||
On ne veut pas la vérification de INTERNAL_IPS faite par la debug-toolbar
|
On ne veut pas la vérification de INTERNAL_IPS faite par la debug-toolbar
|
||||||
|
|
Loading…
Add table
Reference in a new issue