Skip to content

Commit

Permalink
feat(add meals): add meals to nutrition plan
Browse files Browse the repository at this point in the history
- redirect to the page for adding meal items immediately after
creating a meal.
  • Loading branch information
richien committed Jun 14, 2019
1 parent 927c2cc commit 2bcbf07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion wger/nutrition/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
from django.utils.translation import ugettext as _
from wger.core.models import UserProfile

from wger.nutrition.models import IngredientWeightUnit, Ingredient, MealItem
from wger.nutrition.models import (
IngredientWeightUnit, Ingredient, MealItem, Meal)
from wger.utils.widgets import Html5NumberInput
from django.forms import inlineformset_factory


logger = logging.getLogger(__name__)
Expand Down
2 changes: 0 additions & 2 deletions wger/nutrition/templates/meal_item/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
{% endblock %}




{% block content %}
<form action="{{ form_action }}"
method="post"
Expand Down
4 changes: 3 additions & 1 deletion wger/nutrition/views/meal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from wger.nutrition.models import NutritionPlan, Meal
from wger.utils.generic_views import WgerFormMixin
# from wger.nutrition.forms import MealForm

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -53,7 +54,8 @@ def form_valid(self, form):
return super(MealCreateView, self).form_valid(form)

def get_success_url(self):
return self.object.plan.get_absolute_url()
return reverse(
"nutrition:meal_item:add", kwargs={"meal_id": self.object.id})

# Send some additional data to the template
def get_context_data(self, **kwargs):
Expand Down

0 comments on commit 2bcbf07

Please sign in to comment.