default last feed method if not left/right breast

This commit is contained in:
jcgoette 2021-05-31 19:58:37 -04:00 committed by Christopher Charbonneau Wells
parent e8696a8b00
commit 0001281d66
1 changed files with 3 additions and 3 deletions

View File

@ -48,10 +48,10 @@ def set_initial_values(kwargs, form_type):
last_feeding = models.Feeding.objects.filter( last_feeding = models.Feeding.objects.filter(
child=kwargs['initial']['child']).order_by('end').last() child=kwargs['initial']['child']).order_by('end').last()
if last_feeding: if last_feeding:
last_type = last_feeding.type last_method = last_feeding.method
last_feed_args = {'type': last_feeding.type} last_feed_args = {'type': last_feeding.type}
if last_type in ['formula', 'fortified breast milk']: if last_method not in ['left breast', 'right breast']:
last_feed_args['method'] = 'bottle' last_feed_args['method'] = last_method
kwargs['initial'].update(last_feed_args) kwargs['initial'].update(last_feed_args)
# Remove custom kwargs so they do not interfere with `super` calls. # Remove custom kwargs so they do not interfere with `super` calls.