diff --git a/core/forms.py b/core/forms.py index 3aca09c4..024b9abd 100644 --- a/core/forms.py +++ b/core/forms.py @@ -90,7 +90,7 @@ class ChildDeleteForm(forms.ModelForm): class DiaperChangeForm(forms.ModelForm): class Meta: model = models.DiaperChange - fields = ['child', 'time', 'wet', 'solid', 'color'] + fields = ['child', 'time', 'wet', 'solid', 'color', 'amount'] widgets = { 'time': forms.DateTimeInput(attrs={ 'class': 'datetimepicker-input', diff --git a/core/migrations/0009_diaperchange_amount.py b/core/migrations/0009_diaperchange_amount.py new file mode 100644 index 00000000..991260de --- /dev/null +++ b/core/migrations/0009_diaperchange_amount.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.2 on 2020-01-26 21:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0008_auto_20190607_1422'), + ] + + operations = [ + migrations.AddField( + model_name='diaperchange', + name='amount', + field=models.FloatField(blank=True, null=True, verbose_name='Amount'), + ), + ] diff --git a/core/models.py b/core/models.py index f58247e8..debc2354 100644 --- a/core/models.py +++ b/core/models.py @@ -139,6 +139,7 @@ class DiaperChange(models.Model): max_length=255, verbose_name=_('Color') ) + amount = models.FloatField(blank=True, null=True, verbose_name=_('Amount')) objects = models.Manager() diff --git a/core/templates/core/diaperchange_list.html b/core/templates/core/diaperchange_list.html index d8cd1e7a..dfb8ffa9 100644 --- a/core/templates/core/diaperchange_list.html +++ b/core/templates/core/diaperchange_list.html @@ -18,6 +18,7 @@ {% trans "Wet" %} {% trans "Solid" %} {% trans "Color" %} + {% trans "Amount" %} {% trans "Time" %} {% trans "Actions" %} @@ -29,6 +30,7 @@ {{ change.wet|bool_icon }} {{ change.solid|bool_icon }} {{ change.get_color_display }} + {{ change.amount|default_if_none:"" }} {{ change.time }}
diff --git a/core/tests/tests_forms.py b/core/tests/tests_forms.py index b5db0923..bb58414f 100644 --- a/core/tests/tests_forms.py +++ b/core/tests/tests_forms.py @@ -58,7 +58,8 @@ class FormsTestCase(TestCase): 'time': '2000-01-01 1:01', 'wet': 1, 'solid': 1, - 'color': 'black' + 'color': 'black', + 'amount': 0.45 } entry = models.DiaperChange.objects.first() diff --git a/core/tests/tests_models.py b/core/tests/tests_models.py index c727efcc..72f1c521 100644 --- a/core/tests/tests_models.py +++ b/core/tests/tests_models.py @@ -37,12 +37,18 @@ class DiaperChangeTestCase(TestCase): time=timezone.localtime() - timezone.timedelta(days=1), wet=1, solid=1, - color='black' + color='black', + amount=1.25 ) def test_diaperchange_create(self): self.assertEqual(self.change, models.DiaperChange.objects.first()) self.assertEqual(str(self.change), 'Diaper Change') + self.assertEqual(self.change.child, self.child) + self.assertTrue(self.change.wet) + self.assertTrue(self.change.solid) + self.assertEqual(self.change.color, 'black') + self.assertEqual(self.change.amount, 1.25) def test_diaperchange_attributes(self): self.assertListEqual(