From 9d56b6ecbf3ff6018945b32f2528eca0d0ea7d57 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 16 Jul 2019 09:17:46 +0200 Subject: [PATCH] Fix note migration --- note/migrations/0001_initial.py | 20 ++++++++++---------- note/models.py | 22 ++++++++-------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/note/migrations/0001_initial.py b/note/migrations/0001_initial.py index 5f777cac..b694bbf9 100644 --- a/note/migrations/0001_initial.py +++ b/note/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.3 on 2019-07-08 14:08 +# Generated by Django 2.2.3 on 2019-07-16 07:17 from django.conf import settings from django.db import migrations, models @@ -19,8 +19,8 @@ class Migration(migrations.Migration): name='NoteClub', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('solde', models.IntegerField(help_text="en centime, l' argent crédité pour cette instance", verbose_name='solde du compte')), - ('active', models.BooleanField(default=True, verbose_name='etat du compte')), + ('balance', models.DecimalField(decimal_places=2, default=0, help_text='money credited for this instance', max_digits=8, verbose_name='account balance')), + ('is_active', models.BooleanField(default=True, verbose_name='is active')), ], options={ 'abstract': False, @@ -30,9 +30,9 @@ class Migration(migrations.Migration): name='NoteSpec', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('solde', models.IntegerField(help_text="en centime, l' argent crédité pour cette instance", verbose_name='solde du compte')), - ('active', models.BooleanField(default=True, verbose_name='etat du compte')), - ('account_type', models.CharField(choices=[('CH', 'chèques'), ('CB', 'Carte Bancaire'), ('VB', 'Virement Bancaire'), ('CA', 'Cash'), ('RB', 'Remboursement')], max_length=2, unique=True)), + ('balance', models.DecimalField(decimal_places=2, default=0, help_text='money credited for this instance', max_digits=8, verbose_name='account balance')), + ('is_active', models.BooleanField(default=True, verbose_name='is active')), + ('account_type', models.CharField(choices=[('CH', 'bank check'), ('CB', 'credit card'), ('VB', 'bank transfer'), ('CA', 'cash'), ('RB', 'refund')], max_length=2, unique=True)), ], options={ 'abstract': False, @@ -42,13 +42,13 @@ class Migration(migrations.Migration): name='NoteUser', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('solde', models.IntegerField(help_text="en centime, l' argent crédité pour cette instance", verbose_name='solde du compte')), - ('active', models.BooleanField(default=True, verbose_name='etat du compte')), + ('balance', models.DecimalField(decimal_places=2, default=0, help_text='money credited for this instance', max_digits=8, verbose_name='account balance')), + ('is_active', models.BooleanField(default=True, verbose_name='is active')), ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], options={ - 'verbose_name': "One's Note", - 'verbose_name_plural': 'Users Note', + 'verbose_name': "one's note", + 'verbose_name_plural': 'users note', }, ), migrations.CreateModel( diff --git a/note/models.py b/note/models.py index d0f088c0..8424355d 100644 --- a/note/models.py +++ b/note/models.py @@ -41,6 +41,8 @@ class Note(models.Model): verbose_name=_('account balance'), help_text=_("money credited for this instance"), decimal_places=2, # Limit to centimes + max_digits=8, # Limit to 999999,99€ + default=0, ) is_active = models.BooleanField( default=True, @@ -64,27 +66,19 @@ class NoteUser(Note): verbose_name = _("one's note") verbose_name_plural = _("users note") - def __str__(self): - return self.user.get_username() - class NoteSpec(Note): """ - A Note for special Account, where real money enter or leave the system. - - Cash - - Credit Card - - Bank Transfert - - Bank Check - - Refund + A Note for special account, where real money enter or leave the system """ account_type = models.CharField( max_length=2, choices=( - ("CH", "chèques"), - ("CB", "Carte Bancaire"), - ("VB", "Virement Bancaire"), - ("CA", "Cash"), - ("RB", "Remboursement") + ("CH", _("bank check")), + ("CB", _("credit card")), + ("VB", _("bank transfer")), + ("CA", _("cash")), + ("RB", _("refund")), ), unique=True, )