diff --git a/cookbook/forms.py b/cookbook/forms.py index 73a80417..e80fe32f 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -266,7 +266,7 @@ class SyncForm(forms.ModelForm): def __init__(self, *args, **kwargs): space = kwargs.pop('space') super().__init__(*args, **kwargs) - self.fields['book'].queryset = Storage.objects.filter(space=space).all() + self.fields['storage'].queryset = Storage.objects.filter(space=space).all() class Meta: model = Sync diff --git a/cookbook/views/data.py b/cookbook/views/data.py index 39218e6f..1ad355a5 100644 --- a/cookbook/views/data.py +++ b/cookbook/views/data.py @@ -29,7 +29,7 @@ def sync(request): if not has_group_permission(request.user, ['admin']): messages.add_message(request, messages.ERROR, _('You do not have the required permissions to view this page!')) return HttpResponseRedirect(reverse('data_sync')) - form = SyncForm(request.POST) + form = SyncForm(request.POST, space=request.space) if form.is_valid(): new_path = Sync() new_path.path = form.cleaned_data['path'] @@ -39,9 +39,9 @@ def sync(request): new_path.save() return redirect('data_sync') else: - form = SyncForm() + form = SyncForm(space=request.space) - monitored_paths = SyncTable(Sync.objects.fitler(space=request.space).all()) + monitored_paths = SyncTable(Sync.objects.filter(space=request.space).all()) RequestConfig(request, paginate={'per_page': 25}).configure(monitored_paths) return render(request, 'batch/monitor.html', {'form': form, 'monitored_paths': monitored_paths}) diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index 3ce02087..fd127800 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -279,7 +279,7 @@ def edit_ingredients(request): new_unit = units_form.cleaned_data['new_unit'] old_unit = units_form.cleaned_data['old_unit'] if new_unit != old_unit: - recipe_ingredients = Ingredient.objects.filter(unit=old_unit, space=request.space).all() + recipe_ingredients = Ingredient.objects.filter(unit=old_unit, step__recipe__space=request.space).all() for i in recipe_ingredients: i.unit = new_unit i.save() @@ -295,7 +295,7 @@ def edit_ingredients(request): new_food = food_form.cleaned_data['new_food'] old_food = food_form.cleaned_data['old_food'] if new_food != old_food: - ingredients = Ingredient.objects.filter(food=old_food, space=request.space).all() + ingredients = Ingredient.objects.filter(food=old_food, step__recipe__space=request.space).all() for i in ingredients: i.food = new_food i.save() diff --git a/cookbook/views/new.py b/cookbook/views/new.py index 927c873c..f9c79013 100644 --- a/cookbook/views/new.py +++ b/cookbook/views/new.py @@ -103,7 +103,8 @@ def create_new_external_recipe(request, import_id): recipe.save() - recipe.keywords.set(form.cleaned_data['keywords']) + if form.cleaned_data['keywords']: + recipe.keywords.set(form.cleaned_data['keywords']) new_recipe.delete()