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
|
model = models.Pumping
|
||||||
fields = ["child", "amount", "time", "notes"]
|
fields = ["child", "amount", "time", "notes"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"time": forms.DateTimeInput(
|
"time": forms.DateTimeInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -156,8 +157,10 @@ class PumpingForm(CoreModelForm):
|
||||||
class DiaperChangeForm(CoreModelForm, TaggableModelForm):
|
class DiaperChangeForm(CoreModelForm, TaggableModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.DiaperChange
|
model = models.DiaperChange
|
||||||
fields = ["child", "time", "wet", "solid", "color", "amount", "notes", "tags"]
|
fields = ["child", "time", "wet", "solid", "color", "amount", "notes",
|
||||||
|
"tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect(),
|
||||||
"time": forms.DateTimeInput(
|
"time": forms.DateTimeInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -171,7 +174,8 @@ class DiaperChangeForm(CoreModelForm, TaggableModelForm):
|
||||||
class FeedingForm(CoreModelForm, TaggableModelForm):
|
class FeedingForm(CoreModelForm, TaggableModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Feeding
|
model = models.Feeding
|
||||||
fields = ["child", "start", "end", "type", "method", "amount", "notes", "tags"]
|
fields = ["child", "start", "end", "type", "method", "amount", "notes",
|
||||||
|
"tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
"child": ChildRadioSelect,
|
"child": ChildRadioSelect,
|
||||||
"start": forms.DateTimeInput(
|
"start": forms.DateTimeInput(
|
||||||
|
@ -195,6 +199,7 @@ class NoteForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.Note
|
model = models.Note
|
||||||
fields = ["child", "note", "time", "tags"]
|
fields = ["child", "note", "time", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"time": forms.DateTimeInput(
|
"time": forms.DateTimeInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -209,6 +214,7 @@ class SleepForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.Sleep
|
model = models.Sleep
|
||||||
fields = ["child", "start", "end", "notes", "tags"]
|
fields = ["child", "start", "end", "notes", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"start": forms.DateTimeInput(
|
"start": forms.DateTimeInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -230,6 +236,7 @@ class TemperatureForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.Temperature
|
model = models.Temperature
|
||||||
fields = ["child", "temperature", "time", "notes", "tags"]
|
fields = ["child", "temperature", "time", "notes", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"time": forms.DateTimeInput(
|
"time": forms.DateTimeInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -241,10 +248,12 @@ class TemperatureForm(CoreModelForm, TaggableModelForm):
|
||||||
|
|
||||||
|
|
||||||
class TimerForm(CoreModelForm):
|
class TimerForm(CoreModelForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Timer
|
model = models.Timer
|
||||||
fields = ["child", "name", "start"]
|
fields = ["child", "name", "start"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"start": forms.DateTimeInput(
|
"start": forms.DateTimeInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -269,6 +278,7 @@ class TummyTimeForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.TummyTime
|
model = models.TummyTime
|
||||||
fields = ["child", "start", "end", "milestone", "tags"]
|
fields = ["child", "start", "end", "milestone", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"start": forms.DateTimeInput(
|
"start": forms.DateTimeInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -289,6 +299,7 @@ class WeightForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.Weight
|
model = models.Weight
|
||||||
fields = ["child", "weight", "date", "notes", "tags"]
|
fields = ["child", "weight", "date", "notes", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"date": forms.DateInput(
|
"date": forms.DateInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -304,6 +315,7 @@ class HeightForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.Height
|
model = models.Height
|
||||||
fields = ["child", "height", "date", "notes", "tags"]
|
fields = ["child", "height", "date", "notes", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"date": forms.DateInput(
|
"date": forms.DateInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -319,6 +331,7 @@ class HeadCircumferenceForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.HeadCircumference
|
model = models.HeadCircumference
|
||||||
fields = ["child", "head_circumference", "date", "notes", "tags"]
|
fields = ["child", "head_circumference", "date", "notes", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"date": forms.DateInput(
|
"date": forms.DateInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
@ -334,6 +347,7 @@ class BMIForm(CoreModelForm, TaggableModelForm):
|
||||||
model = models.BMI
|
model = models.BMI
|
||||||
fields = ["child", "bmi", "date", "notes", "tags"]
|
fields = ["child", "bmi", "date", "notes", "tags"]
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
"date": forms.DateInput(
|
"date": forms.DateInput(
|
||||||
attrs={
|
attrs={
|
||||||
"autocomplete": "off",
|
"autocomplete": "off",
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
<div{% if id %} id="{{ id }}"{% endif %} class="btn-group btn-group-toggle" data-toggle="buttons">
|
<div{% if id %} id="{{ id }}"{% endif %} class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||||
{% for group, options, index in widget.optgroups %}
|
{% for group, options, index in widget.optgroups %}
|
||||||
{% for option in options %}
|
{% for option in options %}
|
||||||
|
{% if option.value != '' %}
|
||||||
{% include option.template_name with widget=option %}
|
{% include option.template_name with widget=option %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>{% endwith %}
|
</div>{% endwith %}
|
||||||
|
|
|
@ -90,5 +90,6 @@ class ChildRadioSelect(RadioSelect):
|
||||||
|
|
||||||
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
|
def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
|
||||||
option = super().create_option(name, value, label, selected, index, subindex, attrs)
|
option = super().create_option(name, value, label, selected, index, subindex, attrs)
|
||||||
option['picture'] = value.instance.picture
|
if value != '':
|
||||||
|
option['picture'] = value.instance.picture
|
||||||
return option
|
return option
|
||||||
|
|
Loading…
Reference in New Issue