Fakultas Ilmu Komputer UI

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

[GREEN] Implemented nutritionist comment in weekly report

parent 3a6a68b0
Pipeline #79830 passed with stages
in 14 minutes and 31 seconds
from django.contrib import admin
from .models import WeeklyReport
from .models import WeeklyReport, WeeklyReportComment
admin.site.register(WeeklyReport)
admin.site.register(WeeklyReportComment)
# Generated by Django 3.1 on 2021-05-30 14:01
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('diet_progress', '0004_auto_20210530_0818'),
]
operations = [
migrations.CreateModel(
name='WeeklyReportComment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('weight', models.TextField()),
('height', models.TextField()),
('waist_size', models.TextField()),
('changes_felt', models.TextField()),
('hunger_level', models.TextField()),
('fullness_level', models.TextField()),
('heavy_meal', models.TextField()),
('snacks', models.TextField()),
('average_consumption', models.TextField()),
('water_consumption', models.TextField()),
('physical_activity', models.TextField()),
('time_for_activity', models.TextField()),
('feeling_rating', models.TextField()),
('lesson_learned', models.TextField()),
('problem_faced_and_feedbacks', models.TextField()),
('weekly_report', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='weekly_report_comment', to='diet_progress.weeklyreport')),
],
),
]
......@@ -67,3 +67,30 @@ class WeeklyReport(models.Model):
choices = Rating.choices)
lesson_learned = models.TextField()
problem_faced_and_feedbacks = models.TextField()
class WeeklyReportComment(models.Model):
weekly_report = models.OneToOneField(
WeeklyReport,
on_delete=models.CASCADE,
related_name='weekly_report_comment'
)
weight = models.TextField()
height = models.TextField()
waist_size = models.TextField()
changes_felt = models.TextField()
hunger_level = models.TextField()
fullness_level = models.TextField()
heavy_meal = models.TextField()
snacks = models.TextField()
average_consumption = models.TextField()
water_consumption = models.TextField()
physical_activity = models.TextField()
time_for_activity = models.TextField()
feeling_rating = models.TextField()
lesson_learned = models.TextField()
problem_faced_and_feedbacks = models.TextField()
def __str__(self):
return f"Weekly Report {self.weekly_report.id} Comment"
from rest_framework import serializers, fields
from constants.model_choices import PhysicalActivity
from .models import WeeklyReport
from .models import WeeklyReport, WeeklyReportComment
class WeeklyReportSerializer(serializers.ModelSerializer):
......@@ -10,3 +10,9 @@ class WeeklyReportSerializer(serializers.ModelSerializer):
class Meta:
model = WeeklyReport
fields = "__all__"
class WeeklyReportCommentSerializer(serializers.ModelSerializer):
class Meta:
model = WeeklyReportComment
fields = "__all__"
from rest_framework import routers
from .views import WeeklyReportViewSet
from .views import WeeklyReportViewSet, WeeklyReportCommentViewSet
router = routers.SimpleRouter()
router.register('progress/user_report', WeeklyReportViewSet)
router.register('progress/nutritionist_comment', WeeklyReportCommentViewSet)
urlpatterns = []
......
from rest_framework import viewsets, status
from rest_framework.response import Response
from authentication.utilities import get_appropriate_week_num
from .models import WeeklyReport
from .serializers import WeeklyReportSerializer
from .models import WeeklyReport, WeeklyReportComment
from .serializers import WeeklyReportSerializer, WeeklyReportCommentSerializer
class WeeklyReportViewSet(viewsets.ModelViewSet):
serializer_class = WeeklyReportSerializer
......@@ -23,3 +23,8 @@ class WeeklyReportViewSet(viewsets.ModelViewSet):
response = serializer.data
return Response(response, status=status.HTTP_201_CREATED, headers=headers)
class WeeklyReportCommentViewSet(viewsets.ModelViewSet):
serializer_class = WeeklyReportCommentSerializer
queryset = WeeklyReportComment.objects.all()
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