Re-add diaper change amount and color fields

This commit is contained in:
Chris Wells 2024-04-15 13:29:30 +00:00 committed by Christopher Charbonneau Wells
parent eb88d6508a
commit 041a03df0d
2 changed files with 24 additions and 25 deletions

View File

@ -121,7 +121,7 @@ class CoreModelForm(forms.ModelForm):
for fieldset in self.fieldsets: for fieldset in self.fieldsets:
hyrdrated_fieldset = { hyrdrated_fieldset = {
"layout": fieldset["layout"], "layout": fieldset.get("layout", "default"),
"layout_attrs": fieldset.get("layout_attrs", {}), "layout_attrs": fieldset.get("layout_attrs", {}),
"fields": [], "fields": [],
} }
@ -179,8 +179,9 @@ class TaggableModelForm(forms.ModelForm):
class PumpingForm(CoreModelForm, TaggableModelForm): class PumpingForm(CoreModelForm, TaggableModelForm):
fieldsets = [ fieldsets = [
{"fields": ["child", "start", "end", "amount"], "layout": "required"}, {"fields": ["child", "start", "end"], "layout": "required"},
{"layout": "advanced", "fields": ["notes", "tags"]}, {"fields": ["amount"]},
{"fields": ["notes", "tags"], "layout": "advanced"},
] ]
class Meta: class Meta:
@ -196,12 +197,13 @@ class PumpingForm(CoreModelForm, TaggableModelForm):
class DiaperChangeForm(CoreModelForm, TaggableModelForm): class DiaperChangeForm(CoreModelForm, TaggableModelForm):
fieldsets = [ fieldsets = [
{"fields": ["child", "time"], "layout": "required"},
{ {
"fields": ["wet", "solid"], "fields": ["wet", "solid"],
"layout": "choices", "layout": "choices",
"layout_attrs": {"label": "Contents"}, "layout_attrs": {"label": "Contents"},
}, },
{"fields": ["child", "time"], "layout": "required"}, {"fields": ["color", "amount"]},
{"layout": "advanced", "fields": ["notes", "tags"]}, {"layout": "advanced", "fields": ["notes", "tags"]},
] ]
@ -217,11 +219,9 @@ class DiaperChangeForm(CoreModelForm, TaggableModelForm):
class FeedingForm(CoreModelForm, TaggableModelForm): class FeedingForm(CoreModelForm, TaggableModelForm):
fieldsets = [ fieldsets = [
{ {"fields": ["child", "start", "end", "type", "method"], "layout": "required"},
"fields": ["child", "start", "end", "type", "method", "amount"], {"fields": ["amount"]},
"layout": "required", {"fields": ["notes", "tags"], "layout": "advanced"},
},
{"layout": "advanced", "fields": ["notes", "tags"]},
] ]
class Meta: class Meta:
@ -239,11 +239,9 @@ class FeedingForm(CoreModelForm, TaggableModelForm):
class BottleFeedingForm(CoreModelForm, TaggableModelForm): class BottleFeedingForm(CoreModelForm, TaggableModelForm):
fieldsets = [ fieldsets = [
{ {"fields": ["child", "type", "start", "amount"], "layout": "required"},
"fields": ["child", "type", "start", "amount"], {"fields": ["amount"]},
"layout": "required", {"fields": ["notes", "tags"], "layout": "advanced"},
},
{"layout": "advanced", "fields": ["notes", "tags"]},
] ]
def save(self): def save(self):
@ -282,7 +280,7 @@ class SleepForm(CoreModelForm, TaggableModelForm):
"fields": ["child", "start", "end", "nap"], "fields": ["child", "start", "end", "nap"],
"layout": "required", "layout": "required",
}, },
{"layout": "advanced", "fields": ["notes", "tags"]}, {"fields": ["notes", "tags"], "layout": "advanced"},
] ]
class Meta: class Meta:
@ -302,7 +300,7 @@ class TemperatureForm(CoreModelForm, TaggableModelForm):
"fields": ["child", "temperature", "time"], "fields": ["child", "temperature", "time"],
"layout": "required", "layout": "required",
}, },
{"layout": "advanced", "fields": ["notes", "tags"]}, {"fields": ["notes", "tags"], "layout": "advanced"},
] ]
class Meta: class Meta:
@ -337,11 +335,9 @@ class TimerForm(CoreModelForm):
class TummyTimeForm(CoreModelForm, TaggableModelForm): class TummyTimeForm(CoreModelForm, TaggableModelForm):
fieldsets = [ fieldsets = [
{ {"fields": ["child", "start", "end"], "layout": "required"},
"fields": ["child", "start", "end", "milestone"], {"fields": ["milestone"]},
"layout": "required", {"fields": ["tags"], "layout": "advanced"},
},
{"layout": "advanced", "fields": ["tags"]},
] ]
class Meta: class Meta:
@ -360,7 +356,7 @@ class WeightForm(CoreModelForm, TaggableModelForm):
"fields": ["child", "weight", "date"], "fields": ["child", "weight", "date"],
"layout": "required", "layout": "required",
}, },
{"layout": "advanced", "fields": ["notes", "tags"]}, {"fields": ["notes", "tags"], "layout": "advanced"},
] ]
class Meta: class Meta:
@ -379,7 +375,7 @@ class HeightForm(CoreModelForm, TaggableModelForm):
"fields": ["child", "height", "date"], "fields": ["child", "height", "date"],
"layout": "required", "layout": "required",
}, },
{"layout": "advanced", "fields": ["notes", "tags"]}, {"fields": ["notes", "tags"], "layout": "advanced"},
] ]
class Meta: class Meta:
@ -398,7 +394,7 @@ class HeadCircumferenceForm(CoreModelForm, TaggableModelForm):
"fields": ["child", "head_circumference", "date"], "fields": ["child", "head_circumference", "date"],
"layout": "required", "layout": "required",
}, },
{"layout": "advanced", "fields": ["notes", "tags"]}, {"fields": ["notes", "tags"], "layout": "advanced"},
] ]
class Meta: class Meta:
@ -417,7 +413,7 @@ class BMIForm(CoreModelForm, TaggableModelForm):
"fields": ["child", "bmi", "date"], "fields": ["child", "bmi", "date"],
"layout": "required", "layout": "required",
}, },
{"layout": "advanced", "fields": ["notes", "tags"]}, {"fields": ["notes", "tags"], "layout": "advanced"},
] ]
class Meta: class Meta:

View File

@ -0,0 +1,3 @@
{% for field in fieldset.fields %}
<div class="row">{% include "babybuddy/form_field.html" %}</div>
{% endfor %}