ernestophone.ens.fr/instruments/models.py
2021-04-29 00:27:33 +02:00

66 lines
2.4 KiB
Python

from django.db import models
from django.db.models.functions import Lower
from django.utils.translation import gettext_lazy as _
class Instrument(models.Model):
model = models.CharField(_("Modèle"), max_length=100, null=True, blank=True)
prix = models.CharField(_("Prix"), max_length=100, default="", blank=True)
etat = models.CharField(
max_length=100,
default="Bon état",
choices=[
("Bon état", _("Bon état")),
("Etat moyen", _("Etat moyen")),
("Mauvais état", _("Mauvais état")),
],
)
marque = models.CharField(_("Marque"), max_length=100, null=True, blank=True)
serial = models.CharField(
_("Numéro de série"), max_length=100, default=" ", null=True, blank=True
)
annee = models.CharField(_("Année d'achat"), max_length=100, null=True, blank=True)
owner = models.CharField(_("Propriétaire"), max_length=100, default="Fanfare")
user = models.CharField(_("Utilisateur"), max_length=100, blank=True)
type = models.CharField(_("Instrument"), max_length=40, blank=False)
statut = models.CharField(
max_length=100,
default="Disponible",
choices=[("Disponible", _("Disponible")), ("Prêté", _("Prêté·e"))],
)
infos = models.TextField(_("Infos utiles"), null=False, blank=True, default="")
infos_en = models.TextField(
"Infos utiles en anglais", null=False, blank=True, default=""
)
def __str__(self):
return self.type
class Meta:
verbose_name = _("Instrument")
verbose_name_plural = _("Instruments")
ordering = (Lower("type"),)
class Reparation(models.Model):
date = models.DateField(_("Date"), max_length=100)
instru = models.ForeignKey(
"Instrument", on_delete=models.CASCADE, verbose_name=_("Instrument")
)
description = models.CharField(
_("Description"), max_length=100, default=" ", blank=True
)
description_en = models.CharField(
_("Description en anglais"), max_length=100, default=" ", blank=True
)
prix = models.CharField(_("Prix"), max_length=100, default="", blank=True)
lieux = models.CharField(_("Lieux"), max_length=100, default=" ", blank=True)
def __str__(self):
return self.description
class Meta:
verbose_name = _("Réparation")
verbose_name_plural = _("Réparations")
ordering = ("date",)