Fakultas Ilmu Komputer UI

models.py 3.25 KB
Newer Older
Ami's avatar
Ami committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from django.db import models
from multiselectfield import MultiSelectField
from nutritionists.models import Nutritionist
from authentication.models import CustomUser
from constants.model_choices import(
    LargeMealInOneDay,
    SnacksInOneDay,
    ConsumptionInOneDay,
    Changes,
    Hunger,
    PhysicalActivity,
    TimeForActivity,
    Rating
)

class WeeklyReport(models.Model):
    nutritionist = models.ForeignKey(
        Nutritionist,
        on_delete=models.CASCADE,
        related_name='weekly_report'
    )
22
    client = models.ForeignKey(
Ami's avatar
Ami committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
        CustomUser,
        on_delete=models.CASCADE,
        related_name='weekly_report'
    )

    week_num = models.PositiveIntegerField()


    weight = models.PositiveIntegerField()
    height = models.PositiveIntegerField()
    waist_size = models.PositiveIntegerField()
    changes_felt = models.IntegerField(
        choices=Changes.choices)
    hunger_level = models.IntegerField(
        choices=Hunger.choices)
    fullness_level = models.IntegerField(
        choices=Hunger.choices)
    heavy_meal = models.IntegerField(
        choices=LargeMealInOneDay.choices)
    snacks = models.IntegerField(
        choices=SnacksInOneDay.choices)
44
    # This belongs to ONE field on gform
Ami's avatar
Ami committed
45
46
    sweet_beverages = models.IntegerField(
        choices=ConsumptionInOneDay.choices)
47
48
    sugary_ingredients = models.IntegerField(
        choices=ConsumptionInOneDay.choices)
Ami's avatar
Ami committed
49
50
51
52
53
54
55
56
57
58
59
60
    fried_snacks = models.IntegerField(
        choices=ConsumptionInOneDay.choices)
    umami_snacks = models.IntegerField(
        choices=ConsumptionInOneDay.choices)
    sweet_snacks = models.IntegerField(
        choices=ConsumptionInOneDay.choices)
    fruits_portion = models.IntegerField(
        choices=ConsumptionInOneDay.choices)
    vegetables_portion = models.IntegerField(
        choices=ConsumptionInOneDay.choices)
    #########################################

61
    water_consumption = models.PositiveIntegerField()
Ami's avatar
Ami committed
62
63
64
65
66
67
68
69
70
    physical_activity = MultiSelectField(
        choices = PhysicalActivity.choices)
    physical_activity_other = models.TextField()
    time_for_activity = models.IntegerField(
        choices=TimeForActivity.choices)
    feeling_rating = models.IntegerField(
        choices = Rating.choices)
    lesson_learned = models.TextField()
    problem_faced_and_feedbacks = models.TextField()
71

72
73
    def __str__(self):
        return f"{self.client} - {self.nutritionist} - Week {self.week_num}"
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

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"