From 1ddc0734dc19392e92372b9a7dc236b61e985ef4 Mon Sep 17 00:00:00 2001 From: nanoy Date: Fri, 21 Dec 2018 21:35:09 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20du=20mod=C3=A8le=20pinte?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gestion/migrations/0002_pinte.py | 25 +++++++++++++++++++++++++ gestion/models.py | 8 ++++++++ 2 files changed, 33 insertions(+) create mode 100644 gestion/migrations/0002_pinte.py diff --git a/gestion/migrations/0002_pinte.py b/gestion/migrations/0002_pinte.py new file mode 100644 index 0000000..93f21fb --- /dev/null +++ b/gestion/migrations/0002_pinte.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1 on 2018-12-21 20:34 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('gestion', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Pinte', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('last_update_date', models.DateTimeField(auto_now=True)), + ('current_owner', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='pinte_owned_currently', to=settings.AUTH_USER_MODEL)), + ('previous_owner', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='pinte_owned_previously', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/gestion/models.py b/gestion/models.py index 33828d6..f69c16e 100644 --- a/gestion/models.py +++ b/gestion/models.py @@ -225,3 +225,11 @@ class Consumption(models.Model): def __str__(self): return "Consommation de " + str(self.customer) + " concernant le produit " + str(self.product) + +class Pinte(models.Model): + """ + Stores a physical pinte + """ + current_owner = models.ForeignKey(User, on_delete=models.PROTECT, null=True, default=None, related_name="pinte_owned_currently") + previous_owner = models.ForeignKey(User, on_delete=models.PROTECT, null=True, default=None, related_name="pinte_owned_previously") + last_update_date = models.DateTimeField(auto_now=True)