Fakultas Ilmu Komputer UI

Commit bdc400b9 authored by Glenda Emanuella Sutanto's avatar Glenda Emanuella Sutanto Committed by Muzaki Azami
Browse files

Setup Linter

parent ef999afd
......@@ -25,6 +25,9 @@ UnitTest:
- python manage.py runserver 8000 &
when: on_success
script:
- echo "Starting linter..."
- sh linter.sh
- echo "Starting tests..."
- coverage erase
- DATABASE_URL=$TEST_DATABASE_URL coverage run --include="./dietela_quiz/*","./nutritionists/*","./dietela_program/*" manage.py test --keepdb
- coverage xml -i
......
......@@ -14,9 +14,17 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='DietelaProgram',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('price', models.FloatField()),
('id',
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID')),
('name',
models.CharField(
max_length=255)),
('price',
models.FloatField()),
],
),
]
from django.db import models
class DietelaProgram(models.Model):
name = models.CharField(max_length=255)
price = models.FloatField()
from rest_framework import serializers
from .models import DietelaProgram
class DietelaProgramSerializer(serializers.ModelSerializer):
class Meta:
model = DietelaProgram
fields = "__all__"
......@@ -3,6 +3,7 @@ from .models import DietelaProgram
from rest_framework import status
from .serializers import DietelaProgramSerializer
class DietelaProgramTests(APITestCase):
@classmethod
......@@ -25,12 +26,13 @@ class DietelaProgramTests(APITestCase):
serializer = DietelaProgramSerializer(dietela_programs, many=True)
self.assertEqual(response.data, serializer.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_get_valid_single_dietela_program(self):
url = f"{self.BASE_URL}{self.dietela_program_1.pk}/"
response = self.client.get(url)
dietela_program = DietelaProgram.objects.get(pk=self.dietela_program_1.pk)
dietela_program = DietelaProgram.objects.get(
pk=self.dietela_program_1.pk)
serializer = DietelaProgramSerializer(dietela_program)
self.assertEqual(response.data, serializer.data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
......
......@@ -3,6 +3,7 @@ from rest_framework import viewsets
from .serializers import DietelaProgramSerializer
from .models import DietelaProgram
class DietelaProgramViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = DietelaProgramSerializer
queryset = DietelaProgram.objects.all()
from constants.quiz_constants import *
def body_mass_index(weight, height):
return weight/((height/100)**2)
return weight / ((height / 100)**2)
def nutrition_status(body_mass_index):
if (body_mass_index < 18.50): return BodyMassConstants.UNDERWEIGHT
if (body_mass_index <= 22.99): return BodyMassConstants.NORMAL
if (body_mass_index <= 25): return BodyMassConstants.PREOBESITY
if (body_mass_index <= 29.99): return BodyMassConstants.OBESITY1
if (body_mass_index < 18.50):
return BodyMassConstants.UNDERWEIGHT
if (body_mass_index <= 22.99):
return BodyMassConstants.NORMAL
if (body_mass_index <= 25):
return BodyMassConstants.PREOBESITY
if (body_mass_index <= 29.99):
return BodyMassConstants.OBESITY1
return BodyMassConstants.OBESITY2
def ideal_weight_range(height):
return {'min': 19*((height/100)**2), 'max': 23*((height/100)**2)}
return {'min': 19 * ((height / 100)**2), 'max': 23 * ((height / 100)**2)}
def basic_energy_needs(gender, weight, height, age):
if (gender == 1): return (10 * weight) + (6.25 * height - 5 * age) + 5
else: return (10 * weight) + (6.25 * height - 5 * age) - 161
if (gender == 1):
return (10 * weight) + (6.25 * height - 5 * age) + 5
else:
return (10 * weight) + (6.25 * height - 5 * age) - 161
def physical_activity_percentage(body_activity):
physical_activity_percentage_switch = {
......@@ -27,29 +38,60 @@ def physical_activity_percentage(body_activity):
}
return physical_activity_percentage_switch.get(body_activity)
def daily_energy_needs(special_condition, body_mass, basic_energy_needs, physical_activity_percentage):
if (special_condition == 2): return basic_energy_needs + (physical_activity_percentage * basic_energy_needs)
if (special_condition == 3): return basic_energy_needs + (physical_activity_percentage * basic_energy_needs) + 340
if (special_condition == 4): return basic_energy_needs + (physical_activity_percentage * basic_energy_needs) + 452
if (special_condition == 5): return basic_energy_needs + (physical_activity_percentage * basic_energy_needs) + 330
if (special_condition == 6): return basic_energy_needs + (physical_activity_percentage * basic_energy_needs) + 400
if (body_mass == BodyMassConstants.OBESITY1 or body_mass == BodyMassConstants.OBESITY2): return basic_energy_needs
if (body_mass == BodyMassConstants.UNDERWEIGHT): return basic_energy_needs + (physical_activity_percentage * basic_energy_needs) + (0.1 * basic_energy_needs)
return basic_energy_needs + (physical_activity_percentage * basic_energy_needs)
def daily_energy_needs(
special_condition,
body_mass,
basic_energy_needs,
physical_activity_percentage):
if (special_condition == 2):
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs)
if (special_condition == 3):
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + 340
if (special_condition == 4):
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + 452
if (special_condition == 5):
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + 330
if (special_condition == 6):
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + 400
if (body_mass == BodyMassConstants.OBESITY1 or body_mass ==
BodyMassConstants.OBESITY2):
return basic_energy_needs
if (body_mass == BodyMassConstants.UNDERWEIGHT):
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + (0.1 * basic_energy_needs)
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs)
def recommendation_breakfast(breakfast_frequency):
if (breakfast_frequency == 1): return BreakfastReponse.NO_BREAKFAST
if (breakfast_frequency == 2): return BreakfastReponse.MED_BREAKFAST
if (breakfast_frequency == 3): return BreakfastReponse.HI_BREAKFAST
if (breakfast_frequency == 1):
return BreakfastReponse.NO_BREAKFAST
if (breakfast_frequency == 2):
return BreakfastReponse.MED_BREAKFAST
if (breakfast_frequency == 3):
return BreakfastReponse.HI_BREAKFAST
def physical_activity_recommendation(physical_activity_frequency):
if (physical_activity_frequency == 1): return PhysicalActivityResponse.LEVEL1_ACTIVITY
if (physical_activity_frequency == 2): return PhysicalActivityResponse.LEVEL2_ACTIVITY
if (physical_activity_frequency == 3): return PhysicalActivityResponse.LEVEL3_ACTIVITY
if (physical_activity_frequency == 4): return PhysicalActivityResponse.LEVEL4_ACTIVITY
if (physical_activity_frequency == 5): return PhysicalActivityResponse.LEVEL5_ACTIVITY
if (physical_activity_frequency == 1):
return PhysicalActivityResponse.LEVEL1_ACTIVITY
if (physical_activity_frequency == 2):
return PhysicalActivityResponse.LEVEL2_ACTIVITY
if (physical_activity_frequency == 3):
return PhysicalActivityResponse.LEVEL3_ACTIVITY
if (physical_activity_frequency == 4):
return PhysicalActivityResponse.LEVEL4_ACTIVITY
if (physical_activity_frequency == 5):
return PhysicalActivityResponse.LEVEL5_ACTIVITY
def energy_needed_per_dine(breakfast_intensity,daily_energy_needs):
def energy_needed_per_dine(breakfast_intensity, daily_energy_needs):
energy_dictionary = {}
if (0 < breakfast_intensity < 3):
energy_dictionary['breakfast'] = daily_energy_needs * 0.1
......@@ -67,19 +109,17 @@ def energy_needed_per_dine(breakfast_intensity,daily_energy_needs):
return energy_dictionary
return energy_dictionary
def program_recommendation(condition,target,disease):
def program_recommendation(condition, target, disease):
score = condition + target + disease
programs_dictionary = {}
if (22 <= score <= 30):
if (22 <= score <= 30) or (70 <= score <= 79):
programs_dictionary['priority_1'] = ProgramRecommendationResponse.BABY_1
programs_dictionary['priority_2'] = ProgramRecommendationResponse.TRIAL
elif (31 <= score <= 69):
programs_dictionary['priority_1'] = ProgramRecommendationResponse.BABY_3
programs_dictionary['priority_2'] = ProgramRecommendationResponse.BABY_1
elif (70 <= score <= 79):
programs_dictionary['priority_1'] = ProgramRecommendationResponse.BABY_1
programs_dictionary['priority_2'] = ProgramRecommendationResponse.TRIAL
elif (80 <= score <= 99):
programs_dictionary['priority_1'] = ProgramRecommendationResponse.GOALS_3
programs_dictionary['priority_2'] = ProgramRecommendationResponse.GOALS_1
......
......@@ -14,27 +14,239 @@ class Migration(migrations.Migration):
migrations.CreateModel(
name='DietProfile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nama', models.CharField(max_length=100)),
('email', models.EmailField(max_length=100)),
('usia', models.PositiveIntegerField()),
('berat_badan', models.PositiveIntegerField()),
('tinggi_badan', models.PositiveIntegerField()),
('jenis_kelamin', models.IntegerField(choices=[(1, 'Laki-laki'), (2, 'Perempuan')])),
('kondisi_khusus', models.IntegerField(choices=[(1, 'Tidak ada'), (2, 'Hamil Trimester 1'), (3, 'Hamil Trimester 2'), (4, 'Hamil Trimester 3'), (5, 'Menyusui Bayi 0-6 Bulan'), (6, 'Menyusui Bayi 7-12 Bulan')])),
('aktif_badan', models.IntegerField(choices=[(1, 'Lebih banyak duduk dan tidak rutin olahraga'), (2, 'Banyak jalan, banyak bergerak, tetapi tidak rutin olahraga'), (3, 'Olahraga rutin 30-45 menit per hari'), (4, 'Olahraga rutin 45-60 menit per hari'), (5, 'Olahraga rutin lebih dari 60 menit per hari')])),
('sayur_dimakan_sehari', models.IntegerField(choices=[(1, '0 porsi'), (2, '1 porsi'), (3, '2 porsi'), (4, '3 porsi'), (5, 'Lebih dari 3 porsi')])),
('buah_dimakan_sehari', models.IntegerField(choices=[(1, '0 porsi'), (2, '1 porsi'), (3, '2 porsi'), (4, '3 porsi'), (5, 'Lebih dari 3 porsi')])),
('gorengan_dimakan_sehari', models.IntegerField(choices=[(1, '0 potong'), (2, '1 potong'), (3, '2 potong'), (4, '3 potong'), (5, 'Lebih dari 3 potong')])),
('cemilan_manis_dimakan_sehari', models.IntegerField(choices=[(1, '0 potong'), (2, '1 potong'), (3, '2 potong'), (4, '3 potong'), (5, 'Lebih dari 3 potong')])),
('minuman_manis_diminum_sehari', models.IntegerField(choices=[(1, '0 gelas'), (2, '1 gelas'), (3, '2 gelas'), (4, '3 gelas'), (5, 'Lebih dari 3 gelas')])),
('makanan_kemasan_dimakan_sehari', models.IntegerField(choices=[(1, '0 porsi'), (2, '1 porsi'), (3, '2 porsi'), (4, '3 porsi'), (5, 'Lebih dari 3 porsi')])),
('makanan_besar_dimakan_sehari', models.IntegerField(choices=[(1, '1 kali'), (2, '2 kali'), (3, '3 kali'), (4, 'Lebih dari 3 kali')])),
('cemilan_dimakan_sehari', models.IntegerField(choices=[(1, 'Tidak pernah'), (2, '1 kali '), (3, '2 kali'), (4, '3 kali'), (5, 'Lebih dari 3 kali')])),
('jenis_makanan_pagi', models.IntegerField(choices=[(1, 'Tidak pernah makan pagi'), (2, 'Makanan yang ringan saja'), (3, 'Makanan yang sampai mengenyangkan perut')])),
('kondisi_saat_ini', models.IntegerField(choices=[(1, 'Saya belum tertarik melakukan diet dan gaya hidup sehat dan tidak tahu kondisi gizi serta kesehatan saya'), (2, 'Saya belum tertarik melakukan diet dan gaya hidup sehat meskipun saya tahu kondisi gizi dan kesehatan saya'), (3, 'Saya mulai tertarik melakukan diet dan gaya hidup sehat meskipun saya tidak tahu kondisi gizi dan kesehatan saya'), (4, 'Saya mulai tertarik melakukan diet dan gaya hidup sehat dan tahu kondisi gizi dan kesehatan saya'), (5, 'Saya sudah tahu manfaat diet dan gaya hidup sehat namun belum tahu harus mulai menerapkannya dari mana'), (6, 'Saya sudah pernah merubah diet dan gaya hidup menjadi lebih sehat tetapi tidak bertahan lama (dilakukan kurang dari 6 bulan)'), (7, 'Saya sudah pernah berhasil menjalani diet dan gaya hidup sehat selama lebih dari 6 bulan dan ingin melakukannya lagi')])),
('masalah_ingin_diselesaikan', models.IntegerField(choices=[(1, 'Turun berat badan dengan target yang realistis'), (2, 'Naik berat badan dengan target yang realistis'), (3, 'Berat badan yang bertahan permanen, menjaga agar berat badan tidak naik, anti yo-yo diet'), (4, 'Butuh pengaturan gizi Ibu Hamil'), (5, 'Butuh pengaturan gizi Ibu Menyusui'), (6, 'Menyiapkan tubuh untuk mencapai kesuburan dan persiapan kehamilan'), (7, 'Mengatur gula darah tinggi (Pre-diabetes), hiperlipidemia (kolesterol), hipertensi (tekanan darah tinggi)'), (8, 'Capai pola makan sehat dan tetap enjoy menikmati makanan yang disukai'), (9, 'Transisi vegan'), (10, ' Butuh pengaturan gizi pada anak-anak atau remaja')])),
('masalah_kesehatan_dimiliki', models.IntegerField(choices=[(1, 'Tidak ada yang perlu dikhawatirkan'), (2, 'Diabetes Tipe 2'), (3, 'Diabetes Tipe 1'), (4, 'PCOS (Polycystic Ovary Syndrome)'), (5, 'Kolesterol tinggi'), (6, 'Asam urat tinggi'), (7, 'Tekanan darah tinggi'), (8, 'Gula darah tinggi'), (9, 'Kanker'), (10, 'HIV/AIDS'), (11, 'Maag/GERD/Dispepsia/Gangguan lambung'), (12, 'Penyintas Kanker'), (13, 'Penyakit Kronis Lainnya')])),
('id',
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name='ID')),
('nama',
models.CharField(
max_length=100)),
('email',
models.EmailField(
max_length=100)),
('usia',
models.PositiveIntegerField()),
('berat_badan',
models.PositiveIntegerField()),
('tinggi_badan',
models.PositiveIntegerField()),
('jenis_kelamin',
models.IntegerField(
choices=[
(1,
'Laki-laki'),
(2,
'Perempuan')])),
('kondisi_khusus',
models.IntegerField(
choices=[
(1,
'Tidak ada'),
(2,
'Hamil Trimester 1'),
(3,
'Hamil Trimester 2'),
(4,
'Hamil Trimester 3'),
(5,
'Menyusui Bayi 0-6 Bulan'),
(6,
'Menyusui Bayi 7-12 Bulan')])),
('aktif_badan',
models.IntegerField(
choices=[
(1,
'Lebih banyak duduk dan tidak rutin olahraga'),
(2,
'Banyak jalan, banyak bergerak, tetapi tidak rutin olahraga'),
(3,
'Olahraga rutin 30-45 menit per hari'),
(4,
'Olahraga rutin 45-60 menit per hari'),
(5,
'Olahraga rutin lebih dari 60 menit per hari')])),
('sayur_dimakan_sehari',
models.IntegerField(
choices=[
(1,
'0 porsi'),
(2,
'1 porsi'),
(3,
'2 porsi'),
(4,
'3 porsi'),
(5,
'Lebih dari 3 porsi')])),
('buah_dimakan_sehari',
models.IntegerField(
choices=[
(1,
'0 porsi'),
(2,
'1 porsi'),
(3,
'2 porsi'),
(4,
'3 porsi'),
(5,
'Lebih dari 3 porsi')])),
('gorengan_dimakan_sehari',
models.IntegerField(
choices=[
(1,
'0 potong'),
(2,
'1 potong'),
(3,
'2 potong'),
(4,
'3 potong'),
(5,
'Lebih dari 3 potong')])),
('cemilan_manis_dimakan_sehari',
models.IntegerField(
choices=[
(1,
'0 potong'),
(2,
'1 potong'),
(3,
'2 potong'),
(4,
'3 potong'),
(5,
'Lebih dari 3 potong')])),
('minuman_manis_diminum_sehari',
models.IntegerField(
choices=[
(1,
'0 gelas'),
(2,
'1 gelas'),
(3,
'2 gelas'),
(4,
'3 gelas'),
(5,
'Lebih dari 3 gelas')])),
('makanan_kemasan_dimakan_sehari',
models.IntegerField(
choices=[
(1,
'0 porsi'),
(2,
'1 porsi'),
(3,
'2 porsi'),
(4,
'3 porsi'),
(5,
'Lebih dari 3 porsi')])),
('makanan_besar_dimakan_sehari',
models.IntegerField(
choices=[
(1,
'1 kali'),
(2,
'2 kali'),
(3,
'3 kali'),
(4,
'Lebih dari 3 kali')])),
('cemilan_dimakan_sehari',
models.IntegerField(
choices=[
(1,
'Tidak pernah'),
(2,
'1 kali '),
(3,
'2 kali'),
(4,
'3 kali'),
(5,
'Lebih dari 3 kali')])),
('jenis_makanan_pagi',
models.IntegerField(
choices=[
(1,
'Tidak pernah makan pagi'),
(2,
'Makanan yang ringan saja'),
(3,
'Makanan yang sampai mengenyangkan perut')])),
('kondisi_saat_ini',
models.IntegerField(
choices=[
(1,
'Saya belum tertarik melakukan diet dan gaya hidup sehat dan tidak tahu kondisi gizi serta kesehatan saya'),
(2,
'Saya belum tertarik melakukan diet dan gaya hidup sehat meskipun saya tahu kondisi gizi dan kesehatan saya'),
(3,
'Saya mulai tertarik melakukan diet dan gaya hidup sehat meskipun saya tidak tahu kondisi gizi dan kesehatan saya'),
(4,
'Saya mulai tertarik melakukan diet dan gaya hidup sehat dan tahu kondisi gizi dan kesehatan saya'),
(5,
'Saya sudah tahu manfaat diet dan gaya hidup sehat namun belum tahu harus mulai menerapkannya dari mana'),
(6,
'Saya sudah pernah merubah diet dan gaya hidup menjadi lebih sehat tetapi tidak bertahan lama (dilakukan kurang dari 6 bulan)'),
(7,
'Saya sudah pernah berhasil menjalani diet dan gaya hidup sehat selama lebih dari 6 bulan dan ingin melakukannya lagi')])),
('masalah_ingin_diselesaikan',
models.IntegerField(
choices=[
(1,
'Turun berat badan dengan target yang realistis'),
(2,
'Naik berat badan dengan target yang realistis'),
(3,
'Berat badan yang bertahan permanen, menjaga agar berat badan tidak naik, anti yo-yo diet'),
(4,
'Butuh pengaturan gizi Ibu Hamil'),
(5,
'Butuh pengaturan gizi Ibu Menyusui'),
(6,
'Menyiapkan tubuh untuk mencapai kesuburan dan persiapan kehamilan'),
(7,
'Mengatur gula darah tinggi (Pre-diabetes), hiperlipidemia (kolesterol), hipertensi (tekanan darah tinggi)'),
(8,
'Capai pola makan sehat dan tetap enjoy menikmati makanan yang disukai'),
(9,
'Transisi vegan'),
(10,
' Butuh pengaturan gizi pada anak-anak atau remaja')])),
('masalah_kesehatan_dimiliki',
models.IntegerField(
choices=[
(1,
'Tidak ada yang perlu dikhawatirkan'),
(2,
'Diabetes Tipe 2'),
(3,
'Diabetes Tipe 1'),
(4,
'PCOS (Polycystic Ovary Syndrome)'),
(5,
'Kolesterol tinggi'),
(6,
'Asam urat tinggi'),
(7,
'Tekanan darah tinggi'),
(8,
'Gula darah tinggi'),
(9,
'Kanker'),
(10,
'HIV/AIDS'),
(11,
'Maag/GERD/Dispepsia/Gangguan lambung'),
(12,
'Penyintas Kanker'),
(13,
'Penyakit Kronis Lainnya')])),
],
),
]
from django.db import models
from constants.model_choices import DietProfileChoices
# Create your models here.
class DietProfile(models.Model):
name = models.CharField(max_length=100)
......@@ -10,18 +10,31 @@ class DietProfile(models.Model):
weight = models.PositiveIntegerField()
height = models.PositiveIntegerField()
gender = models.IntegerField(choices=DietProfileChoices.CHOICES_GENDER)
special_condition = models.IntegerField(choices=DietProfileChoices.CHOICES_SPECIAL_CONDITION)
body_activity = models.IntegerField(choices=DietProfileChoices.CHOICES_BODY_ACTIVITY)
vegetables_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_VEGETABLES_IN_ONE_DAY)
fruits_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_FRUITS_IN_ONE_DAY)
fried_food_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_FRIED_FOOD_IN_ONE_DAY)
sweet_snacks_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_SWEET_SNACKS_IN_ONE_DAY)
sweet_drinks_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_SWEET_DRINKS_IN_ONE_DAY)
packaged_food_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_PACKAGED_FOOD_IN_ONE_DAY)
large_meal_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_LARGE_MEAL_IN_ONE_DAY)
snacks_in_one_day = models.IntegerField(choices=DietProfileChoices.CHOICES_SNACKS_IN_ONE_DAY)
breakfast_type = models.IntegerField(choices=DietProfileChoices.CHOICES_BREAKFAST_TYPE)
current_condition = models.IntegerField(choices=DietProfileChoices.CHOICES_CURRENT_CONDITION)
problem_to_solve = models.IntegerField(choices=DietProfileChoices.CHOICES_PROBLEM_TO_SOLVE)
health_problem = models.IntegerField(choices=DietProfileChoices.CHOICES_HEALTH_PROBLEM)
special_condition = models.IntegerField(
choices=DietProfileChoices.CHOICES_SPECIAL_CONDITION)
body_activity = models.IntegerField(
choices=DietProfileChoices.CHOICES_BODY_ACTIVITY)
vegetables_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_VEGETABLES_IN_ONE_DAY)
fruits_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_FRUITS_IN_ONE_DAY)
fried_food_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_FRIED_FOOD_IN_ONE_DAY)
sweet_snacks_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_SWEET_SNACKS_IN_ONE_DAY)
sweet_drinks_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_SWEET_DRINKS_IN_ONE_DAY)
packaged_food_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_PACKAGED_FOOD_IN_ONE_DAY)
large_meal_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_LARGE_MEAL_IN_ONE_DAY)
snacks_in_one_day = models.IntegerField(
choices=DietProfileChoices.CHOICES_SNACKS_IN_ONE_DAY)
breakfast_type = models.IntegerField(
choices=DietProfileChoices.CHOICES_BREAKFAST_TYPE)
current_condition = models.IntegerField(
choices=DietProfileChoices.CHOICES_CURRENT_CONDITION)
problem_to_solve = models.IntegerField(
choices=DietProfileChoices.CHOICES_PROBLEM_TO_SOLVE)
health_problem = models.IntegerField(
choices=DietProfileChoices.CHOICES_HEALTH_PROBLEM)
......@@ -2,9 +2,9 @@ from rest_framework import serializers
from .models import DietProfile
class DietProfileSerializer(serializers.ModelSerializer):
class Meta:
model = DietProfile
fields = "__all__"
This diff is collapsed.
......@@ -4,6 +4,8 @@ from .serializers import DietProfileSerializer
from .models import DietProfile
# Create your views here.
class DietProfileViewSet(viewsets.ModelViewSet):
serializer_class = DietProfileSerializer
queryset = DietProfile.objects.all()
autopep8 -iraav dietela_program dietela_quiz nutritionists
pycodestyle --exclude="**/migrations/**" --show-source --show-pep8 --ignore=E501,W503,W504 dietela_program dietela_quiz nutritionists
from django.db import models
class Nutritionist(models.Model):
full_name_and_degree = models.CharField(max_length=255)
registration_certificate_no = models.CharField(max_length=255)
......
from rest_framework import serializers
from .models import Nutritionist
class NutritionistSerializer(serializers.ModelSerializer):