list views

This commit is contained in:
vabene1111
2018-05-03 20:43:47 +02:00
parent 284beb47af
commit e722863093
8 changed files with 50 additions and 29 deletions

View File

@ -74,28 +74,6 @@ class RecipeUpdate(LoginRequiredMixin, UpdateView):
return context
@login_required
def recipe(request, recipe_id):
recipe_obj = Recipe.objects.get(id=recipe_id)
if request.method == "POST":
form = EditRecipeForm(request.POST)
if form.is_valid():
recipe_obj.name = form.cleaned_data['name']
recipe_obj.path = form.cleaned_data['path']
recipe_obj.category = Category.objects.get(name=form.cleaned_data['category'])
recipe_obj.keywords.clear()
recipe_obj.keywords.add(*list(form.cleaned_data['keywords']))
recipe_obj.save()
messages.add_message(request, messages.SUCCESS, _('Recipe updated'))
return redirect(reverse_lazy('edit_recipe', args=[recipe_id]))
else:
messages.add_message(request, messages.ERROR, _('Recipe update failed'))
else:
form = EditRecipeForm(instance=recipe_obj)
return render(request, 'edit/recipe.html', {'form': form})
# Generic Delete views
class RecipeDelete(LoginRequiredMixin, DeleteView):
template_name = "generic\delete_template.html"