Fakultas Ilmu Komputer UI

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

Merge branch 'setup-pylint' into 'staging'

Setup Pylint

See merge request !28
parents 8633adee 0897a2b9
Pipeline #69729 passed with stages
in 9 minutes and 28 seconds
......@@ -3,6 +3,16 @@ stages:
# - sonar-scanner
- deploy
pylint:
image: python:3.7
stage: test
allow_failure: true
before_script:
- pip install -r requirements.txt
when: on_success
script:
- pylint --load-plugins pylint_django --rcfile=./.pylintrc dietela_backend dietela_program dietela_quiz nutritionists
UnitTest:
image: python:3.6.5
stage: test
......@@ -14,8 +24,6 @@ UnitTest:
- python manage.py runserver 8000 &
when: on_success
script:
- echo "Starting linter..."
- sh linter.sh
- echo "Starting tests..."
- rm -f coverage.xml
- coverage erase
......
[MASTER]
disable=
C0114, # missing-module-docstring
C0115, # missing-class-docstring
C0116, # missing-function-docstring
E5110, # django-not-configured
[DESIGN]
max-parents=15
max-locals=30
max-returns=10
ignore-imports=yes
from rest_framework.test import APITestCase
from .models import DietelaProgram
from rest_framework import status
from .models import DietelaProgram
from .serializers import DietelaProgramSerializer
......
from django.urls import path
from rest_framework import routers
from .views import DietelaProgramViewSet
......
from django.shortcuts import render
from rest_framework import viewsets
from .serializers import DietelaProgramSerializer
from .models import DietelaProgram
......
from django.apps import AppConfig
class dietela_quizConfig(AppConfig):
class DietelaQuizConfig(AppConfig):
name = 'dietela_quiz'
from constants.quiz_constants import *
from constants.model_choices import *
from constants.quiz_constants import (
BreakfastReponse,
PhysicalActivityResponse,
ProgramRecommendationResponse,
BodyMassConstants,
VegetableAndFruitSufficiencyResponse,
VegetableAndFruitDietRecommendation,
SugarSaltFatProblemResponse,
SugarSaltFatDietRecommendation,
LargeMealDietRecommendation,
SnacksDietRecommendation,
)
def get_body_mass_index(weight, height):
......@@ -9,19 +19,19 @@ def get_body_mass_index(weight, height):
def get_nutrition_status(body_mass_index):
if (body_mass_index < 18.50):
if body_mass_index < 18.50:
return BodyMassConstants.UNDERWEIGHT
if (body_mass_index <= 22.99):
if body_mass_index <= 22.99:
return BodyMassConstants.NORMAL
if (body_mass_index <= 25):
if body_mass_index <= 25:
return BodyMassConstants.PREOBESITY
if (body_mass_index <= 29.99):
if body_mass_index <= 29.99:
return BodyMassConstants.OBESITY1
return BodyMassConstants.OBESITY2
def get_ideal_weight_range(height):
if (height < 0):
if height < 0:
raise ValueError("Invalid input for ideal weight range!")
return {'min': 19 * ((height / 100)**2), 'max': 23 * ((height / 100)**2)}
......@@ -30,10 +40,9 @@ def get_basic_energy_needs(gender, weight, height, age):
if (gender > 2) or (gender < 1) or (
weight < 0) or (height < 0) or (age < 0):
raise ValueError("Invalid input for basic energy needs!")
if (gender == 1):
if gender == 1:
return (10 * weight) + (6.25 * height - 5 * age) + 5
else:
return (10 * weight) + (6.25 * height - 5 * age) - 161
return (10 * weight) + (6.25 * height - 5 * age) - 161
def get_physical_activity_percentage(body_activity):
......@@ -54,25 +63,24 @@ def get_daily_energy_needs(
body_mass,
basic_energy_needs,
physical_activity_percentage):
if (special_condition == 2):
if special_condition == 2:
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs)
if (special_condition == 3):
if special_condition == 3:
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + 340
if (special_condition == 4):
if special_condition == 4:
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + 452
if (special_condition == 5):
if special_condition == 5:
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + 330
if (special_condition == 6):
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):
if body_mass in (BodyMassConstants.OBESITY1, BodyMassConstants.OBESITY2):
return basic_energy_needs
if (body_mass == BodyMassConstants.UNDERWEIGHT):
if body_mass == BodyMassConstants.UNDERWEIGHT:
return basic_energy_needs + \
(physical_activity_percentage * basic_energy_needs) + (0.1 * basic_energy_needs)
return basic_energy_needs + \
......@@ -80,34 +88,34 @@ def get_daily_energy_needs(
def get_breakfast_recommendation(breakfast_type):
if (breakfast_type == 1):
if breakfast_type == 1:
return BreakfastReponse.NO_BREAKFAST
if (breakfast_type == 2):
if breakfast_type == 2:
return BreakfastReponse.MED_BREAKFAST
return BreakfastReponse.HI_BREAKFAST
def get_physical_activity_recommendation(physical_activity_frequency):
if (physical_activity_frequency == 1):
if physical_activity_frequency == 1:
return PhysicalActivityResponse.LEVEL1_ACTIVITY
if (physical_activity_frequency == 2):
if physical_activity_frequency == 2:
return PhysicalActivityResponse.LEVEL2_ACTIVITY
if (physical_activity_frequency == 3):
if physical_activity_frequency == 3:
return PhysicalActivityResponse.LEVEL3_ACTIVITY
if (physical_activity_frequency == 4):
if physical_activity_frequency == 4:
return PhysicalActivityResponse.LEVEL4_ACTIVITY
return PhysicalActivityResponse.LEVEL5_ACTIVITY
def get_energy_needed_per_dine(breakfast_type, daily_energy_needs):
energy_dictionary = {}
if (0 < breakfast_type < 3):
if 0 < breakfast_type < 3:
energy_dictionary['breakfast'] = daily_energy_needs * 0.1
energy_dictionary['morning_snack'] = daily_energy_needs * 0.15
energy_dictionary['lunch'] = daily_energy_needs * 0.3
energy_dictionary['afternoon_snack'] = daily_energy_needs * 0.15
energy_dictionary['dinner'] = daily_energy_needs * 0.3
elif (breakfast_type == 3):
elif breakfast_type == 3:
energy_dictionary['breakfast'] = daily_energy_needs * 0.2
energy_dictionary['morning_snack'] = daily_energy_needs * 0.1
energy_dictionary['lunch'] = daily_energy_needs * 0.3
......@@ -125,22 +133,22 @@ def get_program_recommendation(current_condition, problem_to_solve, health_probl
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):
elif 31 <= score <= 69:
programs_dictionary['priority_1'] = ProgramRecommendationResponse.BABY_3
programs_dictionary['priority_2'] = ProgramRecommendationResponse.BABY_1
elif (80 <= score <= 99):
elif 80 <= score <= 99:
programs_dictionary['priority_1'] = ProgramRecommendationResponse.GOALS_3
programs_dictionary['priority_2'] = ProgramRecommendationResponse.GOALS_1
elif (100 <= score <= 119):
elif 100 <= score <= 119:
programs_dictionary['priority_1'] = ProgramRecommendationResponse.GOALS_6
programs_dictionary['priority_2'] = ProgramRecommendationResponse.GOALS_3
elif (120 <= score <= 150):
elif 120 <= score <= 150:
programs_dictionary['priority_1'] = ProgramRecommendationResponse.BALANCED_1
programs_dictionary['priority_2'] = ProgramRecommendationResponse.TRIAL
elif (151 <= score <= 159):
elif 151 <= score <= 159:
programs_dictionary['priority_1'] = ProgramRecommendationResponse.BALANCED_3
programs_dictionary['priority_2'] = ProgramRecommendationResponse.BALANCED_1
elif (160 <= score <= 179):
elif 160 <= score <= 179:
programs_dictionary['priority_1'] = ProgramRecommendationResponse.BALANCED_6
programs_dictionary['priority_2'] = ProgramRecommendationResponse.BALANCED_3
else:
......@@ -193,7 +201,7 @@ def get_carbohydrate_needs(
return get_calculate_specific_nutrition_needs(55, daily_energy_needs, 4)
def get_fiber_needs(body_mass_index):
def get_fiber_needs():
return 25
......@@ -220,7 +228,7 @@ def get_vegetable_and_fruit_sufficiency_response(
total_vegetable_and_fruit_score > 8):
raise ValueError("Invalid total vegetable and fruit score!")
if (0 <= total_vegetable_and_fruit_score <= 4):
if 0 <= total_vegetable_and_fruit_score <= 4:
return VegetableAndFruitSufficiencyResponse.LACKING
return VegetableAndFruitSufficiencyResponse.ENOUGH
......@@ -263,7 +271,7 @@ def get_sugar_salt_fat_problem_response(total_sugar_salt_fat_score):
if (total_sugar_salt_fat_score < 0) or (total_sugar_salt_fat_score > 12):
raise ValueError("Invalid total sugar, salt, fat score!")
if (0 <= total_sugar_salt_fat_score <= 5):
if 0 <= total_sugar_salt_fat_score <= 5:
return SugarSaltFatProblemResponse.CONTROLLED
return SugarSaltFatProblemResponse.EXCESSIVE
......@@ -279,11 +287,11 @@ def get_large_meal_diet_recommendation(large_meal_in_one_day):
if (large_meal_in_one_day < 1) or (large_meal_in_one_day > 4):
raise ValueError("Invalid large meal choice number!")
if (large_meal_in_one_day == 1):
if large_meal_in_one_day == 1:
return LargeMealDietRecommendation.ONCE_A_DAY
if (large_meal_in_one_day == 2):
if large_meal_in_one_day == 2:
return LargeMealDietRecommendation.TWICE_A_DAY
if (large_meal_in_one_day == 3):
if large_meal_in_one_day == 3:
return LargeMealDietRecommendation.THRICE_A_DAY
return LargeMealDietRecommendation.MORE_THAN_THRICE_A_DAY
......@@ -292,12 +300,12 @@ def get_snacks_diet_recommendation(snacks_in_one_day):
if (snacks_in_one_day < 1) or (snacks_in_one_day > 5):
raise ValueError("Invalid snacks choice number!")
if (snacks_in_one_day == 1):
if snacks_in_one_day == 1:
return SnacksDietRecommendation.NO_SNACK
if (snacks_in_one_day == 2):
if snacks_in_one_day == 2:
return SnacksDietRecommendation.ONCE_A_DAY
if (snacks_in_one_day == 3):
if snacks_in_one_day == 3:
return SnacksDietRecommendation.TWICE_A_DAY
if (snacks_in_one_day == 4):
if snacks_in_one_day == 4:
return SnacksDietRecommendation.THRICE_A_DAY
return SnacksDietRecommendation.MORE_THAN_THRICE_A_DAY
from django.db import models
from multiselectfield import MultiSelectField
from constants.model_choices import (
Gender,
SpecialCondition,
......@@ -13,8 +14,6 @@ from constants.model_choices import (
ProblemToSolve,
HealthProblem
)
from multiselectfield import MultiSelectField
from .formulas import *
class DietProfile(models.Model):
......
from rest_framework import fields, serializers
from constants.model_choices import HealthProblem
from .models import DietProfile, QuizResult
from .utilities import create_or_update_quiz_result
class DietProfileSerializer(serializers.ModelSerializer):
......@@ -14,7 +13,6 @@ class DietProfileSerializer(serializers.ModelSerializer):
class QuizResultSerializer(serializers.ModelSerializer):
class Meta:
model = QuizResult
fields = "__all__"
import json
import unittest
from rest_framework.test import APITestCase
from rest_framework import status
from .models import DietProfile, QuizResult
from django.test import TestCase
from constants.quiz_constants import *
from constants.quiz_constants import (
BreakfastReponse,
PhysicalActivityResponse,
ProgramRecommendationResponse,
BodyMassConstants,
VegetableAndFruitSufficiencyResponse,
VegetableAndFruitDietRecommendation,
SugarSaltFatProblemResponse,
SugarSaltFatDietRecommendation,
LargeMealDietRecommendation,
SnacksDietRecommendation,
)
from .models import DietProfile, QuizResult
from .formulas import (
get_body_mass_index,
get_nutrition_status,
......@@ -60,7 +70,7 @@ class DietelaQuizTests(APITestCase):
def test_diet_profile_saved(self):
self.assertEqual(DietProfile.objects.count(), 1)
def test_diet_profile_string(self):
self.assertEqual(str(self.diet_profile), 'test - test@test.com')
......@@ -122,7 +132,7 @@ class DietelaQuizTests(APITestCase):
'problem_to_solve': 1,
'health_problem': [1]
}
response = self.client.post(
self.client.post(
'/dietela-quiz/diet-profile/', data, format='json')
self.assertEqual(QuizResult.objects.filter(diet_profile__name='test3').count(), 1)
......@@ -338,13 +348,13 @@ class FormulaTest(TestCase):
hi_breakfast = 3
self.assertEqual(
get_breakfast_recommendation(1),
get_breakfast_recommendation(no_breakfast),
BreakfastReponse.NO_BREAKFAST)
self.assertEqual(
get_breakfast_recommendation(2),
get_breakfast_recommendation(med_breakfast),
BreakfastReponse.MED_BREAKFAST)
self.assertEqual(
get_breakfast_recommendation(3),
get_breakfast_recommendation(hi_breakfast),
BreakfastReponse.HI_BREAKFAST)
def test_get_physical_activity_recommendation(self):
......@@ -519,7 +529,7 @@ class FormulaTest(TestCase):
body_mass_index = 20
daily_energy_needs = 500
self.assertEquals(
self.assertEqual(
get_protein_needs(
special_condition_choice,
body_mass_index,
......@@ -534,7 +544,7 @@ class FormulaTest(TestCase):
body_mass_index = 35
daily_energy_needs = 450
self.assertEquals(
self.assertEqual(
get_protein_needs(
special_condition_choice,
body_mass_index,
......@@ -549,7 +559,7 @@ class FormulaTest(TestCase):
body_mass_index = 20
daily_energy_needs = 500
self.assertEquals(
self.assertEqual(
get_fat_needs(
special_condition_choice,
body_mass_index,
......@@ -564,7 +574,7 @@ class FormulaTest(TestCase):
body_mass_index = 35
daily_energy_needs = 450
self.assertEquals(
self.assertEqual(
get_fat_needs(
special_condition_choice,
body_mass_index,
......@@ -579,7 +589,7 @@ class FormulaTest(TestCase):
body_mass_index = 20
daily_energy_needs = 500
self.assertEquals(
self.assertEqual(
get_carbohydrate_needs(
special_condition_choice,
body_mass_index,
......@@ -594,7 +604,7 @@ class FormulaTest(TestCase):
body_mass_index = 35
daily_energy_needs = 450
self.assertEquals(
self.assertEqual(
get_carbohydrate_needs(
special_condition_choice,
body_mass_index,
......@@ -605,9 +615,8 @@ class FormulaTest(TestCase):
4))
def test_get_fiber_needs(self):
body_mass_index = 35
self.assertEqual(get_fiber_needs(body_mass_index), 25)
self.assertEqual(get_fiber_needs(), 25)
def test_get_food_consumed_score(self):
choice = 3
......@@ -874,7 +883,6 @@ class FormulaTest(TestCase):
class QuizResultTests(APITestCase):
def setUp(self):
self.diet_profile = DietProfile.objects.create(
name="test2",
......@@ -898,7 +906,7 @@ class QuizResultTests(APITestCase):
problem_to_solve=1,
health_problem=[2, 3])
self.quizResult = QuizResult.objects.create(
self.quiz_result = QuizResult.objects.create(
diet_profile = self.diet_profile,
age = self.diet_profile.age,
weight = self.diet_profile.weight,
......@@ -930,9 +938,9 @@ class QuizResultTests(APITestCase):
'priority_2': ProgramRecommendationResponse.TRIAL,
}
)
def test_quiz_result_saved(self):
self.assertEqual(QuizResult.objects.count(), 1)
def test_quiz_result_string(self):
self.assertEqual(str(self.quizResult), str(self.diet_profile))
self.assertEqual(str(self.quiz_result), str(self.diet_profile))
from django.urls import path
from rest_framework import routers
from .views import DietProfileViewSet
......
from .formulas import *
from .formulas import (
get_body_mass_index,
get_nutrition_status,
get_ideal_weight_range,
get_basic_energy_needs,
get_physical_activity_percentage,
get_daily_energy_needs,
get_protein_needs,
get_fat_needs,
get_carbohydrate_needs,
get_fiber_needs,
get_total_vegetable_and_fruit_score,
get_vegetable_and_fruit_sufficiency_response,
get_vegetable_and_fruit_diet_recommendation,
get_total_sugar_salt_fat_score,
get_sugar_salt_fat_problem_response,
get_sugar_salt_fat_diet_recommendation,
get_large_meal_diet_recommendation,
get_snacks_diet_recommendation,
get_breakfast_recommendation,
get_energy_needed_per_dine,
get_physical_activity_recommendation,
get_program_recommendation,
)
from .models import (
QuizResult
)
......@@ -11,38 +34,61 @@ def create_or_update_quiz_result(profile):
body_mass_index = get_body_mass_index(profile.weight,profile.height)
nutrition_status = get_nutrition_status(body_mass_index)
ideal_weight_range = get_ideal_weight_range(profile.height)
basic_energy_needs = get_basic_energy_needs(profile.gender,profile.weight,profile.height,profile.age)
physical_activity_percentage = get_physical_activity_percentage(profile.body_activity)
daily_energy_needs = get_daily_energy_needs(profile.special_condition,nutrition_status,basic_energy_needs,physical_activity_percentage)
protein = get_protein_needs(profile.special_condition,body_mass_index,daily_energy_needs)
fat = get_fat_needs(profile.special_condition,body_mass_index,daily_energy_needs)
carbohydrate = get_carbohydrate_needs(profile.special_condition,body_mass_index,daily_energy_needs)
fiber = get_fiber_needs(body_mass_index)
daily_nutrition_needs = {'protein_needs': protein, 'fat_needs': fat, 'carbohydrate_needs': carbohydrate, 'fiber_needs': fiber,}
total_vegetable_and_fruit_score = get_total_vegetable_and_fruit_score(profile.vegetables_in_one_day,profile.fruits_in_one_day)
vegetable_and_fruit_sufficiency = get_vegetable_and_fruit_sufficiency_response(total_vegetable_and_fruit_score)
vegetable_and_fruit_diet_recommendation = get_vegetable_and_fruit_diet_recommendation(vegetable_and_fruit_sufficiency)
total_sugar_salt_fat_score = get_total_sugar_salt_fat_score(profile.fried_food_in_one_day,profile.sweet_snacks_in_one_day,profile.sweet_drinks_in_one_day,profile.packaged_food_in_one_day)
basic_energy_needs = get_basic_energy_needs(profile.gender,
profile.weight,profile.height,profile.age)
physical_activity_percentage = get_physical_activity_percentage(
profile.body_activity)
daily_energy_needs = get_daily_energy_needs(profile.special_condition,
nutrition_status,basic_energy_needs,physical_activity_percentage)
protein = get_protein_needs(profile.special_condition,body_mass_index,
daily_energy_needs)
fat = get_fat_needs(profile.special_condition,body_mass_index,
daily_energy_needs)
carbohydrate = get_carbohydrate_needs(profile.special_condition,
body_mass_index,daily_energy_needs)
fiber = get_fiber_needs()
daily_nutrition_needs = {'protein_needs': protein, 'fat_needs': fat,
'carbohydrate_needs': carbohydrate, 'fiber_needs': fiber,}
total_vegetable_and_fruit_score = get_total_vegetable_and_fruit_score(
profile.vegetables_in_one_day,profile.fruits_in_one_day)
vegetable_and_fruit_sufficiency = get_vegetable_and_fruit_sufficiency_response(
total_vegetable_and_fruit_score)
vegetable_and_fruit_diet_recommendation = \
get_vegetable_and_fruit_diet_recommendation(vegetable_and_fruit_sufficiency)
total_sugar_salt_fat_score = get_total_sugar_salt_fat_score(
profile.fried_food_in_one_day,profile.sweet_snacks_in_one_day,
profile.sweet_drinks_in_one_day,profile.packaged_food_in_one_day)
sugar_salt_fat_problem = get_sugar_salt_fat_problem_response(total_sugar_salt_fat_score)
sugar_salt_fat_diet_recommendation = get_sugar_salt_fat_diet_recommendation(sugar_salt_fat_problem)
large_meal_diet_recommendation = get_large_meal_diet_recommendation(profile.large_meal_in_one_day)
snacks_diet_recommendation = get_snacks_diet_recommendation(profile.snacks_in_one_day)
sugar_salt_fat_problem = get_sugar_salt_fat_problem_response(
total_sugar_salt_fat_score)
sugar_salt_fat_diet_recommendation = \
get_sugar_salt_fat_diet_recommendation(sugar_salt_fat_problem)
large_meal_diet_recommendation = \
get_large_meal_diet_recommendation(profile.large_meal_in_one_day)
snacks_diet_recommendation = \
get_snacks_diet_recommendation(profile.snacks_in_one_day)
breakfast_recommendation = get_breakfast_recommendation(profile.breakfast_type)
energy_needed_per_dine = get_energy_needed_per_dine(profile.breakfast_type,daily_energy_needs)
physical_activity_recommendation = get_physical_activity_recommendation(profile.body_activity)
program_recommendation = get_program_recommendation(profile.current_condition,profile.problem_to_solve,profile.health_problem)
program_recommendation = get_program_recommendation(profile.current_condition,
profile.problem_to_solve,profile.health_problem)
quiz_result = QuizResult.objects.update_or_create(diet_profile=profile,age=age,weight=weight,height=height,gender=gender,
body_mass_index=body_mass_index,nutrition_status=nutrition_status,ideal_weight_range=ideal_weight_range,
daily_energy_needs=daily_energy_needs,daily_nutrition_needs=daily_nutrition_needs,
vegetable_and_fruit_sufficiency=vegetable_and_fruit_sufficiency,vegetable_and_fruit_diet_recommendation=vegetable_and_fruit_diet_recommendation,
sugar_salt_fat_problem=sugar_salt_fat_problem,sugar_salt_fat_diet_recommendation=sugar_salt_fat_diet_recommendation,
large_meal_diet_recommendation=large_meal_diet_recommendation,snacks_diet_recommendation=snacks_diet_recommendation,
breakfast_recommendation=breakfast_recommendation,energy_needed_per_dine=energy_needed_per_dine,physical_activity_recommendation=physical_activity_recommendation,
program_recommendation=program_recommendation)
quiz_result = QuizResult.objects.update_or_create(
diet_profile=profile,age=age,weight=weight,height=height,gender=gender,
body_mass_index=body_mass_index,nutrition_status=nutrition_status,
ideal_weight_range=ideal_weight_range,daily_energy_needs=daily_energy_needs,
daily_nutrition_needs=daily_nutrition_needs,
vegetable_and_fruit_sufficiency=vegetable_and_fruit_sufficiency,
vegetable_and_fruit_diet_recommendation=vegetable_and_fruit_diet_recommendation,
sugar_salt_fat_problem=sugar_salt_fat_problem,
sugar_salt_fat_diet_recommendation=sugar_salt_fat_diet_recommendation,
large_meal_diet_recommendation=large_meal_diet_recommendation,
snacks_diet_recommendation=snacks_diet_recommendation,
breakfast_recommendation=breakfast_recommendation,
energy_needed_per_dine=energy_needed_per_dine,
physical_activity_recommendation=physical_activity_recommendation,
program_recommendation=program_recommendation
)
return quiz_result[0]
from django.shortcuts import render
from rest_framework import viewsets, status
from rest_framework.response import Response
from .serializers import DietProfileSerializer, QuizResultSerializer
from .models import DietProfile, QuizResult
from .utilities import create_or_update_quiz_result
from rest_framework.response import Response
class DietProfileViewSet(viewsets.ModelViewSet):
......@@ -21,7 +20,7 @@ class DietProfileViewSet(viewsets.ModelViewSet):
response['quiz_result'] = QuizResultSerializer(quiz_result).data
return Response(response, status=status.HTTP_201_CREATED, headers=headers)
def perform_create(self, serializer):
instance = serializer.save()
create_or_update_quiz_result(instance)
......
#!/bin/bash
autopep8 -iraav dietela_program dietela_quiz nutritionists
pycodestyle --exclude="**/migrations/**" --show-source --show-pep8 --ignore=E501,W503,W504 dietela_program dietela_quiz nutritionists