Fakultas Ilmu Komputer UI

Commit 70be2a21 authored by Glenda Emanuella Sutanto's avatar Glenda Emanuella Sutanto
Browse files

Add new variable to mark if something (cart) is paid

parent cbf0f5fc
...@@ -26,21 +26,27 @@ class UserAuthSerializer(serializers.ModelSerializer): ...@@ -26,21 +26,27 @@ class UserAuthSerializer(serializers.ModelSerializer):
result['transaction_status'] = None result['transaction_status'] = None
result['cart_id'] = None result['cart_id'] = None
result['all_carts_are_expired'] = None result['all_carts_are_expired'] = False
if instance.cart.exists(): if instance.cart.exists():
result['transaction_status'] = instance.cart.last().transaction_status result['transaction_status'] = instance.cart.last().transaction_status
result['cart_id'] = instance.cart.last().id result['cart_id'] = instance.cart.last().id
something_is_paid = False
all_carts_are_expired = True all_carts_are_expired = True
for cart in instance.cart.all(): for cart in instance.cart.all():
if cart.program_end_date is None: if cart.program_end_date is None:
continue continue
something_is_paid = True
if cart.program_end_date >= datetime.date.today(): if cart.program_end_date >= datetime.date.today():
all_carts_are_expired = False all_carts_are_expired = False
break break
result['all_carts_are_expired'] = all_carts_are_expired if not something_is_paid:
result['all_carts_are_expired'] = False
else:
result['all_carts_are_expired'] = all_carts_are_expired
result['nutritionist'] = None result['nutritionist'] = None
......
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