feat(fournitures): ajoute un fichier joint ; typiquement pour centraliser les certificats
This commit is contained in:
parent
bc7aba0cb5
commit
e216451162
@ -38,9 +38,17 @@ class PainAdmin(admin.ModelAdmin):
|
||||
admin_site.register(models.Pain, PainAdmin)
|
||||
|
||||
|
||||
class DocumentInline(admin.TabularInline):
|
||||
model = models.Document
|
||||
extra = 1
|
||||
|
||||
|
||||
class FournitureAdmin(admin.ModelAdmin):
|
||||
list_display = ["nom", "ordre", "couleur", "conditionnement", "emballage"]
|
||||
list_editable = ["ordre", "couleur", "conditionnement", "emballage"]
|
||||
inlines = [
|
||||
DocumentInline,
|
||||
]
|
||||
actions = None
|
||||
save_as = True
|
||||
|
||||
|
45
fournée/core/migrations/0015_document.py
Normal file
45
fournée/core/migrations/0015_document.py
Normal file
@ -0,0 +1,45 @@
|
||||
# Generated by Django 4.2.13 on 2024-05-15 10:19
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import fournée.core.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("core", "0014_fourniture_emballage"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Document",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.AutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("nom", models.CharField(max_length=64, unique=True)),
|
||||
(
|
||||
"fichier",
|
||||
models.FileField(
|
||||
upload_to=fournée.core.models.upload_to, verbose_name="Fichier"
|
||||
),
|
||||
),
|
||||
(
|
||||
"fourniture",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="core.fourniture",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"ordering": ["nom"],
|
||||
},
|
||||
),
|
||||
]
|
@ -0,0 +1,23 @@
|
||||
# Generated by Django 4.2.13 on 2024-05-15 10:37
|
||||
|
||||
from django.db import migrations, models
|
||||
import fournée.core.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("core", "0015_document"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="document",
|
||||
name="fichier",
|
||||
field=models.FileField(upload_to=fournée.core.models.upload_to),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="fourniture",
|
||||
name="conditionnement",
|
||||
field=models.DecimalField(decimal_places=3, default=0, max_digits=6),
|
||||
),
|
||||
]
|
@ -1,8 +1,14 @@
|
||||
from uuid import uuid4
|
||||
|
||||
from django.db import models
|
||||
|
||||
from colorfield.fields import ColorField
|
||||
|
||||
|
||||
def upload_to(instance, filename):
|
||||
return "{}/{}".format(uuid4(), filename)
|
||||
|
||||
|
||||
class Fournée(models.Model):
|
||||
class Meta:
|
||||
ordering = ["-date"]
|
||||
@ -26,6 +32,18 @@ class Fournée(models.Model):
|
||||
])
|
||||
|
||||
|
||||
class Document(models.Model):
|
||||
class Meta:
|
||||
ordering = ["nom"]
|
||||
|
||||
fourniture = models.ForeignKey("Fourniture", on_delete=models.CASCADE)
|
||||
nom = models.CharField(max_length=64, unique=True)
|
||||
fichier = models.FileField(upload_to=upload_to)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.nom}"
|
||||
|
||||
|
||||
class Fourniture(models.Model):
|
||||
class Meta:
|
||||
ordering = ["ordre"]
|
||||
|
Loading…
Reference in New Issue
Block a user