Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

167197488 favicon #129

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added hirola/front/static/front/assets/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hirola/front/templates/front/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'front/css/footer.css' %}" /> {% endblock %}
<!-- Application Title -->
<title>{% block title %}teke{% endblock %}</title>
<!-- Load Static for Images and CSS -->
<link rel="shortcut icon" href="{% static 'front/assets/favicon.png' %}" type="image/x-icon">
</head>

<body id="body">
Expand Down
2 changes: 1 addition & 1 deletion hirola/front/templates/front/phone_category.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h5>Oops! We currently do not have it</h5>
<div class="card image-div">
<div class="card-content center">
<a href="/profile/{{ phone.phone_model.id }}/" class="image">
<img src="{{ MEDIA_URL }}{{ phone.phone_model.brand_model_image }}">
<img src="{{ MEDIA_URL }}{{ phone.phone_model.brand_model_image }}" height="150" width="80">
</a>
<div class="card-title-text center"><b>{{ phone.phone_model}}</b></div>
</div>
Expand Down
34 changes: 33 additions & 1 deletion hirola/front/tests/checkout/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test the views of checkout page"""
from front.base_test import BaseTestCase
from front.models import Cart, User, Feature, Order
from front.models import Cart, User, Feature, Order, PhoneModelList
from django.test import Client


Expand Down Expand Up @@ -146,6 +146,38 @@ def test_order_items(self):
carts = Cart.objects.filter(owner=user)
self.assertEqual(len(carts), 0)

def test_item_quantity_reduced(self):
"""
Test that when a client order's an item
- That its quantity is reduced by the number
of items ordered
"""
self.winniethepooh = Client()
User.objects.create(email="[email protected]")
user = User.objects.get(email="[email protected]")
self.winniethepooh.force_login(user)
phone = PhoneModelList.objects.get(
id=self.samsung_note_5_rose_gold.pk)
self.assertEqual(phone.quantity, 4)
Cart.objects.create(
phone_model_item=self.samsung_note_5_rose_gold,
quantity=2, owner=user)
response = self.winniethepooh.post('/order')
self.assertRedirects(response, '/dashboard#orders', 302)
phone = PhoneModelList.objects.get(
id=self.samsung_note_5_rose_gold.pk)
self.assertEqual(phone.quantity, 2)
# if item's quantity gets to zero, the item should not be in stock
Cart.objects.create(
phone_model_item=self.samsung_note_5_rose_gold,
quantity=2, owner=user)
response = self.winniethepooh.post('/order')
self.assertRedirects(response, '/dashboard#orders', 302)
phone = PhoneModelList.objects.get(
id=self.samsung_note_5_rose_gold.pk)
self.assertEqual(phone.quantity, 0)
self.assertFalse(phone.is_in_stock)

def test_get_order_url(self):
"""
Test that when the order url is visited without posting any data
Expand Down
32 changes: 31 additions & 1 deletion hirola/front/tests/dashboard/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from front.base_test import (BaseTestCase, Client)
from front.tests.test_users import UserSignupTestCase
from front.models import (
Review, User, ShippingAddress, Order, OrderStatus, Cart, CancelledOrder)
Review, User, ShippingAddress, Order, OrderStatus, Cart, CancelledOrder,
PhoneModelList)


class DashboardTemplate(BaseTestCase):
Expand Down Expand Up @@ -220,6 +221,35 @@ def test_cancel_order(self):
with self.assertRaises(Order.DoesNotExist):
Order.objects.get(owner=owner)

def test_item_quantity_restored_on_order_cancel(self):
"""
Test that when a user cancels an order
- That the item's quantity is restored
with the number of items the canceled order had
"""
owner = User.objects.get(email="[email protected]")
self.winniethepooh = Client()
self.winniethepooh.force_login(owner)
phone = PhoneModelList.objects.get(
id=self.samsung_note_5_rose_gold.pk)
self.assertEqual(phone.quantity, 4)
Cart.objects.create(
phone_model_item=self.samsung_note_5_rose_gold,
quantity=4, owner=owner)
response = self.winniethepooh.post('/order')
self.assertRedirects(response, '/dashboard#orders', 302)
order = Order.objects.get(owner=owner)
phone = PhoneModelList.objects.get(
id=self.samsung_note_5_rose_gold.pk)
self.assertEqual(phone.quantity, 0)
self.assertFalse(phone.is_in_stock)
response = self.uriel.get('/cancel/{}'.format(order.pk))
self.assertEqual(response.status_code, 200)
phone = PhoneModelList.objects.get(
id=self.samsung_note_5_rose_gold.pk)
self.assertEqual(phone.quantity, 4)
self.assertTrue(phone.is_in_stock)

def test_cancel_non_existent_order(self):
"""
Test that the app handles cancelling of a non existent order.
Expand Down
12 changes: 11 additions & 1 deletion hirola/front/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ def place_order(request):
if request.method == 'POST':
shipping_address = None
if request.POST.get('hidden_pickup') == "1":
return(save_shipping_address_form(request))
return save_shipping_address_form(request)
return populate_order(request, shipping_address)
return redirect('/checkout')

Expand Down Expand Up @@ -924,6 +924,11 @@ def populate_order(request, address):
phone=obj.phone_model_item, status=order_status,
total_price=obj.total_price, shipping_address=address)
Cart.objects.filter(id=obj.id).delete()
phone = PhoneModelList.objects.get(id=obj.phone_model_item.pk)
phone.quantity -= obj.quantity
if phone.quantity == 0:
phone.is_in_stock = False
phone.save()
send_order_notice_email(
request, cart, get_cart_total(cart), address)
return redirect('/dashboard#orders')
Expand Down Expand Up @@ -974,6 +979,11 @@ def cancel_order(request, pk):
shipping_address=order.shipping_address,)
order.delete()
order_cancellation_form = OrderCancellationForm()
phone = PhoneModelList.objects.get(id=order.phone.pk)
phone.quantity += order.quantity
if not phone.is_in_stock:
phone.is_in_stock = True
phone.save()
return order_cancellation_data(request, order_cancellation_form)
messages.info(request, 'That order\'s cancel window has expired')
return redirect('/dashboard')
Expand Down