From 197a147ebabf0d32b66df1779877504de6051b9a Mon Sep 17 00:00:00 2001 From: shivam kohli Date: Mon, 6 Aug 2018 09:29:40 +0530 Subject: changed price field to decimal --- inventory/migrations/0003_auto_20180806_0342.py | 19 +++++++++++++++++++ inventory/migrations/0004_auto_20180806_0356.py | 19 +++++++++++++++++++ inventory/models.py | 2 +- inventory/views.py | 4 ++-- templates/inventory/new_product.html | 2 +- 5 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 inventory/migrations/0003_auto_20180806_0342.py create mode 100644 inventory/migrations/0004_auto_20180806_0356.py diff --git a/inventory/migrations/0003_auto_20180806_0342.py b/inventory/migrations/0003_auto_20180806_0342.py new file mode 100644 index 0000000..b703c08 --- /dev/null +++ b/inventory/migrations/0003_auto_20180806_0342.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('inventory', '0002_merchant_website'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='price', + field=models.IntegerField(blank=True, null=True), + ), + ] diff --git a/inventory/migrations/0004_auto_20180806_0356.py b/inventory/migrations/0004_auto_20180806_0356.py new file mode 100644 index 0000000..9c0a639 --- /dev/null +++ b/inventory/migrations/0004_auto_20180806_0356.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('inventory', '0003_auto_20180806_0342'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='price', + field=models.DecimalField(null=True, max_digits=50, decimal_places=5), + ), + ] diff --git a/inventory/models.py b/inventory/models.py index a65142c..c405c3e 100644 --- a/inventory/models.py +++ b/inventory/models.py @@ -47,7 +47,7 @@ class Product(models.Model): product_id = models.AutoField(primary_key=True) name = models.CharField(max_length=50, blank=True, null=True) description = models.CharField(max_length=300, blank=True, null=True) - price = models.CharField(max_length=50, blank=True, null=True) + price = models.DecimalField(max_digits=50, decimal_places=5, null=True) delivery_date = models.DateTimeField(auto_now=True) starting_inventory = models.IntegerField(blank=True, null=True) minimum_required = models.IntegerField(blank=True, null=True) diff --git a/inventory/views.py b/inventory/views.py index 97b63b6..958913e 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -403,7 +403,7 @@ def add_product(request): description = request.POST.get('description') product_instance.description = description price = request.POST.get('price') - product_instance.price = price + product_instance.price = float(price) starting_inventory = request.POST.get('starting_inventory') product_instance.starting_inventory = starting_inventory product_instance.inventory_on_hand = starting_inventory @@ -432,7 +432,7 @@ def product(request, uid): context_dict['url_update_inventory'] = url_update_inventory base_url = request.build_absolute_uri().rsplit('/', 3)[0] merchant = request.user.username - parameters = "name="+item.name+'&price='+item.price+'&merchant='+merchant + parameters = "name="+item.name+'&price='+str(item.price)+'&merchant='+merchant if item.document: context_dict['href'] = base_url+"/payment?"+parameters context_dict['digital'] = 'True' diff --git a/templates/inventory/new_product.html b/templates/inventory/new_product.html index c50aaa1..3bba0c6 100644 --- a/templates/inventory/new_product.html +++ b/templates/inventory/new_product.html @@ -40,7 +40,7 @@ with the Taler Codeless Merchant. If not, see . - + -- cgit v1.2.3