From c8312990906b9e14a5160ca8ce41929455ef27ce Mon Sep 17 00:00:00 2001 From: nanoy Date: Wed, 5 Dec 2018 01:43:21 +0100 Subject: [PATCH] Bugs fixs --- .gitignore | 3 +- coopeV3/settings.py | 1 - gestion/forms.py | 2 +- gestion/migrations/0010_auto_20181205_0142.py | 74 +++++++++++++++++++ gestion/models.py | 14 ++-- gestion/templates/gestion/products_index.html | 8 +- users/migrations/0006_auto_20181205_0142.py | 33 +++++++++ users/models.py | 4 +- users/templates/users/index.html | 2 +- users/views.py | 2 + 10 files changed, 126 insertions(+), 17 deletions(-) create mode 100644 gestion/migrations/0010_auto_20181205_0142.py create mode 100644 users/migrations/0006_auto_20181205_0142.py diff --git a/.gitignore b/.gitignore index 8e15950..0878e26 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ tags # End of https://www.gitignore.io/api/vim,git,django -.vscode \ No newline at end of file +.vscode +venv \ No newline at end of file diff --git a/coopeV3/settings.py b/coopeV3/settings.py index 30f5d45..bde1d67 100644 --- a/coopeV3/settings.py +++ b/coopeV3/settings.py @@ -27,7 +27,6 @@ DEBUG = True ALLOWED_HOSTS = ['127.0.0.1'] - # Application definition INSTALLED_APPS = [ diff --git a/gestion/forms.py b/gestion/forms.py index 6c364b7..da007cf 100644 --- a/gestion/forms.py +++ b/gestion/forms.py @@ -34,7 +34,7 @@ class ProductForm(forms.ModelForm): class KegForm(forms.ModelForm): class Meta: model = Keg - fields = "__all__" + exclude = ("is_active", ) class MenuForm(forms.ModelForm): class Meta: diff --git a/gestion/migrations/0010_auto_20181205_0142.py b/gestion/migrations/0010_auto_20181205_0142.py new file mode 100644 index 0000000..931e1ae --- /dev/null +++ b/gestion/migrations/0010_auto_20181205_0142.py @@ -0,0 +1,74 @@ +# Generated by Django 2.1 on 2018-12-05 00:42 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gestion', '0009_auto_20181202_1628'), + ] + + operations = [ + migrations.AlterField( + model_name='historicalkeg', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Prix du fût'), + ), + migrations.AlterField( + model_name='historicalmenu', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant'), + ), + migrations.AlterField( + model_name='historicalmenuhistory', + name='amount', + field=models.DecimalField(decimal_places=2, default=0, max_digits=7), + ), + migrations.AlterField( + model_name='historicalproduct', + name='adherentRequired', + field=models.BooleanField(default=True, verbose_name='Adhérent requis'), + ), + migrations.AlterField( + model_name='historicalrefund', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant'), + ), + migrations.AlterField( + model_name='historicalreload', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant'), + ), + migrations.AlterField( + model_name='keg', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Prix du fût'), + ), + migrations.AlterField( + model_name='menu', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant'), + ), + migrations.AlterField( + model_name='menuhistory', + name='amount', + field=models.DecimalField(decimal_places=2, default=0, max_digits=7), + ), + migrations.AlterField( + model_name='product', + name='adherentRequired', + field=models.BooleanField(default=True, verbose_name='Adhérent requis'), + ), + migrations.AlterField( + model_name='refund', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant'), + ), + migrations.AlterField( + model_name='reload', + name='amount', + field=models.DecimalField(decimal_places=2, max_digits=7, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Montant'), + ), + ] diff --git a/gestion/models.py b/gestion/models.py index b83ddef..95cda26 100644 --- a/gestion/models.py +++ b/gestion/models.py @@ -38,7 +38,7 @@ class Product(models.Model): is_active = models.BooleanField(default=True, verbose_name="Actif") volume = models.PositiveIntegerField(default=0) deg = models.DecimalField(default=0,max_digits=5, decimal_places=2, verbose_name="Degré", validators=[MinValueValidator(0)]) - adherentRequired = models.BooleanField(default=True) + adherentRequired = models.BooleanField(default=True, verbose_name="Adhérent requis") history = HistoricalRecords() def __str__(self): @@ -63,7 +63,7 @@ def isDemi(id): ) def isGalopin(id): - product = Product.objects.get(id) + product = Product.objects.get(id=id) if product.category != Product.G_PRESSION: raise ValidationError( ('%(product)s n\'est pas un galopin'), @@ -84,7 +84,7 @@ class Keg(models.Model): name = models.CharField(max_length=20, unique=True, verbose_name="Nom") stockHold = models.IntegerField(default=0, verbose_name="Stock en soute") barcode = models.CharField(max_length=20, unique=True, verbose_name="Code barre") - amount = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="Prix du fût", validators=[MinValueValidator(0)]) + amount = models.DecimalField(max_digits=7, decimal_places=2, verbose_name="Prix du fût", validators=[MinValueValidator(0)]) capacity = models.IntegerField(default=30, verbose_name="Capacité (L)") pinte = models.ForeignKey(Product, on_delete=models.PROTECT, related_name="futp", validators=[isPinte]) demi = models.ForeignKey(Product, on_delete=models.PROTECT, related_name="futd", validators=[isDemi]) @@ -126,7 +126,7 @@ class Reload(models.Model): verbose_name = "Rechargement" customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="reload_taken", verbose_name="Client") - amount = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="Montant", validators=[MinValueValidator(0)]) + amount = models.DecimalField(max_digits=7, decimal_places=2, verbose_name="Montant", validators=[MinValueValidator(0)]) PaymentMethod = models.ForeignKey(PaymentMethod, on_delete=models.PROTECT, verbose_name="Moyen de paiement") coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="reload_realized") date = models.DateTimeField(auto_now_add=True) @@ -154,7 +154,7 @@ class Refund(models.Model): date = models.DateTimeField(auto_now_add=True) customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="refund_taken", verbose_name="Client") - amount = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="Montant", validators=[MinValueValidator(0)]) + amount = models.DecimalField(max_digits=7, decimal_places=2, verbose_name="Montant", validators=[MinValueValidator(0)]) coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="refund_realized") history = HistoricalRecords() @@ -167,7 +167,7 @@ class Menu(models.Model): Stores menus """ name = models.CharField(max_length=255, verbose_name="Nom") - amount = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="Montant", validators=[MinValueValidator(0)]) + amount = models.DecimalField(max_digits=7, decimal_places=2, verbose_name="Montant", validators=[MinValueValidator(0)]) barcode = models.CharField(max_length=20, unique=True, verbose_name="Code barre") articles = models.ManyToManyField(Product, verbose_name="Produits") is_active = models.BooleanField(default=False, verbose_name="Actif") @@ -195,7 +195,7 @@ class MenuHistory(models.Model): paymentMethod = models.ForeignKey(PaymentMethod, on_delete=models.PROTECT) date = models.DateTimeField(auto_now_add=True) menu = models.ForeignKey(Menu, on_delete=models.PROTECT) - amount = models.DecimalField(max_digits=5, decimal_places=2, default=0) + amount = models.DecimalField(max_digits=7, decimal_places=2, default=0) coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="menu_selled") history = HistoricalRecords() diff --git a/gestion/templates/gestion/products_index.html b/gestion/templates/gestion/products_index.html index 3e0e9b3..95d19d3 100644 --- a/gestion/templates/gestion/products_index.html +++ b/gestion/templates/gestion/products_index.html @@ -17,7 +17,7 @@ {% if perms.gestion.add_product %}
  • Créer un produit
  • {% endif %} - {% if permis.gestion.view_product} + {% if perms.gestion.view_product %}
  • Rechercher un produit
  • Lister tous les produits
  • {% endif %} @@ -32,13 +32,13 @@ {% if perms.gestion.add_keg %}
  • Créer un fut
  • {% endif %} - {% if perms.gestion.open_keg} + {% if perms.gestion.open_keg %}
  • Percuter un fut
  • {% endif %} - {% if perms.gestion.close_keg} + {% if perms.gestion.close_keg %}
  • Fermer un fût
  • {% endif %} - {% if perms.gestion.view_keg} + {% if perms.gestion.view_keg %}
  • Lister les futs
  • {% endif %} diff --git a/users/migrations/0006_auto_20181205_0142.py b/users/migrations/0006_auto_20181205_0142.py new file mode 100644 index 0000000..97973d6 --- /dev/null +++ b/users/migrations/0006_auto_20181205_0142.py @@ -0,0 +1,33 @@ +# Generated by Django 2.1 on 2018-12-05 00:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0005_auto_20181202_1628'), + ] + + operations = [ + migrations.AlterField( + model_name='historicalprofile', + name='credit', + field=models.DecimalField(decimal_places=2, default=0, max_digits=7), + ), + migrations.AlterField( + model_name='historicalprofile', + name='debit', + field=models.DecimalField(decimal_places=2, default=0, max_digits=7), + ), + migrations.AlterField( + model_name='profile', + name='credit', + field=models.DecimalField(decimal_places=2, default=0, max_digits=7), + ), + migrations.AlterField( + model_name='profile', + name='debit', + field=models.DecimalField(decimal_places=2, default=0, max_digits=7), + ), + ] diff --git a/users/models.py b/users/models.py index 72c97aa..d56a51f 100644 --- a/users/models.py +++ b/users/models.py @@ -71,8 +71,8 @@ class Profile(models.Model): verbose_name = "Profil" user = models.OneToOneField(User, on_delete=models.CASCADE) - credit = models.DecimalField(max_digits=5, decimal_places=2, default=0) - debit = models.DecimalField(max_digits=5, decimal_places=2, default=0) + credit = models.DecimalField(max_digits=7, decimal_places=2, default=0) + debit = models.DecimalField(max_digits=7, decimal_places=2, default=0) school = models.ForeignKey(School, on_delete=models.PROTECT, blank=True, null=True) cotisationEnd = models.DateTimeField(blank=True, null=True) history = HistoricalRecords() diff --git a/users/templates/users/index.html b/users/templates/users/index.html index 8ef388d..05a141b 100644 --- a/users/templates/users/index.html +++ b/users/templates/users/index.html @@ -16,7 +16,7 @@ Actions possibles :