Skip to content

Commit

Permalink
Merge ad4c90b into 89ed408
Browse files Browse the repository at this point in the history
  • Loading branch information
daegalus committed Dec 31, 2021
2 parents 89ed408 + ad4c90b commit c052abe
Show file tree
Hide file tree
Showing 74 changed files with 3,058 additions and 113 deletions.
18 changes: 18 additions & 0 deletions api/serializers.py
Expand Up @@ -173,3 +173,21 @@ class WeightSerializer(CoreModelSerializer):
class Meta:
model = models.Weight
fields = ('id', 'child', 'weight', 'date', 'notes')


class HeightSerializer(CoreModelSerializer):
class Meta:
model = models.Height
fields = ('id', 'child', 'height', 'date', 'notes')


class HeadCircumferenceSerializer(CoreModelSerializer):
class Meta:
model = models.HeadCircumference
fields = ('id', 'child', 'head_circumference', 'date', 'notes')


class BMISerializer(CoreModelSerializer):
class Meta:
model = models.BMI
fields = ('id', 'child', 'bmi', 'date', 'notes')
3 changes: 3 additions & 0 deletions api/urls.py
Expand Up @@ -15,6 +15,9 @@
router.register(r'timers', views.TimerViewSet)
router.register(r'tummy-times', views.TummyTimeViewSet)
router.register(r'weight', views.WeightViewSet)
router.register(r'height', views.HeightViewSet)
router.register(r'head-circumference', views.HeadCircumferenceViewSet)
router.register(r'bmi', views.BMIViewSet)

app_name = 'api'

Expand Down
18 changes: 18 additions & 0 deletions api/views.py
Expand Up @@ -60,3 +60,21 @@ class WeightViewSet(viewsets.ModelViewSet):
queryset = models.Weight.objects.all()
serializer_class = serializers.WeightSerializer
filterset_fields = ('child', 'date')


class HeightViewSet(viewsets.ModelViewSet):
queryset = models.Height.objects.all()
serializer_class = serializers.HeightSerializer
filterset_fields = ('child', 'date')


class HeadCircumferenceViewSet(viewsets.ModelViewSet):
queryset = models.HeadCircumference.objects.all()
serializer_class = serializers.HeadCircumferenceSerializer
filterset_fields = ('child', 'date')


class BMIViewSet(viewsets.ModelViewSet):
queryset = models.BMI.objects.all()
serializer_class = serializers.BMISerializer
filterset_fields = ('child', 'date')
63 changes: 63 additions & 0 deletions babybuddy/fixtures/tests.json
Expand Up @@ -399,5 +399,68 @@
"date": "2017-11-18",
"notes": "before feed"
}
},
{
"model": "core.height",
"pk": 1,
"fields":
{
"child": 1,
"height": 9.5,
"date": "2017-11-11"
}
},
{
"model": "core.height",
"pk": 2,
"fields":
{
"child": 1,
"height": 10.5,
"date": "2017-11-18",
"notes": "before feed"
}
},
{
"model": "core.headcircumference",
"pk": 1,
"fields":
{
"child": 1,
"head_circumference": 5.5,
"date": "2017-11-11"
}
},
{
"model": "core.headcircumference",
"pk": 2,
"fields":
{
"child": 1,
"head_circumference": 6.5,
"date": "2017-11-18",
"notes": "before feed"
}
},
{
"model": "core.bmi",
"pk": 1,
"fields":
{
"child": 1,
"bmi": 25.5,
"date": "2017-11-11"
}
},
{
"model": "core.bmi",
"pk": 2,
"fields":
{
"child": 1,
"bmi": 26.5,
"date": "2017-11-18",
"notes": "before feed"
}
}
]
78 changes: 78 additions & 0 deletions babybuddy/management/commands/fake.py
Expand Up @@ -74,6 +74,18 @@ def _add_child_data(self):
self._add_weight_entry()
last_weight_entry_time = self.time

self.height = round(uniform(8.0, 12.0), 2)
self._add_height_entry()
last_height_entry_time = self.time

self.head_circumference = round(uniform(8.0, 12.0), 2)
self._add_head_circumference_entry()
last_head_circumference_entry_time = self.time

self.bmi = round(uniform(8.0, 12.0), 2)
self._add_bmi_entry()
last_bmi_entry_time = self.time

