mirror of https://github.com/snachodog/mybuddy.git
✨ applies new child selection widget to all forms
filters out blank option for timer form as it does not really make sense to allow user to select no child
This commit is contained in:
parent
e86d7cc6f6
commit
ac664cb511
|
@ -143,6 +143,7 @@ class PumpingForm(CoreModelForm):
|
|||
model = models.Pumping
|
||||
fields = ["child", "amount", "time", "notes"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"time": forms.DateTimeInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -156,8 +157,10 @@ class PumpingForm(CoreModelForm):
|
|||
class DiaperChangeForm(CoreModelForm, TaggableModelForm):
|
||||
class Meta:
|
||||
model = models.DiaperChange
|
||||
fields = ["child", "time", "wet", "solid", "color", "amount", "notes", "tags"]
|
||||
fields = ["child", "time", "wet", "solid", "color", "amount", "notes",
|
||||
"tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect(),
|
||||
"time": forms.DateTimeInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -171,7 +174,8 @@ class DiaperChangeForm(CoreModelForm, TaggableModelForm):
|
|||
class FeedingForm(CoreModelForm, TaggableModelForm):
|
||||
class Meta:
|
||||
model = models.Feeding
|
||||
fields = ["child", "start", "end", "type", "method", "amount", "notes", "tags"]
|
||||
fields = ["child", "start", "end", "type", "method", "amount", "notes",
|
||||
"tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"start": forms.DateTimeInput(
|
||||
|
@ -195,6 +199,7 @@ class NoteForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.Note
|
||||
fields = ["child", "note", "time", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"time": forms.DateTimeInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -209,6 +214,7 @@ class SleepForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.Sleep
|
||||
fields = ["child", "start", "end", "notes", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"start": forms.DateTimeInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -230,6 +236,7 @@ class TemperatureForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.Temperature
|
||||
fields = ["child", "temperature", "time", "notes", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"time": forms.DateTimeInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -241,10 +248,12 @@ class TemperatureForm(CoreModelForm, TaggableModelForm):
|
|||
|
||||
|
||||
class TimerForm(CoreModelForm):
|
||||
|
||||
class Meta:
|
||||
model = models.Timer
|
||||
fields = ["child", "name", "start"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"start": forms.DateTimeInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -269,6 +278,7 @@ class TummyTimeForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.TummyTime
|
||||
fields = ["child", "start", "end", "milestone", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"start": forms.DateTimeInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -289,6 +299,7 @@ class WeightForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.Weight
|
||||
fields = ["child", "weight", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -304,6 +315,7 @@ class HeightForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.Height
|
||||
fields = ["child", "height", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -319,6 +331,7 @@ class HeadCircumferenceForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.HeadCircumference
|
||||
fields = ["child", "head_circumference", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
@ -334,6 +347,7 @@ class BMIForm(CoreModelForm, TaggableModelForm):
|
|||
model = models.BMI
|
||||
fields = ["child", "bmi", "date", "notes", "tags"]
|
||||
widgets = {
|
||||
"child": ChildRadioSelect,
|
||||
"date": forms.DateInput(
|
||||
attrs={
|
||||
"autocomplete": "off",
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
<div{% if id %} id="{{ id }}"{% endif %} class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||
{% for group, options, index in widget.optgroups %}
|
||||
{% for option in options %}
|
||||
{% if option.value != '' %}
|
||||
{% include option.template_name with widget=option %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>{% endwith %}
|
||||
|
|
|
@ -90,5 +90,6 @@ class ChildRadioSelect(RadioSelect):
|
|||
|
||||
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
|
||||
option = super().create_option(name, value, label, selected, index, subindex, attrs)
|
||||
if value != '':
|
||||
option['picture'] = value.instance.picture
|
||||
return option
|
||||
|
|
Loading…
Reference in New Issue