mirror of https://github.com/snachodog/mybuddy.git
Add generic "Amount" field to Diaper Change model (#77)
This commit is contained in:
parent
6bf63f89b1
commit
a8abfb725f
|
@ -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',
|
||||
|
|
|
@ -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'),
|
||||
),
|
||||
]
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<th class="text-center">{% trans "Wet" %}</th>
|
||||
<th class="text-center">{% trans "Solid" %}</th>
|
||||
<th>{% trans "Color" %}</th>
|
||||
<th>{% trans "Amount" %}</th>
|
||||
<th>{% trans "Time" %}</th>
|
||||
<th class="text-center">{% trans "Actions" %}</th>
|
||||
</tr>
|
||||
|
@ -29,6 +30,7 @@
|
|||
<td class="text-center">{{ change.wet|bool_icon }}</td>
|
||||
<td class="text-center">{{ change.solid|bool_icon }}</td>
|
||||
<td>{{ change.get_color_display }}</td>
|
||||
<td>{{ change.amount|default_if_none:"" }}</td>
|
||||
<td>{{ change.time }}</td>
|
||||
<td class="text-center">
|
||||
<div class="btn-group btn-group-sm" role="group" aria-label="{% trans "Actions" %}">
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue