mirror of https://github.com/snachodog/mybuddy.git
feat: create a trimmed form just for bottle feeding.
While Feeding for is great, i think there is room to create optimised forms for breast feeding and bottle feeding. This is the first one a trimmed down form for bottle feeding specifically
This commit is contained in:
parent
4ff6f7dd9b
commit
3c54636790
|
@ -264,7 +264,12 @@
|
||||||
{% trans "Feeding" %}
|
{% trans "Feeding" %}
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if perms.core.add_feeding %}
|
||||||
|
<a class="dropdown-item ps-5{% if request.path == '/feedings/bottle/add/' %} active{% endif %}"
|
||||||
|
href="{% url 'core:bottle-feeding-add' %}"><i class="icon-add" aria-hidden="true"></i>
|
||||||
|
{% trans "Bottle Feeding" %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
{% if perms.core.view_pumping %}
|
{% if perms.core.view_pumping %}
|
||||||
<a class="dropdown-item{% if request.path == '/pumping/' %} active{% endif %}"
|
<a class="dropdown-item{% if request.path == '/pumping/' %} active{% endif %}"
|
||||||
href="{% url 'core:pumping-list' %}">
|
href="{% url 'core:pumping-list' %}">
|
||||||
|
|
|
@ -187,6 +187,24 @@ class FeedingForm(CoreModelForm, TaggableModelForm):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class BottleFeedingForm(CoreModelForm, TaggableModelForm):
|
||||||
|
def save(self):
|
||||||
|
instance = super(BottleFeedingForm, self).save(commit=False)
|
||||||
|
instance.method = "bottle"
|
||||||
|
instance.end = instance.start
|
||||||
|
instance.save()
|
||||||
|
return instance
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.Feeding
|
||||||
|
fields = ["child", "start", "type", "amount", "notes", "tags"]
|
||||||
|
widgets = {
|
||||||
|
"child": ChildRadioSelect,
|
||||||
|
"start": DateTimeInput(),
|
||||||
|
"notes": forms.Textarea(attrs={"rows": 5}),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class NoteForm(CoreModelForm, TaggableModelForm):
|
class NoteForm(CoreModelForm, TaggableModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Note
|
model = models.Note
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% if request.resolver_match.url_name == 'feeding-update' %}
|
{% if request.resolver_match.url_name == 'feeding-update' %}
|
||||||
{% trans "Update a Feeding" %}
|
{% trans "Update a Feeding" %}
|
||||||
|
{% elif request.resolver_match.url_name == 'bottle-feeding-add' %}
|
||||||
|
{% trans "Add a Bottle Feeding" %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% trans "Add a Feeding" %}
|
{% trans "Add a Feeding" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -23,6 +25,8 @@
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
<h1>Update <span class="text-info">{{ object }}</span></h1>
|
<h1>Update <span class="text-info">{{ object }}</span></h1>
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
{% elif request.resolver_match.url_name == 'bottle-feeding-add' %}
|
||||||
|
<h1>{% trans "Add a Bottle Feeding" %}</h1>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1>{% trans "Add a Feeding" %}</h1>
|
<h1>{% trans "Add a Feeding" %}</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -38,6 +38,11 @@ urlpatterns = [
|
||||||
views.DiaperChangeDelete.as_view(),
|
views.DiaperChangeDelete.as_view(),
|
||||||
name="diaperchange-delete",
|
name="diaperchange-delete",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"feedings/bottle/add/",
|
||||||
|
views.BottleFeedingAdd.as_view(),
|
||||||
|
name="bottle-feeding-add",
|
||||||
|
),
|
||||||
path("feedings/", views.FeedingList.as_view(), name="feeding-list"),
|
path("feedings/", views.FeedingList.as_view(), name="feeding-list"),
|
||||||
path("feedings/add/", views.FeedingAdd.as_view(), name="feeding-add"),
|
path("feedings/add/", views.FeedingAdd.as_view(), name="feeding-add"),
|
||||||
path("feedings/<int:pk>/", views.FeedingUpdate.as_view(), name="feeding-update"),
|
path("feedings/<int:pk>/", views.FeedingUpdate.as_view(), name="feeding-update"),
|
||||||
|
|
|
@ -192,6 +192,13 @@ class FeedingAdd(CoreAddView):
|
||||||
success_url = reverse_lazy("core:feeding-list")
|
success_url = reverse_lazy("core:feeding-list")
|
||||||
|
|
||||||
|
|
||||||
|
class BottleFeedingAdd(CoreAddView):
|
||||||
|
model = models.Feeding
|
||||||
|
permission_required = ("core.add_feeding",)
|
||||||
|
form_class = forms.BottleFeedingForm
|
||||||
|
success_url = reverse_lazy("core:feeding-list")
|
||||||
|
|
||||||
|
|
||||||
class FeedingUpdate(CoreUpdateView):
|
class FeedingUpdate(CoreUpdateView):
|
||||||
model = models.Feeding
|
model = models.Feeding
|
||||||
permission_required = ("core.change_feeding",)
|
permission_required = ("core.change_feeding",)
|
||||||
|
|
Loading…
Reference in New Issue