[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-codeless] branch master updated: added shipment deta
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-codeless] branch master updated: added shipment detail form and some basic improvements |
Date: |
Sun, 08 Jul 2018 22:41:05 +0200 |
This is an automated email from the git hooks/post-receive script.
shivam-kohli pushed a commit to branch master
in repository codeless.
The following commit(s) were added to refs/heads/master by this push:
new c1b0677 added shipment detail form and some basic improvements
c1b0677 is described below
commit c1b0677b2a9e48f2916f61fbd69194aad7830d8a
Author: shivam kohli <address@hidden>
AuthorDate: Mon Jul 9 02:11:07 2018 +0530
added shipment detail form and some basic improvements
---
codeless/urls.py | 5 +-
inventory/migrations/0001_initial.py | 12 +--
inventory/models.py | 11 +--
inventory/views.py | 66 ++++++++++---
templates/inventory/home.html | 1 +
templates/inventory/new_product.html | 3 +-
templates/inventory/{product.html => order.html} | 108 ++++++++++++++++-----
templates/inventory/product.html | 3 +-
.../{new_product.html => shipment_details.html} | 90 ++---------------
9 files changed, 162 insertions(+), 137 deletions(-)
diff --git a/codeless/urls.py b/codeless/urls.py
index 27cfc20..61b621d 100644
--- a/codeless/urls.py
+++ b/codeless/urls.py
@@ -10,6 +10,8 @@ urlpatterns = [
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
+ url(r'^shipment/$', 'inventory.views.shipment', name='shipment'),
+ url(r'^order/$', 'inventory.views.order', name='order'),
url(r'^fulfillment/$', 'inventory.views.fulfillment', name='fulfillment'),
url(r'^payment$', 'inventory.views.payment', name='payment'),
url(r'^pay/$', 'inventory.views.pay', name='pay'),
@@ -21,9 +23,6 @@ urlpatterns = [
url(r'^home/product/(?P<uid>[\*\w\-]+)$',
'inventory.views.product', name='product'),
url(r'^home/$', 'inventory.views.home', name='home'),
- url(r'^customize_payment_button/$',
- 'inventory.views.customize_payment_button',
- name='customize_payment_button'),
url(r'^accounts/login/$', 'inventory.views.login', name='login'),
url(r'^logout/$', 'inventory.views.logout', name='logout'),
url(r'^password_reset/$', auth_views.password_reset,
diff --git a/inventory/migrations/0001_initial.py
b/inventory/migrations/0001_initial.py
index c09fa98..f42be67 100644
--- a/inventory/migrations/0001_initial.py
+++ b/inventory/migrations/0001_initial.py
@@ -24,11 +24,12 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='Order',
fields=[
- ('order_id', models.AutoField(primary_key=True,
serialize=False)),
- ('description', models.CharField(max_length=300, blank=True,
null=True)),
+ ('id', models.AutoField(verbose_name='ID', primary_key=True,
serialize=False, auto_created=True)),
+ ('order_id', models.CharField(max_length=300, blank=True,
null=True)),
+ ('summary', models.CharField(max_length=300, blank=True,
null=True)),
('order_date', models.DateTimeField(auto_now=True)),
('address', models.CharField(max_length=250, blank=True,
null=True)),
- ('fulfillment_url', models.URLField(default='NULL')),
+ ('merchant', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
@@ -80,9 +81,4 @@ class Migration(migrations.Migration):
name='product_id',
field=models.ManyToManyField(null=True, to='inventory.Product'),
),
- migrations.AddField(
- model_name='order',
- name='user',
- field=models.ForeignKey(to=settings.AUTH_USER_MODEL),
- ),
]
diff --git a/inventory/models.py b/inventory/models.py
index 6319f10..09d3606 100644
--- a/inventory/models.py
+++ b/inventory/models.py
@@ -81,16 +81,15 @@ class Order(models.Model):
""" Details of the order customer buys is updated in this table.
These details will be used to make request to the Merchant Backend API
"""
- order_id = models.AutoField(primary_key=True)
- product_id = models.ManyToManyField(Product, null=True)
- description = models.CharField(max_length=300, blank=True, null=True)
+ order_id = models.CharField(max_length=300, blank=True, null=True)
+ product_id = models.ManyToManyField(Product, blank=True)
+ summary = models.CharField(max_length=300, blank=True, null=True)
order_date = models.DateTimeField(auto_now=True)
address = models.CharField(max_length=250, blank=True, null=True)
- user = models.ForeignKey(User, on_delete=models.CASCADE)
- fulfillment_url = models.URLField(max_length=200, default='NULL')
+ merchant = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
- return self.description
+ return self.summary
class Purchase(models.Model):
diff --git a/inventory/views.py b/inventory/views.py
index 93e7cd8..681009d 100644
--- a/inventory/views.py
+++ b/inventory/views.py
@@ -22,7 +22,7 @@
from inventory.forms import SignUpForm, MerchantDetailForm, LoginForm,
DocumentForm
-from inventory.models import Merchant, Product
+from inventory.models import Merchant, Product, Order
from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from django.contrib.auth import login as auth_login
@@ -43,6 +43,41 @@ def fulfillment(request):
return render(request, 'inventory/fulfillment.html')
+def shipment(request):
+ context_dict = {}
+ name = request.GET.get('name')
+ price = request.GET.get('price')
+ merchant = request.GET.get('merchant')
+ context_dict['name'] = name
+ context_dict['price'] = price
+ context_dict['merchant'] = merchant
+ return render(request, 'inventory/shipment_details.html', context_dict)
+
+
address@hidden
+def order(request):
+ user_instance = User.objects.get(username=request.user.username)
+ order = Order.objects.filter(merchant=user_instance)
+ context_dict = {}
+ array = []
+ for i in order:
+ data = {}
+ data['order_id'] = i.order_id
+ product = i.product_id.all()
+ array_product = []
+ for item in range(len(product)):
+ data_product = {}
+ data_product["name"] = product[item].name
+ array_product.append(data_product)
+ data['array_product'] = array_product
+ data['summary'] = i.summary
+ data['order_date'] = i.order_date
+ data['address'] = i.address
+ array.append(data)
+ context_dict['data'] = array
+ return render(request, 'inventory/order.html', context_dict)
+
+
@csrf_exempt
def pay(request):
if request.method == 'POST':
@@ -56,19 +91,31 @@ def pay(request):
if r.status_code != 200:
return HttpResponse(r.status_code)
contract_terms = r.json()["contract_terms"]
- print(contract_terms['products'])
+ order_instance = Order.objects.create(
+ order_id=contract_terms["order_id"],
+ summary=contract_terms["summary"],
+
merchant=User.objects.get(username=contract_terms["merchant"]["name"])
+ )
+ order_instance.save()
for i in contract_terms['products']:
+ product_instance = Product.objects.get(name=i["description"])
+ order_instance.product_id.add(product_instance)
+ order_instance.save()
update_inventory(i["description"],i["quantity"])
return JsonResponse(r.json())
def payment(request):
- session_id = request.session.session_key
- # merchant_instance = User.objects.get(username=uid)
+ # session_id = request.session.session_key
name = request.GET.get('name')
price = request.GET.get('price')
merchant = request.GET.get('merchant')
+ name_user = request.GET.get('name_user')
+ address_user = request.GET.get('address_user')
summary = name+' purchased from '+merchant
+ user = User.objects.get(username=merchant)
+ primary_key = user.pk
+ merchant_instance = Merchant.objects.get(pk=primary_key)
base_url = request.build_absolute_uri().rsplit('/', 1)[0]
# Creating an Order for a Payment
order = dict(order=dict(amount="KUDOS:"+price,
@@ -84,7 +131,7 @@ def payment(request):
fulfillment_url=base_url+"/fulfillment/",
pay_url=base_url+"/pay/",
merchant=dict(
- address="test",
+ address=merchant_instance.address,
name=merchant,
jurisdiction="none",
instance="default",
@@ -96,7 +143,7 @@ def payment(request):
pay_params = dict(
instance="default",
order_id=order_resp["order_id"],
- session_id=session_id,
+ # session_id=session_id,
)
pay_status = backend_get("check-payment", pay_params)
payment_redirect_url = pay_status["payment_redirect_url"]
@@ -219,16 +266,11 @@ def product(request, uid):
base_url = request.build_absolute_uri().rsplit('/', 3)[0]
merchant = request.user.username
parameters =
"name="+product.name+'&price='+product.price+'&merchant='+merchant
- context_dict['href'] = base_url + "/payment?"+parameters
+ context_dict['href'] = base_url+"/shipment?"+parameters
return render(request, 'inventory/product.html', context_dict)
@login_required
-def customize_payment_button(request):
- return render(request, 'inventory/new_product.html')
-
-
address@hidden
def new_product(request):
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
diff --git a/templates/inventory/home.html b/templates/inventory/home.html
index a4e89ac..0d222af 100644
--- a/templates/inventory/home.html
+++ b/templates/inventory/home.html
@@ -141,6 +141,7 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
<div class="sidenav">
<a href="/home">Home</a>
<a href="/logout">Logout</a></li>
+ <a href="/order">Order</a></li>
</div>
<div class="main">
diff --git a/templates/inventory/new_product.html
b/templates/inventory/new_product.html
index 55126f8..5e81f4e 100644
--- a/templates/inventory/new_product.html
+++ b/templates/inventory/new_product.html
@@ -134,7 +134,8 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
<div class="sidenav">
<a href="/home">Home</a>
- <a href="/logout">Logout</a></li>
+ <a href="/logout">Logout</a></li>
+ <a href="/order">Order</a></li>
</div>
<div class="main">
diff --git a/templates/inventory/product.html b/templates/inventory/order.html
similarity index 51%
copy from templates/inventory/product.html
copy to templates/inventory/order.html
index 9ac159b..763003d 100644
--- a/templates/inventory/product.html
+++ b/templates/inventory/order.html
@@ -53,6 +53,7 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
overflow-x: hidden;
padding-top: 20px;
}
+
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
@@ -60,14 +61,75 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
color: #818181;
display: block;
}
+
.sidenav a:hover {
color: #f1f1f1;
}
+ .btn {
+ background-color: white;
+ border: 1px solid #cccccc;
+ color: #696969;
+ padding: 0.5rem;
+ text-transform: lowercase;
+ }
+ .btnblock {
+ display: block;
+ width: 100%;
+ }
+ .cards {
+ display: flex;
+ flex-wrap: wrap;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ }
+ .cards__item {
+ /*display: flex;*/
+ padding: 1rem;
+ }
+ @media (min-width: 40rem) {
+ .cards__item {
+ width: 50%;
+ }
+ }
+ @media (min-width: 56rem) {
+ .cards__item {
+ width: 33.3333%;
+ }
+ }
+ .card {
+ background-color: white;
+ border-radius: 0.25rem;
+ box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.25);
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ }
+ .card__content {
+ display: flex;
+ flex: 1 1 auto;
+ flex-direction: column;
+ padding: 1rem;
+ }
+ .card__title {
+ color: #696969;
+ font-size: 1.25rem;
+ font-weight: 300;
+ letter-spacing: 2px;
+ text-transform: uppercase;
+ }
+ .card__text {
+ flex: 1 1 auto;
+ font-size: 0.875rem;
+ line-height: 1.5;
+ margin-bottom: 1.25rem;
+ }
.main {
margin-left: 160px;
font-size: 28px;
padding: 0px 10px;
}
+
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
@@ -78,35 +140,31 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
<div class="sidenav">
<a href="/home">Home</a>
- <a href="/logout">Logout</a></li>
+ <a href="/logout">Logout</a></li>
+ <a href="/order">Order</a></li>
</div>
-
<div class="main">
<center>
- <h1 style="text-transform: uppercase;" id="name">{{ name }}</h1>
+ <h1 style="text-transform: uppercase;" id="name">ORDERS PLACED</h1>
</center>
-
- <h5 color="black">The code for the pay now button is:</h5>
-
- <xmp style="font-size: 50% ">
- <a href="{{ href }}" style="text-decoration: none;"
onmouseover="this.style.textDecoration = 'underline'"
onmouseout="this.style.textDecoration = 'none'">buy now</a>
- </xmp>
-
- <h5 color="black">The above code would look like(click to perform the
payment):</h5>
- <a href="{{ href }}" style="text-decoration: none;"
onmouseover="this.style.textDecoration = 'underline'"
onmouseout="this.style.textDecoration = 'none'">buy now</a>
-
-
- <h5 color="black">Description:</h5><h6>{{ description }}</h6><br>
- <h5 color="black">Price:</h5><h6>{{ price }}</h6><br>
- <h5 color="black">The Cuurent Inventory on Hand is:- {{ inventory_on_hand
}}</h5>
-
- <form name="update_stock" action="{{ url_update_inventory }}"
method="post" enctype="multipart/form-data">
- {% csrf_token %}
- <input type="number" name="stock_updated" id="stock_updated"
placeholder="Update Stock" required>
- <button name="update_stock" type="submit"
class="submit">Update</button>
- </form>
-
+ <ul class="cards">
+ {% for item in data %}
+ <li class="cards__item">
+ <div class="card">
+ <div class="card__content">
+ <div class="card__title">{{ item.order_id }}</div>
+ <p class="card__text">{{ item.summary }}</p><br>
+ <p class="card__text">PRODUCT IN THE ORDER</p><br>
+ <ol>
+ {% for i in item.array_product %}
+ <li class="card__text">{{ i.name }}</li>
+ {% endfor %}
+ </ol>
+ </div>
+ </div>
+ </li>
+ {% endfor %}
+ </ul>
</div>
-
</body>
</html>
\ No newline at end of file
diff --git a/templates/inventory/product.html b/templates/inventory/product.html
index 9ac159b..2081adb 100644
--- a/templates/inventory/product.html
+++ b/templates/inventory/product.html
@@ -78,7 +78,8 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
<div class="sidenav">
<a href="/home">Home</a>
- <a href="/logout">Logout</a></li>
+ <a href="/logout">Logout</a></li>
+ <a href="/order">Order</a></li>
</div>
<div class="main">
diff --git a/templates/inventory/new_product.html
b/templates/inventory/shipment_details.html
similarity index 51%
copy from templates/inventory/new_product.html
copy to templates/inventory/shipment_details.html
index 55126f8..7aee562 100644
--- a/templates/inventory/new_product.html
+++ b/templates/inventory/shipment_details.html
@@ -20,60 +20,8 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
-->
<html>
<head>
- <title>Home</title>
+ <title>Shipment Details</title>
<style type="text/css">
- *,
- *::before,
- *::after {
- box-sizing: border-box;
- }
- html {
- background-color: #f0f0f0;
- }
- body {
- color: #999999;
- font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial,
sans-serif;
- font-style: normal;
- font-weight: 400;
- letter-spacing: 0;
- padding: 1rem;
- text-rendering: optimizeLegibility;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- -moz-font-feature-settings: "liga" on;
- }
- .sidenav {
- height: 100%;
- width: 160px;
- position: fixed;
- z-index: 1;
- top: 0;
- left: 0;
- background-color: #111;
- overflow-x: hidden;
- padding-top: 20px;
- }
-
- .sidenav a {
- padding: 6px 8px 6px 16px;
- text-decoration: none;
- font-size: 25px;
- color: #818181;
- display: block;
- }
-
- .sidenav a:hover {
- color: #f1f1f1;
- }
- .main {
- margin-left: 160px;
- font-size: 28px;
- padding: 0px 10px;
- }
- @media screen and (max-height: 450px) {
- .sidenav {padding-top: 15px;}
- .sidenav a {font-size: 18px;}
- }
#contact {width:100%; height:100%; margin 0 auto; background: #DDD; }
.container {width:960px; height:auto; margin: 0 auto; padding: 50px 0;}
@@ -132,44 +80,24 @@ with the Taler Codeless Merchant. If not, see
<https://www.gnu.org/licenses/>.
</head>
<body>
-<div class="sidenav">
- <a href="/home">Home</a>
- <a href="/logout">Logout</a></li>
-</div>
-
<div class="main">
<center>
- <h1>ADD A NEW PRODUCT</h1>
+ <h1>ADD SHIPMENT DETAILS</h1>
</center>
<section id="contact">
<div class="container">
- <form name="add_product_form" action="/add_product/" method="post"
enctype="multipart/form-data">
-
- {% csrf_token %}
- <input type="text" name="name" id="name" placeholder="Name"
required>
- <textarea type="text" name="description" id="description"
placeholder="Description" required></textarea>
- <input type="text" name="price" id="price" placeholder="Price"
required>
- <input type="number" name="starting_inventory"
id="starting_inventory" placeholder="Starting Inventory" required>
- <input type="number" name="minimum_required"
id="minimum_required" placeholder="Minimum Quantity Required" required>
- <button name="add_product" type="submit" class="submit">Add
Product</button>
+ <form name="add_product_form" action="/payment" method="get"
enctype="multipart/form-data">
+ <input type="text" name="name_user" id="name_user"
placeholder="Enter name" required>
+ <input type="text" name="address_user" id="address_user"
placeholder="Address(For Digital Inventory leave blank)">
+ <input type="hidden" name="name" value="{{ name }}">
+ <input type="hidden" name="price" value="{{ price }}">
+ <input type="hidden" name="merchant" value="{{ merchant }}">
+ <button name="add_product" type="submit"
class="submit">Submit</button>
</form>
</div>
</section>
-
- <section id="contact">
- <div class="container">
- <form method="post" enctype="multipart/form-data">
- <form method="post" enctype="multipart/form-data">
- <h1>FOR DIGITAL INVENTORY</h1>
- {% csrf_token %}
- {{ form.as_p }}
- <button name="add_product" type="submit" class="submit">Add
Product</button>
- </form>
- </div>
- </section>
-
</div>
</body>
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-codeless] branch master updated: added shipment detail form and some basic improvements,
gnunet <=