mirror of https://github.com/snachodog/mybuddy.git
Respect child if set when setting feeding defaults
This commit is contained in:
parent
b31d9194d9
commit
5e9946ecd6
|
@ -42,12 +42,15 @@ def set_defaults_from_timer(kwargs):
|
||||||
# Sets the default Feeding type to the one used in the most recent entry.
|
# Sets the default Feeding type to the one used in the most recent entry.
|
||||||
def set_default_feeding_type(kwargs):
|
def set_default_feeding_type(kwargs):
|
||||||
instance = kwargs.get('instance', None)
|
instance = kwargs.get('instance', None)
|
||||||
|
initial = kwargs.get('initial', None)
|
||||||
if not kwargs.get('initial'):
|
if not kwargs.get('initial'):
|
||||||
kwargs.update(initial={})
|
kwargs.update(initial={})
|
||||||
if instance is None and models.Feeding.objects.count() > 0:
|
if instance is None and initial and 'child' in initial:
|
||||||
kwargs['initial'].update({
|
if models.Feeding.objects.filter(child=initial['child']).count() > 0:
|
||||||
'type': models.Feeding.objects.latest('end').type
|
kwargs['initial'].update({
|
||||||
})
|
'type': models.Feeding.objects.filter(
|
||||||
|
child=initial['child']).latest('end').type
|
||||||
|
})
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue