Skip to content

Commit

Permalink
did some changes for autonoums navigatation
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackcipher101 committed May 27, 2020
1 parent 50412d3 commit 48733de
Show file tree
Hide file tree
Showing 29 changed files with 23 additions and 6 deletions.
Binary file modified accounts/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified accounts/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified accounts/__pycache__/views.cpython-36.pyc
Binary file not shown.
Binary file modified db.sqlite3
Binary file not shown.
Binary file modified product/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified product/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file modified product/__pycache__/apps.cpython-36.pyc
Binary file not shown.
Binary file modified product/__pycache__/forms.cpython-36.pyc
Binary file not shown.
Binary file modified product/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file modified product/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified product/__pycache__/views.cpython-36.pyc
Binary file not shown.
Binary file modified product/migrations/__pycache__/0001_initial.cpython-36.pyc
Binary file not shown.
Binary file modified product/migrations/__pycache__/0002_product_price.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file modified product/migrations/__pycache__/0004_order.cpython-36.pyc
Binary file not shown.
Binary file modified product/migrations/__pycache__/0005_orderitem.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified product/migrations/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
2 changes: 0 additions & 2 deletions product/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Order(models.Model):
buyer=models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
items=models.ManyToManyField(OrderItem)


def add(self):
return self.items.all()

Expand All @@ -36,4 +35,3 @@ def get_cart_total(self):

def __str__(self):
return self.buyer

13 changes: 10 additions & 3 deletions product/templates/product/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<td colspan=2>
<strong class="pull-right">Order Total:</strong>
</td>

<td colspan= 1>
$<strong>{{ order.get_cart_total }}</strong>
</td>
Expand All @@ -43,7 +43,7 @@
<td colspan=1 >
<a href="{% url 'product_list' %}" class="btn btn-warning pull-left">
{% if order %}Continue Shopping{% else %}Add Items to Cart {% endif %}
</a>
</a>
</td>
<td colspan=2>

Expand All @@ -52,9 +52,16 @@
</td>
</tr>
</table>

</div>
</section>
<form method="POST" action="#" class="post-form">
{% csrf_token %}
coordiantes:<br>
<input type="text" name="locatation" value="">
<br>
<input type="submit" value="Submit">
</form>
{% endblock %}

{% block scripts %}
Expand Down
14 changes: 13 additions & 1 deletion product/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.shortcuts import render, get_object_or_404
from .forms import ProductForm
from django.shortcuts import redirect
import socket

def product_list(request):
products=Product.objects.order_by('price')
Expand Down Expand Up @@ -35,10 +36,21 @@ def get_pending_order(request):
def order_details(request):
existing_order=get_pending_order(request)
context={'order':existing_order }
if request.method == "POST":
locatation=request.POST.get('locatation')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((socket.gethostname(), 1234))
s.listen(5)
clientsocket, address = s.accept()
print(f"Connection from {address} has been established.")
clientsocket.send(bytes(locatation,"utf-8"))
return redirect("/")
return render(request,'product/cart.html',context)


def delete_from_cart(request, item_id):
item_to_delete = OrderItem.objects.filter(pk=item_id)
if item_to_delete.exists():
item_to_delete[0].delete()

return redirect('order_summary')
Binary file modified quiz/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified quiz/__pycache__/settings.cpython-36.pyc
Binary file not shown.
Binary file modified quiz/__pycache__/urls.cpython-36.pyc
Binary file not shown.
Binary file modified quiz/__pycache__/wsgi.cpython-36.pyc
Binary file not shown.

0 comments on commit 48733de

Please sign in to comment.