Fakultas Ilmu Komputer UI

Commit d2601bac authored by Glenda Emanuella Sutanto's avatar Glenda Emanuella Sutanto
Browse files

[GREEN] Added program end date field in cart

parent ef7c345c
Pipeline #80249 passed with stages
in 16 minutes and 20 seconds
PROGRAM_DURATION = {
"BABY_1": 30,
"BABY_3": 90,
"GOALS_1": 30,
"GOALS_3": 90,
"GOALS_6": 180,
"BALANCED_1": 30,
"BALANCED_3": 90,
"BALANCED_6": 180,
"TRIAL": 7
}
# Generated by Django 3.1 on 2021-05-31 04:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('payment', '0005_auto_20210510_2324'),
]
operations = [
migrations.AddField(
model_name='cart',
name='program_end_date',
field=models.DateField(blank=True, null=True),
),
]
......@@ -22,6 +22,7 @@ class Cart(models.Model):
)
transaction_status = models.CharField(max_length=128,\
choices=TRANSACTION_STATUS.choices, default=TRANSACTION_STATUS.UNPAID)
program_end_date = models.DateField(null=True,blank=True)
def __str__(self):
return f"{self.user} - {self.program.unique_code} - {self.nutritionist}"
import json
import os
from datetime import timedelta, date
from rest_framework import viewsets, status
from rest_framework.response import Response
import requests
from constants.transaction_status import TransactionStatus as TRANSACTION_STATUS
from constants.string_constants import CART_NOT_FOUND_MESSAGE
from constants.program_duration import PROGRAM_DURATION
from dietela_program.serializers import DietelaProgramSerializer
from dietela_program.models import DietelaProgram
from diet_questionnaire.models import DietQuestionnaire
......@@ -119,6 +121,8 @@ class MidtransRedirectionViewSet(viewsets.ViewSet):
status=status.HTTP_400_BAD_REQUEST)
cart.transaction_status = transaction_status
cart.program_end_date = date.today() + timedelta(days=\
PROGRAM_DURATION[cart.program.unique_code])
cart.save()
DietQuestionnaire.objects.create(user=cart.user)
......
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