Fakultas Ilmu Komputer UI

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

parent 9adb8365
Pipeline #84189 passed with stages
in 12 minutes and 55 seconds
......@@ -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:
continue
something_is_paid = True
if cart.program_end_date >= datetime.date.today():
all_carts_are_expired = False
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
......
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