self._add_note_entry()
while self.time < self.time_now:
self._add_sleep_entry()
Expand All @@ -91,6 +103,15 @@ def _add_child_data(self):
if (self.time - last_weight_entry_time).days > 6:
self._add_weight_entry()
last_weight_entry_time = self.time
if (self.time - last_height_entry_time).days > 6:
self._add_height_entry()
last_height_entry_time = self.time
if (self.time - last_head_circumference_entry_time).days > 6:
self._add_head_circumference_entry()
last_head_circumference_entry_time = self.time
if (self.time - last_bmi_entry_time).days > 6:
self._add_bmi_entry()
last_bmi_entry_time = self.time

@transaction.atomic
def _add_diaperchange_entry(self):
Expand Down Expand Up @@ -249,3 +270,60 @@ def _add_weight_entry(self):
date=self.time.date(),
notes=notes
).save()

@transaction.atomic
def _add_height_entry(self):
"""
Add a height entry. This assumes a weekly interval.
:returns:
"""
self.height += uniform(0.1, 0.3)

notes = ''
if choice([True, False, False, False]):
notes = ' '.join(self.faker.sentences(randint(1, 5)))

models.Height.objects.create(
child=self.child,
height=round(self.height, 2),
date=self.time.date(),
notes=notes
).save()

@transaction.atomic
def _add_head_circumference_entry(self):
"""
Add a head circumference entry. This assumes a weekly interval.
:returns:
"""
self.head_circumference += uniform(0.1, 0.3)

notes = ''
if choice([True, False, False, False]):
notes = ' '.join(self.faker.sentences(randint(1, 5)))

models.HeadCircumference.objects.create(
child=self.child,
head_circumference=round(self.head_circumference, 2),
date=self.time.date(),
notes=notes
).save()

@transaction.atomic
def _add_bmi_entry(self):
"""
Add a BMI entry. This assumes a weekly interval.
:returns:
"""
self.bmi += uniform(0.1, 0.3)

notes = ''
if choice([True, False, False, False]):
notes = ' '.join(self.faker.sentences(randint(1, 5)))

models.BMI.objects.create(
child=self.child,
bmi=round(self.bmi, 2),
date=self.time.date(),
notes=notes
).save()
24 changes: 24 additions & 0 deletions babybuddy/static_src/fontello/config.json
Expand Up @@ -221,6 +221,30 @@
"css": "cancel",
"code": 59411,
"src": "fontawesome"
},
{
"uid": "6a96c51e961a2e48dfcbe2c47fd1204e",
"css": "height",
"code": 61508,
"src": "mfglabs"
},
{
"uid": "bb46b15cb78cc4cc05d3d715d522ac4d",
"css": "head-circumference",
"code": 59412,
"src": "entypo"
},
{
"uid": "2c452255d4fed51ef0a6ef86436a7d08",
"css": "bmi",
"code": 62101,
"src": "fontawesome"
},
{
"uid": "b95cfc96d48a72dd665e0ab109880b5e",
"css": "measurements",
"code": 59413,
"src": "entypo"
}
]
}
4 changes: 4 additions & 0 deletions babybuddy/static_src/fontello/css/babybuddy-codes.css
Expand Up @@ -19,6 +19,9 @@
.icon-arrow-up:before { content: '\e811'; } /* '' */
.icon-arrow-down:before { content: '\e812'; } /* '' */
.icon-cancel:before { content: '\e813'; } /* '' */
.icon-head-circumference:before { content: '\e814'; } /* '' */
.icon-measurements:before { content: '\e815'; } /* '' */
.icon-height:before { content: '\f044'; } /* '' */
.icon-dashboard:before { content: '\f0e4'; } /* '' */
.icon-tummytime:before { content: '\f118'; } /* '' */
.icon-sad:before { content: '\f119'; } /* '' */
Expand All @@ -34,4 +37,5 @@
.icon-note:before { content: '\f249'; } /* '' */
.icon-weight:before { content: '\f24e'; } /* '' */
.icon-today:before { content: '\f274'; } /* '' */
.icon-bmi:before { content: '\f295'; } /* '' */
.icon-temperature:before { content: '\f2c8'; } /* '' */

0 comments on commit c052abe

Please sign in to comment.