fixed various space related bugs

This commit is contained in:
vabene1111 2021-03-11 16:41:05 +01:00
parent b552badff7
commit 7e38e946a5
4 changed files with 8 additions and 7 deletions

View File

@ -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

View File

@ -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})

View File

@ -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()

View File

@ -103,6 +103,7 @@ def create_new_external_recipe(request, import_id):
recipe.save()
if form.cleaned_data['keywords']:
recipe.keywords.set(form.cleaned_data['keywords'])
new_recipe.delete()