From ce0acde3d07739580e69c0f255bceeb468458c83 Mon Sep 17 00:00:00 2001 From: nanoy Date: Sun, 23 Jun 2019 16:43:23 +0200 Subject: [PATCH] Remove barcodes --- gestion/forms.py | 2 +- gestion/migrations/0011_auto_20190623_1640.py | 37 +++++++++++++++++++ gestion/models.py | 12 ------ gestion/templates/gestion/kegs_list.html | 4 -- gestion/templates/gestion/manage.html | 25 ++++++------- gestion/templates/gestion/menus_list.html | 2 - .../templates/gestion/product_profile.html | 1 - gestion/templates/gestion/products_list.html | 2 - gestion/views.py | 9 ++--- staticfiles/manage.js | 20 +++++----- 10 files changed, 63 insertions(+), 51 deletions(-) create mode 100644 gestion/migrations/0011_auto_20190623_1640.py diff --git a/gestion/forms.py b/gestion/forms.py index cd084dc..daa8b8c 100644 --- a/gestion/forms.py +++ b/gestion/forms.py @@ -49,7 +49,7 @@ class KegForm(forms.ModelForm): class Meta: model = Keg - fields = ["name", "stockHold", "barcode", "amount", "capacity"] + fields = ["name", "stockHold", "amount", "capacity"] widgets = {'amount': forms.TextInput} category = forms.ModelChoiceField(queryset=Category.objects.all(), label="Catégorie") diff --git a/gestion/migrations/0011_auto_20190623_1640.py b/gestion/migrations/0011_auto_20190623_1640.py new file mode 100644 index 0000000..dfc3f47 --- /dev/null +++ b/gestion/migrations/0011_auto_20190623_1640.py @@ -0,0 +1,37 @@ +# Generated by Django 2.1 on 2019-06-23 14:40 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('gestion', '0010_auto_20190623_1623'), + ] + + operations = [ + migrations.RemoveField( + model_name='historicalkeg', + name='barcode', + ), + migrations.RemoveField( + model_name='historicalmenu', + name='barcode', + ), + migrations.RemoveField( + model_name='historicalproduct', + name='barcode', + ), + migrations.RemoveField( + model_name='keg', + name='barcode', + ), + migrations.RemoveField( + model_name='menu', + name='barcode', + ), + migrations.RemoveField( + model_name='product', + name='barcode', + ), + ] diff --git a/gestion/models.py b/gestion/models.py index b19bc3b..06a4559 100644 --- a/gestion/models.py +++ b/gestion/models.py @@ -62,10 +62,6 @@ class Product(models.Model): """ Number of product at the bar. """ - barcode = models.CharField(max_length=255, unique=True, verbose_name="Code barre") - """ - The barcode of the product. - """ category = models.ForeignKey('Category', on_delete=models.PROTECT, verbose_name="Catégorie") """ The category of the product @@ -170,10 +166,6 @@ class Keg(models.Model): """ The number of this keg in the hold. """ - barcode = models.CharField(max_length=20, unique=True, verbose_name="Code barre") - """ - The barcode of the keg. - """ amount = models.DecimalField(max_digits=7, decimal_places=2, verbose_name="Prix du fût", validators=[MinValueValidator(0)]) """ The price of the keg. @@ -317,10 +309,6 @@ class Menu(models.Model): """ Price of the menu. """ - barcode = models.CharField(max_length=20, unique=True, verbose_name="Code barre") - """ - Barcode of the menu. - """ articles = models.ManyToManyField(Product, verbose_name="Produits") """ Stores :class:`Products ` contained in the menu diff --git a/gestion/templates/gestion/kegs_list.html b/gestion/templates/gestion/kegs_list.html index 32b4035..e98bbf1 100644 --- a/gestion/templates/gestion/kegs_list.html +++ b/gestion/templates/gestion/kegs_list.html @@ -28,7 +28,6 @@ Nom Stock en soute - Code barre Capacité Quantité vendue Montant vendu @@ -43,7 +42,6 @@ {{ kegH.keg.name }} {{ kegH.keg.stockHold}} - {{ kegH.keg.barcode }} {{ kegH.keg.capacity }} L {{ kegH.quantitySold }} L {{ kegH.amountSold }} € @@ -77,7 +75,6 @@ Nom Stock en soute - Code barre Capacité Prix du fût Degré @@ -90,7 +87,6 @@ {{ keg.name }} {{ keg.stockHold}} - {{ keg.barcode }} {{ keg.capacity }} L {{ keg.amount }} € {{ keg.pinte.deg }}° diff --git a/gestion/templates/gestion/manage.html b/gestion/templates/gestion/manage.html index 80b3aa0..d4f49f6 100644 --- a/gestion/templates/gestion/manage.html +++ b/gestion/templates/gestion/manage.html @@ -98,7 +98,6 @@ - @@ -117,43 +116,43 @@ {% for cotisation in cotisations %} - {% if forloop.counter0|divisibleby:4 %} + {% if forloop.counter0|divisibleby:3 %} {% endif %} - {% if forloop.counter|divisibleby:4 %} + {% if forloop.counter|divisibleby:3 %} {% endif %} {% endfor %} - {% if not cotisations|divisibleby:4 %} + {% if not cotisations|divisibleby:3 %} {% endif %} {% for product in bieresPression %} - {% if forloop.counter0|divisibleby:4 %} + {% if forloop.counter0|divisibleby:3 %} {% endif %} - {% if forloop.counter|divisibleby:4 %} + {% if forloop.counter|divisibleby:3 %} {% endif %} {% endfor %} - {% if not bieresPression|divisibleby:4 %} + {% if not bieresPression|divisibleby:3 %} {% endif %} {% for category in categories %} {% if category.active_products.count > 0 %} {% for product in category.active_products %} - {% if forloop.counter0|divisibleby:4 %} + {% if forloop.counter0|divisibleby:3 %} {% endif %} - {% if forloop.counter|divisibleby:4 %} + {% if forloop.counter|divisibleby:3 %} {% endif %} {% endfor %} - {% if not category.active_products|divisibleby:4 %} + {% if not category.active_products|divisibleby:3 %} {% endif %} {% endif %} @@ -161,15 +160,15 @@ {% if menus %} {% for product in menus %} - {% if forloop.counter0|divisibleby:4 %} + {% if forloop.counter0|divisibleby:3 %} {% endif %} - {% if forloop.counter|divisibleby:4 %} + {% if forloop.counter|divisibleby:3 %} {% endif %} {% endfor %} - {% if not menus|divisibleby:4 %} + {% if not menus|divisibleby:3 %} {% endif %} {% endif %} diff --git a/gestion/templates/gestion/menus_list.html b/gestion/templates/gestion/menus_list.html index 22ef402..453240a 100644 --- a/gestion/templates/gestion/menus_list.html +++ b/gestion/templates/gestion/menus_list.html @@ -17,7 +17,6 @@ - @@ -28,7 +27,6 @@ - diff --git a/gestion/templates/gestion/product_profile.html b/gestion/templates/gestion/product_profile.html index 6c52477..d3e81f9 100644 --- a/gestion/templates/gestion/product_profile.html +++ b/gestion/templates/gestion/product_profile.html @@ -16,7 +16,6 @@ Prix de vente : {{ product.amount }}€
Stock en soute : {{ product.stockHold }}
Stock au bar : {{ product.stockBar }}
- Code Barre : {{ product.barcode }}
Catégorie : {{ product.category }}
Actif : {{ product.is_active | yesno:"Oui, Non"}}
Dégré : {{ product.deg }}
diff --git a/gestion/templates/gestion/products_list.html b/gestion/templates/gestion/products_list.html index f986d20..3d8d1f6 100644 --- a/gestion/templates/gestion/products_list.html +++ b/gestion/templates/gestion/products_list.html @@ -21,7 +21,6 @@ - @@ -36,7 +35,6 @@ - diff --git a/gestion/views.py b/gestion/views.py index f29aca4..3b01e78 100644 --- a/gestion/views.py +++ b/gestion/views.py @@ -393,7 +393,7 @@ def productProfile(request, pk): @login_required def getProduct(request, pk): """ - Get a :class:`gestion.models.Product` by barcode and return it in JSON format. + Get a :class:`gestion.models.Product` by pk and return it in JSON format. pk The primary key of the :class:`gestion.models.Product` to get infos. @@ -403,7 +403,7 @@ def getProduct(request, pk): nb_pintes = 1 else: nb_pintes = 0 - data = json.dumps({"pk": product.pk, "barcode" : product.barcode, "name": product.name, "amount": product.amount, "needQuantityButton": product.needQuantityButton, "nb_pintes": nb_pintes}) + data = json.dumps({"pk": product.pk, "name": product.name, "amount": product.amount, "needQuantityButton": product.needQuantityButton, "nb_pintes": nb_pintes}) return HttpResponse(data, content_type='application/json') @active_required @@ -464,7 +464,6 @@ def addKeg(request): amount = pinte_price, stockHold = 0, stockBar = 0, - barcode = "pinte_" + form.cleaned_data["barcode"], category = form.cleaned_data["category"], needQuantityButton = False, is_active = True, @@ -481,7 +480,6 @@ def addKeg(request): amount = ceil(5*pinte_price)/10, stockHold = 0, stockBar = 0, - barcode = "demi_" + form.cleaned_data["barcode"], category = form.cleaned_data["category"], needQuantityButton = False, is_active = True, @@ -499,7 +497,6 @@ def addKeg(request): amount = ceil(2.5 * pinte_price)/10, stockHold = 0, stockBar = 0, - barcode = "galopin_" + form.cleaned_data["barcode"], category = form.cleaned_data["category"], needQuantityButton = False, is_active = True, @@ -758,7 +755,7 @@ def get_menu(request, pk): for article in menu.articles: if article.category == Product.DRAFT_PINTE: nb_pintes +=1 - data = json.dumps({"pk": menu.pk, "barcode" : menu.barcode, "name": menu.name, "amount" : menu.amount, "needQuantityButton": False, "nb_pintes": nb_pintes}) + data = json.dumps({"pk": menu.pk, "name": menu.name, "amount" : menu.amount, "needQuantityButton": False, "nb_pintes": nb_pintes}) return HttpResponse(data, content_type='application/json') class MenusAutocomplete(autocomplete.Select2QuerySetView): diff --git a/staticfiles/manage.js b/staticfiles/manage.js index a85f2cc..f4d3249 100644 --- a/staticfiles/manage.js +++ b/staticfiles/manage.js @@ -19,14 +19,14 @@ function get_config(){ function get_product(id){ res = $.get("getProduct/" + id, function(data){ nbPintes += data.nb_pintes; - add_product(data.pk, data.barcode, data.name, data.amount, data.needQuantityButton); + add_product(data.pk, data.name, data.amount, data.needQuantityButton); }); } function get_menu(id){ res = $.get("getMenu/" + id, function(data){ nbPintes += data.nb_pintes; - add_menu(data.pk, data.barcode, data.name, data.amount, data.needQuantityButton); + add_menu(data.pk, data.name, data.amount, data.needQuantityButton); }); } @@ -36,7 +36,7 @@ function get_cotisation(id){ }); } -function add_product(pk, barcode, name, amount, needQuantityButton){ +function add_product(pk, name, amount, needQuantityButton){ exist = false index = -1; for(k=0;k < products.length; k++){ @@ -56,12 +56,12 @@ function add_product(pk, barcode, name, amount, needQuantityButton){ if(exist){ products[index].quantity += quantity; }else{ - products.push({"pk": pk, "barcode": barcode, "name": name, "amount": amount, "quantity": quantity}); + products.push({"pk": pk, "name": name, "amount": amount, "quantity": quantity}); } generate_html() } -function add_menu(pk, barcode, name, amount){ +function add_menu(pk, name, amount){ exist = false; index = -1; for(k=0; k < menus.length; k++){ @@ -73,12 +73,12 @@ function add_menu(pk, barcode, name, amount){ if(exist){ menus[index].quantity += 1; }else{ - menus.push({"pk": pk, "barcode": barcode, "name": name, "amount": amount, "quantity":1}); + menus.push({"pk": pk, "name": name, "amount": amount, "quantity":1}); } generate_html(); } -function add_cotisation(pk, barcode, duration, amount){ +function add_cotisation(pk, duration, amount){ exist = false; index = -1; for(k=0; k < cotisations.length; k++){ @@ -90,7 +90,7 @@ function add_cotisation(pk, barcode, duration, amount){ if(exist){ cotisations[index].quantity += 1; }else{ - cotisations.push({"pk": pk, "barcode": barcode, "duration": duration, "amount": amount, "quantity":1}); + cotisations.push({"pk": pk, "duration": duration, "amount": amount, "quantity":1}); } generate_html(); } @@ -103,11 +103,11 @@ function generate_html(){ } for(k=0;k'; + html += ''; } for(k=0; k'; + html += ''; } $("#items").html(html) updateTotal();
CodeBarre Nom Produit Prix Unitaire Quantité
Cotisations
Bières pression
{{category}}
Menus
Nom PrixCode barre Produits Actif Administrer
{{ menu.name }} {{ menu.amount}} €{{ menu.barcode }} {% for art in menu.articles.all %}{{art}},{% endfor %} {{ menu.is_active | yesno:"Oui, Non"}} {% if perms.gestion.change_menu %}{% if menu.is_active %} Désa{% else %} A{% endif %}ctiver Modifier{% endif %} Prix Stock (soute) Stock (bar)Code barre Catégorie Actif Degré{{ product.amount}} {{ product.stockHold }} {{ product.stockBar }}{{ product.barcode }} {{ product.category }} {{ product.is_active | yesno:"Oui, Non"}} {{ product.deg }}' + product.name + '' + String(product.amount) + ' €' + String(Number((product.quantity * product.amount).toFixed(2))) + ' €
' + product.name + '' + String(product.amount) + ' €' + String(Number((product.quantity * product.amount).toFixed(2))) + ' €
' + menu.name + '' + String(menu.amount) + ' €' + String(Number((menu.quantity * menu.amount).toFixed(2))) + ' €
' + menu.name + '' + String(menu.amount) + ' €' + String(Number((menu.quantity * menu.amount).toFixed(2))) + ' €