summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshivam kohli <kohlishivam5522@gmail.com>2018-08-06 09:29:40 +0530
committershivam kohli <kohlishivam5522@gmail.com>2018-08-06 09:29:40 +0530
commit197a147ebabf0d32b66df1779877504de6051b9a (patch)
tree57a873f5daa61d9b7e69f0056261918f62039a6a
parent3dea6592563c23a483a5454f55f639de32092be4 (diff)
downloadcodeless-197a147ebabf0d32b66df1779877504de6051b9a.tar.gz
codeless-197a147ebabf0d32b66df1779877504de6051b9a.tar.bz2
codeless-197a147ebabf0d32b66df1779877504de6051b9a.zip
changed price field to decimal
-rw-r--r--inventory/migrations/0003_auto_20180806_0342.py19
-rw-r--r--inventory/migrations/0004_auto_20180806_0356.py19
-rw-r--r--inventory/models.py2
-rw-r--r--inventory/views.py4
-rw-r--r--templates/inventory/new_product.html2
5 files changed, 42 insertions, 4 deletions
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 <https://www.gnu.org/licenses/>.
<input type="text" name="description" id="description" required></input>
<label for="price" class="tooltip">Price<font size="1"><span class="tooltiptext">Enter the price of the product. Remeber to write price in English texts. For Example 100 or 99.95</span></font></label>
- <input type="text" name="price" id="price" required>
+ <input type="number" name="price" id="price"min="0" value="0" step="0.01" title="Currency" pattern="^\d+(?:\.\d{1,2})?$" required>
<label for="starting_inventory" class="tooltip">Starting Inventory<font size="1"><span class="tooltiptext">Enter the number of Inventory initially available for the given product</span></font></label>
<input type="number" name="starting_inventory" id="starting_inventory" required>