Self hosted FLOSS fitness/workout, nutrition and weight tracker
Updated log based on flake feedback
Christopher O'Connell92bcb92e62fe
diff --git a/wger/nutrition/views/log.py b/wger/nutrition/views/log.pyindex 0f61339dd..434d1d70d 100644--- a/wger/nutrition/views/log.py+++ b/wger/nutrition/views/log.py@@ -126,13 +126,15 @@ def log_meal(request, meal_pk):if not is_owner and not mealUser.userprofile.ro_access:return HttpResponseForbidden()-+_logMealPlan([meal])date = datetime.date.today()- return HttpResponseRedirect(reverse('nutrition:log:detail', kwargs={'pk': meal_pk,- 'year': date.year,- 'month': date.month,- 'day': date.day}))+ return HttpResponseRedirect(reverse('nutrition:log:detail',+ kwargs={'pk': meal_pk,+ 'year': date.year,+ 'month': date.month,+ 'day': date.day}))+def log_plan(request, plan_pk):"""@@ -143,10 +145,11 @@ def log_plan(request, plan_pk):is_owner = request.user == planUserif not is_owner and not planUser.userprofile.ro_access:return HttpResponseForbidden()-+_logMealPlan(plan.meal_set.select_related())return HttpResponseRedirect(reverse('nutrition:log:overview', kwargs={'pk': plan_pk}))+def _logMealPlan(meals):"""Helper method to log a collection of meals@@ -155,11 +158,12 @@ def _logMealPlan(meals):for meal in meals:for item in meal.mealitem_set.select_related():log_item = LogItem(plan=item.meal.plan,- ingredient=item.ingredient,- weight_unit=item.weight_unit,- amount=item.amount)+ ingredient=item.ingredient,+ weight_unit=item.weight_unit,+ amount=item.amount)log_item.save()+class LogCreateView(WgerFormMixin, CreateView):"""Generic view to create a new meal diary entry