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):
result['transaction_status'] = None
result['cart_id'] = None
result['all_carts_are_expired'] = None
result['all_carts_are_expired'] = False
if instance.cart.exists():
result['transaction_status'] = instance.cart.last().transaction_status
result['cart_id'] = instance.cart.last().id
something_is_paid = False
all_carts_are_expired = True
for cart in instance.cart.all():
if cart.program_end_date is None:
something_is_paid = True
if cart.program_end_date >= datetime.date.today():
all_carts_are_expired = False
result['all_carts_are_expired'] = all_carts_are_expired
if not something_is_paid:
result['all_carts_are_expired'] = False
result['all_carts_are_expired'] = all_carts_are_expired
result['nutritionist'] = None
Supports Markdown
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