Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ppl-fasilkom-ui
2021
Kelas D
PT Gizi Sehat - Dietela
Dietela Backend
Commits
d2601bac
Commit
d2601bac
authored
May 31, 2021
by
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
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
constants/program_duration.py
0 → 100644
View file @
d2601bac
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
}
payment/migrations/0006_cart_program_end_date.py
0 → 100644
View file @
d2601bac
# 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
),
),
]
payment/models.py
View file @
d2601bac
...
...
@@ -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
}
"
payment/views.py
View file @
d2601bac
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment