Fakultas Ilmu Komputer UI

Commit 2a191a23 authored by Muzaki Azami's avatar Muzaki Azami
Browse files

Merge branch 'PBI-9-ModifyModelsAttributes' into 'staging'

Split physical_activity attribute into full of choices attribute and optional attribute

See merge request !60
parents 4caf8bca c1cfcd01
Pipeline #76314 passed with stages
in 11 minutes and 27 seconds
......@@ -45,10 +45,10 @@ def get_diet_questionnaire_payload_sample_with_step():
],
"multivitamin_tablet_suplement": "-",
"physical_activity": [
"jogging",
"basket",
"apa aja boleh"
1,
7
],
"other_physical_activity": "workout",
"diet_and_life_style_story": "-",
"disease": [
18
......@@ -120,20 +120,15 @@ def get_diet_questionnaire_response_sample_with_step(id, user_id):
"night_snack_explanation": "indomi",
"food_alergies": "-",
"diet_drinks": "-",
"meal_provider": [
1,
2,
3
],
"cigarette_alcohol_condition": [
4
],
"multivitamin_tablet_suplement": "-",
"physical_activity": [
"jogging",
"basket",
"apa aja boleh"
1,
7
],
"other_physical_activity": "workout",
"diet_and_life_style_story": "-",
"disease": [
18
......@@ -196,10 +191,10 @@ def get_diet_questionnaire_payload_sample_without_step():
],
"multivitamin_tablet_suplement": "-",
"physical_activity": [
"jogging",
"basket",
"apa aja boleh"
1,
7
],
"other_physical_activity": "workout",
"diet_and_life_style_story": "-",
"disease": [
18
......@@ -270,20 +265,15 @@ def get_diet_questionnaire_response_sample_without_step(id, user_id):
"night_snack_explanation": "indomi",
"food_alergies": "-",
"diet_drinks": "-",
"meal_provider": [
1,
2,
3
],
"cigarette_alcohol_condition": [
4
],
"multivitamin_tablet_suplement": "-",
"physical_activity": [
"jogging",
"basket",
"apa aja boleh"
1,
7
],
"other_physical_activity": "workout",
"diet_and_life_style_story": "-",
"disease": [
18
......
......@@ -180,6 +180,17 @@ class CigaretteAlcoholCondition(models.IntegerChoices):
CONDITION_3 = 3, 'Terkadang mengkonsumsi salah satu jenis minuman beralkohol (contoh: bir, vodka, wine)'
CONDITION_4 = 4, 'Tidak termasuk salah satu diatas'
class PhysicalActivity(models.IntegerChoices):
ACTIVITY_1 = 1, 'Hampir tidak pernah olahraga'
ACTIVITY_2 = 2, 'Jogging'
ACTIVITY_3 = 3, 'Senam aerobic, zumba, yoga, dan sejenisnya'
ACTIVITY_4 = 4, 'Sepak bola/Futsal'
ACTIVITY_5 = 5, 'Renang'
ACTIVITY_6 = 6, 'Basket'
ACTIVITY_7 = 7, 'Bulutangkis'
ACTIVITY_8 = 8, 'Voli'
ACTIVITY_9 = 9, 'Lainnya'
class Disease(models.IntegerChoices):
DISEASE_1 = 1, 'Tidak ada'
DISEASE_2 = 2, 'Diabetes Melitus Tipe II (Kencing Manis)'
......
# Generated by Django 3.1 on 2021-05-10 18:04
from django.db import migrations, models
import multiselectfield.db.fields
class Migration(migrations.Migration):
dependencies = [
('diet_questionnaire', '0006_auto_20210509_2113'),
]
operations = [
migrations.AddField(
model_name='dietquestionnaire',
name='other_physical_activity',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='dietquestionnaire',
name='physical_activity',
field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[(1, 'Hampir tidak pernah olahraga'), (2, 'Jogging'), (3, 'Senam aerobic, zumba, yoga, dan sejenisnya'), (4, 'Sepak bola/Futsal'), (5, 'Renang'), (6, 'Basket'), (7, 'Bulutangkis'), (8, 'Voli')], max_length=15, null=True),
),
]
......@@ -16,6 +16,7 @@ from constants.model_choices import (
LiquidConsumptionFrequency,
MealProvider,
CigaretteAlcoholCondition,
PhysicalActivity,
Disease,
Complaint,
)
......@@ -103,7 +104,10 @@ class DietQuestionnaire(models.Model):
choices = CigaretteAlcoholCondition.choices, null=True, blank=True
)
multivitamin_tablet_suplement = models.CharField(max_length=200, null=True, blank=True)
physical_activity = ArrayField(models.CharField(max_length=200), null=True, blank=True)
physical_activity = MultiSelectField(
choices = PhysicalActivity.choices, null=True, blank=True
)
other_physical_activity = models.CharField(max_length=200, null=True, blank=True)
diet_and_life_style_story = models.TextField(null=True, blank=True)
disease = MultiSelectField(
choices = Disease.choices, null=True, blank=True
......
......@@ -3,6 +3,7 @@ from constants.model_choices import (
MealProvider,
Complaint,
CigaretteAlcoholCondition,
PhysicalActivity,
Disease
)
from .models import DietQuestionnaire
......@@ -21,6 +22,10 @@ class DietQuestionnaireSerializer(serializers.ModelSerializer):
choices = CigaretteAlcoholCondition.choices, required=False
)
physical_activity = fields.MultipleChoiceField(
choices = PhysicalActivity.choices, required=False
)
disease = fields.MultipleChoiceField(
choices = Disease.choices, required=False
)
......
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