mirror of https://github.com/snachodog/mybuddy.git
Add an amount field to the Feeding model.
This commit is contained in:
parent
0c03e93a72
commit
79472dcdbe
|
@ -21,7 +21,8 @@ class DiaperChangeSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class FeedingSerializer(serializers.HyperlinkedModelSerializer):
|
class FeedingSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Feeding
|
model = Feeding
|
||||||
fields = ('baby', 'start', 'end', 'duration', 'type', 'method')
|
fields = ('baby', 'start', 'end', 'duration', 'type', 'method',
|
||||||
|
'amount')
|
||||||
|
|
||||||
|
|
||||||
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
|
@ -33,7 +33,7 @@ class FeedingViewSet(viewsets.ModelViewSet):
|
||||||
serializer_class = FeedingSerializer
|
serializer_class = FeedingSerializer
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
params = ['baby__last_name', 'type', 'method']
|
params = ['baby__last_name', 'type', 'method', 'amount']
|
||||||
return filter_by_params(self.request, Feeding, params)
|
return filter_by_params(self.request, Feeding, params)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,11 @@ class DiaperChangeAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
@admin.register(Feeding)
|
@admin.register(Feeding)
|
||||||
class FeedingAdmin(admin.ModelAdmin):
|
class FeedingAdmin(admin.ModelAdmin):
|
||||||
list_display = ('start', 'end', 'duration', 'child', 'type', 'method',)
|
list_display = ('start', 'end', 'duration', 'child', 'type', 'method',
|
||||||
|
'amount')
|
||||||
list_filter = ('child', 'type', 'method',)
|
list_filter = ('child', 'type', 'method',)
|
||||||
search_fields = ('child__first_name', 'child__last_name', 'type', 'method',)
|
search_fields = ('child__first_name', 'child__last_name', 'type',
|
||||||
|
'method',)
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Note)
|
@admin.register(Note)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class DiaperChangeForm(forms.ModelForm):
|
||||||
class FeedingForm(forms.ModelForm):
|
class FeedingForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Feeding
|
model = Feeding
|
||||||
fields = ['child', 'start', 'end', 'type', 'method']
|
fields = ['child', 'start', 'end', 'type', 'method', 'amount']
|
||||||
widgets = {
|
widgets = {
|
||||||
'start': forms.DateTimeInput(attrs={
|
'start': forms.DateTimeInput(attrs={
|
||||||
'class': 'datepicker-input',
|
'class': 'datepicker-input',
|
||||||
|
|
|
@ -57,6 +57,7 @@ class Feeding(models.Model):
|
||||||
('left breast', 'Left breast'),
|
('left breast', 'Left breast'),
|
||||||
('right breast', 'Right breast'),
|
('right breast', 'Right breast'),
|
||||||
])
|
])
|
||||||
|
amount = models.FloatField(blank=True, null=True)
|
||||||
|
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th>Child</th>
|
<th>Child</th>
|
||||||
<th>Start</th>
|
<th>Date</th>
|
||||||
<th>End</th>
|
|
||||||
<th>Duration</th>
|
<th>Duration</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>Method</th>
|
<th>Method</th>
|
||||||
|
<th>Amount (oz)</th>
|
||||||
<th class="text-center">Actions</th>
|
<th class="text-center">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -25,10 +25,10 @@
|
||||||
<th scope="row">{{ feeding.id }}</th>
|
<th scope="row">{{ feeding.id }}</th>
|
||||||
<td>{{ feeding.child }}</td>
|
<td>{{ feeding.child }}</td>
|
||||||
<td>{{ feeding.start }}</td>
|
<td>{{ feeding.start }}</td>
|
||||||
<td>{{ feeding.end }}</td>
|
|
||||||
<td>{{ feeding.duration }}</td>
|
<td>{{ feeding.duration }}</td>
|
||||||
<td>{{ feeding.type }}</td>
|
<td>{{ feeding.type }}</td>
|
||||||
<td>{{ feeding.method }}</td>
|
<td>{{ feeding.method }}</td>
|
||||||
|
<td>{{ feeding.amount }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
|
<div class="btn-group btn-group-sm" role="group" aria-label="Actions">
|
||||||
<a href="{% url 'feeding-update' feeding.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
|
<a href="{% url 'feeding-update' feeding.id %}" class="btn btn-primary"><i class="fa fa-pencil" aria-hidden="true"></i></a>
|
||||||
|
|
Loading…
Reference in New Issue