From 233d68c64b8745918e120daf8d964655ea4a59ca Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 2 Jul 2016 18:30:59 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20une=20table=20cotisation=20sp=C3=A9cif?= =?UTF-8?q?ique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/admin.py | 11 +++- .../migrations/0008_auto_20160702_1614.py | 50 ++++++++++++++++++ .../migrations/0009_remove_cotisation_user.py | 18 +++++++ .../0008_auto_20160702_1614.cpython-34.pyc | Bin 0 -> 1477 bytes ...0009_remove_cotisation_user.cpython-34.pyc | Bin 0 -> 619 bytes cotisations/models.py | 13 ++++- 6 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 cotisations/migrations/0008_auto_20160702_1614.py create mode 100644 cotisations/migrations/0009_remove_cotisation_user.py create mode 100644 cotisations/migrations/__pycache__/0008_auto_20160702_1614.cpython-34.pyc create mode 100644 cotisations/migrations/__pycache__/0009_remove_cotisation_user.cpython-34.pyc diff --git a/cotisations/admin.py b/cotisations/admin.py index a26ed35c..03a7efbe 100644 --- a/cotisations/admin.py +++ b/cotisations/admin.py @@ -1,12 +1,12 @@ from django.contrib import admin -from .models import Facture, Article, Banque, Paiement +from .models import Facture, Article, Banque, Paiement, Cotisation class FactureAdmin(admin.ModelAdmin): list_display = ('user','paiement','name', 'number', 'date') class ArticleAdmin(admin.ModelAdmin): - list_display = ('name','prix') + list_display = ('name','prix','cotisation') class BanqueAdmin(admin.ModelAdmin): list_display = ('name',) @@ -14,7 +14,14 @@ class BanqueAdmin(admin.ModelAdmin): class PaiementAdmin(admin.ModelAdmin): list_display = ('moyen',) +class PaiementAdmin(admin.ModelAdmin): + list_display = ('moyen',) + +class CotisationAdmin(admin.ModelAdmin): + list_display = ('facture','date_start','date_end') + admin.site.register(Facture, FactureAdmin) admin.site.register(Article, ArticleAdmin) admin.site.register(Banque, BanqueAdmin) admin.site.register(Paiement, PaiementAdmin) +admin.site.register(Cotisation, CotisationAdmin) diff --git a/cotisations/migrations/0008_auto_20160702_1614.py b/cotisations/migrations/0008_auto_20160702_1614.py new file mode 100644 index 00000000..54d6de67 --- /dev/null +++ b/cotisations/migrations/0008_auto_20160702_1614.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0005_auto_20160702_0006'), + ('cotisations', '0007_auto_20160702_1543'), + ] + + operations = [ + migrations.CreateModel( + name='Cotisation', + fields=[ + ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('date_start', models.DateTimeField(auto_now_add=True)), + ('date_end', models.DateTimeField()), + ], + ), + migrations.AddField( + model_name='article', + name='cotisation', + field=models.BooleanField(default=True), + preserve_default=False, + ), + migrations.AddField( + model_name='article', + name='duration', + field=models.DurationField(blank=True, null=True), + ), + migrations.AddField( + model_name='facture', + name='valid', + field=models.BooleanField(default=True), + ), + migrations.AddField( + model_name='cotisation', + name='facture', + field=models.ForeignKey(to='cotisations.Facture', on_delete=django.db.models.deletion.PROTECT), + ), + migrations.AddField( + model_name='cotisation', + name='user', + field=models.ForeignKey(to='users.User', on_delete=django.db.models.deletion.PROTECT), + ), + ] diff --git a/cotisations/migrations/0009_remove_cotisation_user.py b/cotisations/migrations/0009_remove_cotisation_user.py new file mode 100644 index 00000000..4dc65e9a --- /dev/null +++ b/cotisations/migrations/0009_remove_cotisation_user.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cotisations', '0008_auto_20160702_1614'), + ] + + operations = [ + migrations.RemoveField( + model_name='cotisation', + name='user', + ), + ] diff --git a/cotisations/migrations/__pycache__/0008_auto_20160702_1614.cpython-34.pyc b/cotisations/migrations/__pycache__/0008_auto_20160702_1614.cpython-34.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eeebbd86244bfe373259d96b0e9153c31faadbf9 GIT binary patch literal 1477 zcmZ`(OLN;c5MDk-(Q=|Xah`o8O`Fk0l3m-$p_50Qy3@%d=_KxSMi&gNg)~$sQUyt? z*46zp{Y!i8rMct>55J-d=)pe>^guc=X}~FC8-NbH>iBP% z6gn2Q%QPNlC`A$%QbkGLu_>I!V-*!~mgeM7c{0hL4>f-IwApyXEiWwq2|6MUXkY{0 z0sJ1uwvI`{og20D z6o7|ghrzbyXR1qpm(4DlfL9ER$*+r z&oF-k@4u9D{q%fQD{a`MIe?jf=_U85OVedFnz4?6JQ*t}&ol&;8 zx<-0@=I)w0!%nwP|fSZ1Hb{$CY)h?lJ~YDv;nAvNUN`6_60BR0$>+U_k0(h1#uB<)he1BUsDJ@Je2p zSP(N4=M)qy`*imG@9yXO>>YStAJxN>0KCJ$MbV$)Q8P3gH-Q8oB`_yI%-w>-g4Bk& z4Jm~=1#-=8;1pglNI}@JZov-YE#NJ<_ni+c1U}LIGK&{E7c7YjA)`e3miE$kC8HwF zGo_srgNa%g`QK`xGsUCEXapDtWSCpPJFr3~8w54|_5|3EJFo-GgdE^)Z0~CK=C6nD zF7hH)zx__aFg#;XS>$XK4kzJhIAX)eaEwp}gk@1GwAW;4TEEaz33=;VFaL|lHuCvx z-C=baW7=a3%an;gzsJ~986_s&+_>0?jEig$3ngt#)ZIIg=38+Ui-c=0-{5%anY@8K z#CUDKXTdg-K~+_O6r((7z*NvoF~CoqGg+5ojf5HK!RA?-ff`oTLDREc>Jo?4ueZKq upqFJ)O2m{F3bf1DQMSql{ILd=6d!AK!?pL0jJk8N|MI2DRYu#lj_n`NI-kY> literal 0 HcmV?d00001 diff --git a/cotisations/models.py b/cotisations/models.py index 206bdb1a..195a70c8 100644 --- a/cotisations/models.py +++ b/cotisations/models.py @@ -13,13 +13,16 @@ class Facture(models.Model): date = models.DateTimeField(auto_now_add=True) name = models.CharField(max_length=255) prix = models.DecimalField(max_digits=5, decimal_places=2) + valid = models.BooleanField(default=True) def __str__(self): - return str(self.name) + return str(self.name) + ' ' + str(self.date) + ' ' + str(self.user) class Article(models.Model): name = models.CharField(max_length=255) prix = models.DecimalField(max_digits=5, decimal_places=2) + cotisation = models.BooleanField() + duration = models.DurationField(blank=True, null=True) def __str__(self): return self.name @@ -36,6 +39,14 @@ class Paiement(models.Model): def __str__(self): return self.moyen +class Cotisation(models.Model): + facture = models.ForeignKey('Facture', on_delete=models.PROTECT) + date_start = models.DateTimeField(auto_now_add=True) + date_end = models.DateTimeField() + + def __str__(self): + return str(self.facture) + class NewFactureForm(ModelForm): article = forms.ModelMultipleChoiceField(queryset=Article.objects.all(), label="Article")