Commit e191223e authored by Ulises Morales Ramírez's avatar Ulises Morales Ramírez

Merge branch 'paypal' into 'dev'

Paypal

See merge request !7
parents 427ba53f fb5cd2c0
...@@ -445,6 +445,7 @@ $(document).ready(function () { ...@@ -445,6 +445,7 @@ $(document).ready(function () {
}); });
} else { } else {
hideWaitingModal();
$('aside').removeClass("control-sidebar-open"); $('aside').removeClass("control-sidebar-open");
mssgModal({ mssgModal({
title : "No products were found!", title : "No products were found!",
......
...@@ -68,9 +68,10 @@ ...@@ -68,9 +68,10 @@
{% block user %}{% endblock %} {% block user %}{% endblock %}
</li> </li>
<!-- Control Sidebar Toggle Button --> <!-- Control Sidebar Toggle Button -->
<li> <li>{% if showcart %}
<a id="product-list-toggle" href="#" data-toggle="control-sidebar"><i <a id="product-list-toggle" href="#" data-toggle="control-sidebar"><i
class="fa fa-shopping-cart"></i></a> class="fa fa-shopping-cart"></i></a>
{% endif %}
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -2,211 +2,245 @@ ...@@ -2,211 +2,245 @@
{% load staticfiles %} {% load staticfiles %}
{% block headMedia %} {% block headMedia %}
<link rel="stylesheet" href="{% static 'catalog/css/map.css' %}" type="text/css"> <link rel="stylesheet" href="{% static 'catalog/css/map.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'catalog/css/body.css' %}" type="text/css"> <link rel="stylesheet" href="{% static 'catalog/css/body.css' %}" type="text/css">
<link rel="stylesheet" href="{% static 'catalog/css/modal1.css' %}" type="text/css"> <link rel="stylesheet" href="{% static 'catalog/css/modal1.css' %}" type="text/css">
<!-- <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">--> <!-- <link rel="stylesheet" href="https://openlayers.org/en/v4.6.4/css/ol.css" type="text/css">-->
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css"> <link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<!-- <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>--> <!-- <script src="https://openlayers.org/en/v4.6.4/build/ol.js"></script>-->
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script> <script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<script src="{% static 'catalog/js/openLayers4.js' %}"></script> <script src="{% static 'catalog/js/openLayers4.js' %}"></script>
<script src="{% static 'catalog/js/sidtMap.js' %}"></script> <script src="{% static 'catalog/js/sidtMap.js' %}"></script>
{% endblock %} {% endblock %}
{% block messages %} {% block messages %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i> <i class="fa fa-envelope-o"></i>
<span class="label label-success">4</span> <span class="label label-success">4</span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="header">You have 4 messages</li> <li class="header">You have 4 messages</li>
<li> <li>
<!-- inner menu: contains the actual data --> <!-- inner menu: contains the actual data -->
<ul class="menu"> <ul class="menu">
<li><!-- start message --> <li><!-- start message -->
<a href="#"> <a href="#">
<div class="pull-left"> <div class="pull-left">
<img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image"> <img src="dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
</div> </div>
<h4> <h4>
Support Team Support Team
<small><i class="fa fa-clock-o"></i> 5 mins</small> <small><i class="fa fa-clock-o"></i> 5 mins</small>
</h4> </h4>
<p>Why not buy a new awesome theme?</p> <p>Why not buy a new awesome theme?</p>
</a> </a>
</li> </li>
<!-- end message --> <!-- end message -->
<li> <li>
<a href="#"> <a href="#">
<div class="pull-left"> <div class="pull-left">
<img src="dist/img/user3-128x128.jpg" class="img-circle" alt="User Image"> <img src="dist/img/user3-128x128.jpg" class="img-circle" alt="User Image">
</div> </div>
<h4> <h4>
AdminLTE Design Team AdminLTE Design Team
<small><i class="fa fa-clock-o"></i> 2 hours</small> <small><i class="fa fa-clock-o"></i> 2 hours</small>
</h4> </h4>
<p>Why not buy a new awesome theme?</p> <p>Why not buy a new awesome theme?</p>
</a> </a>
</li> </li>
</ul> </ul>
</li> </li>
<li class="footer"><a href="#">See All Messages</a></li> <li class="footer"><a href="#">See All Messages</a></li>
</ul> </ul>
{% endblock %} {% endblock %}
{% block notifications %} {% block notifications %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i> <i class="fa fa-bell-o"></i>
<span class="label label-warning">10</span> <span class="label label-warning">10</span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="header">You have 10 notifications</li> <li class="header">You have 10 notifications</li>
<li> <li>
<!-- inner menu: contains the actual data --> <!-- inner menu: contains the actual data -->
<ul class="menu"> <ul class="menu">
<li> <li>
<a href="#"> <a href="#">
<i class="fa fa-users text-aqua"></i> 5 new members joined today <i class="fa fa-users text-aqua"></i> 5 new members joined today
</a> </a>
</li> </li>
</li> </li>
</ul> </ul>
</li> </li>
<li class="footer"><a href="#">View all</a></li> <li class="footer"><a href="#">View all</a></li>
</ul> </ul>
{% endblock %} {% endblock %}
{% block tasks %} {% block tasks %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-flag-o"></i> <i class="fa fa-flag-o"></i>
<span class="label label-danger">9</span> <span class="label label-danger">9</span>
</a> </a>
<ul c{% load static %}lass="dropdown-menu"> <ul c{% load static %}lass="dropdown-menu">
<li class="header">You have 9 tasks</li> <li class="header">You have 9 tasks</li>
<li> <li>
<!-- inner menu: contains the actual data --> <!-- inner menu: contains the actual data -->
<ul class="menu"> <ul class="menu">
<li><!-- Task item --> <li><!-- Task item -->
<a href="#"> <a href="#">
<h3> <h3>
Design some buttons Design some buttons
<small class="pull-right">20%</small> <small class="pull-right">20%</small>
</h3> </h3>
<div class="progress xs"> <div class="progress xs">
<div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar" <div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar"
aria-valuenow="20" aria-valuemin="0" aria-valuemax="100"> aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
<span class="sr-only">20% Complete</span> <span class="sr-only">20% Complete</span>
</div>
</div> </div>
</a> </div>
</li> </a>
<!-- end task item --> </li>
</ul> <!-- end task item -->
</li> </ul>
<li class="footer"> </li>
<a href="#">View all tasks</a> <li class="footer">
</li> <a href="#">View all tasks</a>
</ul> </li>
</ul>
{% endblock %} {% endblock %}
{% block sidebar %} {% block sidebar %}
<div class="form-group"> <div class="form-group">
<br> <br>
<ul class="sidebar-menu" data-widget="tree"> <ul class="sidebar-menu" data-widget="tree">
<li> <li>
<a class="treeview " href="{{ BASE_URL }}/catalog"> <a class="treeview " href="{{ BASE_URL }}/catalog">
<i class="fa fa-map"></i> <i class="fa fa-map"></i>
<span>Home</span> <span>Home</span>
<span class="pull-right-container"> <span class="pull-right-container">
<span class="label label-primary pull-right"></span> <span class="label label-primary pull-right"></span>
</span> </span>
</a> </a>
</li> </li>
</ul> </ul>
</div> </div>
<!-- form-group--> <!-- form-group-->
{% endblock %} {% endblock %}
{% block user %} {% block user %}
{% include "user_button.html" %} {% include "user_button.html" %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<!-- Content Wrapper. Contains page content -->
<!-- Main content -->
<div id="cartPage" class="wrapper" style="background-color: #ecf0f5">
<div class="text-center"><h1>Shopping Cart</h1></div>
<!-- Content Wrapper. Contains page content --> <!-- Content Wrapper. Contains page content -->
<!-- Main content --> <!-- Main content -->
<div id="cartPage" class="wrapper" style="background-color: #ecf0f5"> <section class="content" style="overflow-y: auto; height: 85vh">
<div class="text-center"><h1>Shopping Cart</h1></div> <div class="row">
<!-- Content Wrapper. Contains page content --> <div class="col-md-5 col-md-offset-2">
<!-- Main content -->
<section class="content" style="overflow-y: auto; height: 85vh">
<div class="row">
<div class="col-md-5 col-md-offset-2">
{% for product in product_list %} {% for product in product_list %}
<div class="box box-warning" style="margin-bottom: 10px"> <div class="box box-warning" style="margin-bottom: 10px">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Product {{ product.aggreg_date }}</h3> <h3 class="box-title">{{ product.process }}: {{ product.aggreg_date }}</h3>
<div class="box-tools pull-right"> <div class="box-tools pull-right">
<span class="badge bg-green">Price ${{ product.price }}</span> <span class="badge bg-green">Price ${{ product.price }}</span>
<button type="button" class="btn btn-box-tool" data-widget="collapse"> <button type="button" class="btn btn-box-tool" data-widget="collapse">
<i class="fa fa-minus"></i> <i class="fa fa-minus"></i>
</button> </button>
</div>
</div>
<div class="box-body">
<ul class="products-list product-list-in-box">
{% for catalog in product.catalog %}
<li class="item">
<div class="product-img">
<img src="data:image/jpeg;base64, {{ catalog.info.img }}">
</div> </div>
</div> <div class="product-info">
<div class="box-body">
<ul class="products-list product-list-in-box">
{% for catalog in product.catalog %}
<li class="item">
<div class="product-img">
<img src="data:image/jpeg;base64, {{ catalog.info.img }}">
</div>
<div class="product-info">
<span class="product-title"> <span class="product-title">
{{ catalog.info.identifier }} {{ catalog.info.identifier }}
</span> </span>
<span class="product-description"> <span class="product-description">
{{ catalog.info.instrumentname }} {{ catalog.info.instrumentname }}
</span> </span>
</div> </div>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>
</div>
{% endfor %}
</div> </div>
<div class="col-md-3"> {% endfor %}
<div class="box box-warning"> </div>
<div class="box-header with-border"> <div class="col-md-3">
<h3 class="box-title">Summary</h3> <div class="box box-warning">
</div> <div class="box-header with-border">
<div class="box-body"> <h3 class="box-title">Summary</h3>
<div class="table-responsive"> </div>
<table class="table"> <div class="box-body">
<tbody> <div class="table-responsive">
<tr> <table class="table">
<th>Total products:</th> <tbody>
<td>{{ total_products }}</td> <tr>
</tr> <th>Total products:</th>
<tr> <td>{{ total_products }}</td>
<th>Total price:</th> </tr>
<td>${{ total_price }}</td> <tr>
</tr> <th>Total price:</th>
</tbody> <td>${{ total_price }}</td>
<tfoot> </tr>
<tr> </tbody>
<td><a href="../pay" class="btn btn-primary">Pay</a></td> <tfoot>
</tr> <tr>
</tfoot> <td>
</table> <a href="../pay" class="btn btn-primary pull-right">Pay</a>
</div> </td>
<td>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business"
value="ulisexmorales-facilitator@gmail.com">
<input type="hidden" name="currency_code" value="MXN">
{% for product in product_list %}
<input type="hidden" name="item_name_{{forloop.counter}}"
value="{{product.process}}: {{ product.aggreg_date }}">
<input type="hidden" name="amount_{{forloop.counter}}"
value="{{ product.price }}">
<input type="hidden" name="item_number_{{forloop.counter}}"
value="{{ product.product_id }}">
{% endfor %}
<input type='hidden' name='cancel_return'
value='http://www.example.com/cancel.php'>
<input type='hidden' name='return'
value='http://www.example.com/success.php'>
<input type="image"
src="https://www.sandbox.paypal.com/es_XC/MX/i/btn/btn_buynowCC_LG.gif"
border="0" name="submit"
alt="PayPal, la forma más segura y rápida de pagar en línea.">
<img alt="" border="0"
src="https://www.sandbox.paypal.com/es_XC/i/scr/pixel.gif" width="1"
height="1">
</form>
</td>
</tr>
</tfoot>
</table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</section> </div>
<!-- /.content --> </section>
</div> <!-- /.content -->
<!-- Footer --> </div>
<footer class=" page-footer font-small special-color-dark pt-5" style="bottom: 0; position: absolute"> <!-- Footer -->
<footer class=" page-footer font-small special-color-dark pt-5" style="bottom: 0; position: absolute">
<!-- Footer Elements --> <!-- Footer Elements -->
<div class="container"> <div class="container">
<!-- Social buttons <!-- Social buttons
...@@ -249,10 +283,10 @@ ...@@ -249,10 +283,10 @@
<!-- Copyright --> <!-- Copyright -->
</footer> </footer>
<!-- Footer --> <!-- Footer -->
<!-- /.content --> <!-- /.content -->
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<!-- page script --> <!-- page script -->
{% endblock %} {% endblock %}
...@@ -34,6 +34,15 @@ ...@@ -34,6 +34,15 @@
</span> </span>
</a> </a>
</li> </li>
<li>
<a class="treeview " href="{{ BASE_URL }}/catalog/cart">
<i class="fa fa-shopping-cart"></i>
<span>View shopping cart</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
<li> <li>
<a class="treeview " href="{% url 'logout' %}?next={{ request.path }}"> <a class="treeview " href="{% url 'logout' %}?next={{ request.path }}">
<i class="fa fa-sign-out"></i> <i class="fa fa-sign-out"></i>
......
...@@ -62,9 +62,9 @@ def map(request): ...@@ -62,9 +62,9 @@ def map(request):
View function for home page of site. View function for home page of site.
""" """
form = ASFSearchForm(request.POST) form = ASFSearchForm(request.POST)
showcart = True
# Render the HTML template index.html with the data in the context variable # Render the HTML template index.html with the data in the context variable
return render(request, 'map.html', { "searchForm": form }) return render(request, 'map.html', { "searchForm": form,"showcart": showcart })
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def requestToImage(request): def requestToImage(request):
...@@ -559,5 +559,28 @@ def Pay (request): ...@@ -559,5 +559,28 @@ def Pay (request):
user = User.objects.get(id=request.user.id)
prod_list = []
product_list = Purchase.objects.values('id','user', 'productList', 'purchased', 'price', 'aggreg_date','search__process_id__name').filter(user=user, purchased=0)
total_price = 0
total_products = 0
for products in product_list:
product = json.loads(products['productList'])
prod_list.append({
'purchased': products['purchased'],
'price': products['price'],
'aggreg_date': products['aggreg_date'],
'catalog': product,
'product_id': products['id'],
"process": products['search__process_id__name'],
})
total_price += products['price']
total_products += 1
return render(request, 'show_cart.html', {'product_list': prod_list, 'total_price': total_price, 'total_products': total_products})
#-------------------------------------
def Pay (request):
Purchase.objects.filter(user_id=request.user.id, purchased=0).update(purchased=True) Purchase.objects.filter(user_id=request.user.id, purchased=0).update(purchased=True)
return redirect('../../reports') return redirect('../../reports')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment