fixed meal plan form not own type display
This commit is contained in:
parent
0005ca243c
commit
67a4a2627b
@ -20,7 +20,7 @@ from cookbook.helper.permission_helper import group_required, GroupRequiredMixin
|
||||
|
||||
from cookbook.helper.permission_helper import OwnerRequiredMixin
|
||||
from cookbook.models import Recipe, Sync, Keyword, RecipeImport, Storage, Comment, Ingredient, RecipeBook, \
|
||||
MealPlan, Unit, Food
|
||||
MealPlan, Unit, Food, MealType
|
||||
from cookbook.provider.dropbox import Dropbox
|
||||
from cookbook.provider.nextcloud import Nextcloud
|
||||
|
||||
@ -192,6 +192,11 @@ class MealPlanUpdate(OwnerRequiredMixin, UpdateView):
|
||||
def get_success_url(self):
|
||||
return reverse('view_plan_entry', kwargs={'pk': self.object.pk})
|
||||
|
||||
def get_form(self, form_class=None):
|
||||
form = self.form_class(**self.get_form_kwargs())
|
||||
form.fields['meal_type'].queryset = MealType.objects.filter(created_by=self.request.user).all()
|
||||
return form
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(MealPlanUpdate, self).get_context_data(**kwargs)
|
||||
context['title'] = _("Meal-Plan")
|
||||
|
@ -11,7 +11,7 @@ from django.views.generic import CreateView
|
||||
from cookbook.forms import ImportRecipeForm, RecipeImport, KeywordForm, Storage, StorageForm, InternalRecipeForm, \
|
||||
RecipeBookForm, MealPlanForm
|
||||
from cookbook.helper.permission_helper import GroupRequiredMixin, group_required
|
||||
from cookbook.models import Keyword, Recipe, RecipeBook, MealPlan, ShareLink
|
||||
from cookbook.models import Keyword, Recipe, RecipeBook, MealPlan, ShareLink, MealType
|
||||
|
||||
|
||||
class RecipeCreate(GroupRequiredMixin, CreateView):
|
||||
@ -132,6 +132,11 @@ class MealPlanCreate(GroupRequiredMixin, CreateView):
|
||||
form_class = MealPlanForm
|
||||
success_url = reverse_lazy('view_plan')
|
||||
|
||||
def get_form(self, form_class=None):
|
||||
form = self.form_class(**self.get_form_kwargs())
|
||||
form.fields['meal_type'].queryset = MealType.objects.filter(created_by=self.request.user).all()
|
||||
return form
|
||||
|
||||
def get_initial(self):
|
||||
return dict(
|
||||
meal_type=self.request.GET['meal'] if 'meal' in self.request.GET else None,
|
||||
|
Loading…
Reference in New Issue
Block a user