mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
renamed models + new migrations + initial data
This commit is contained in:
@@ -6,7 +6,7 @@ from django.urls import reverse_lazy
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic import CreateView
|
||||
|
||||
from cookbook.forms import ImportRecipeForm, NewRecipe
|
||||
from cookbook.forms import ImportRecipeForm, RecipeImport
|
||||
from cookbook.models import Category, Keyword, Recipe
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@ class RecipeCreate(LoginRequiredMixin, CreateView): # this exists for completen
|
||||
template_name = "generic\\new_template.html"
|
||||
model = Recipe
|
||||
fields = ['name', 'category', 'keywords']
|
||||
success_url = reverse_lazy('list_category')
|
||||
|
||||
def get_initial(self):
|
||||
return {'value1': self.request.user}
|
||||
success_url = reverse_lazy('index')
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(RecipeCreate, self).get_context_data(**kwargs)
|
||||
@@ -63,14 +60,14 @@ def create_new_recipe(request, import_id):
|
||||
|
||||
recipe.keywords.set(form.cleaned_data['keywords'])
|
||||
|
||||
NewRecipe.objects.get(id=import_id).delete()
|
||||
RecipeImport.objects.get(id=import_id).delete()
|
||||
|
||||
messages.add_message(request, messages.SUCCESS, _('Imported new recipe!'))
|
||||
return redirect('list_import')
|
||||
else:
|
||||
messages.add_message(request, messages.ERROR, _('There was an error importing this recipe!'))
|
||||
else:
|
||||
new_recipe = NewRecipe.objects.get(id=import_id)
|
||||
new_recipe = RecipeImport.objects.get(id=import_id)
|
||||
form = ImportRecipeForm(initial={'path': new_recipe.path, 'name': new_recipe.name})
|
||||
|
||||
return render(request, 'forms/edit_import_recipe.html', {'form': form})
|
||||
|
||||
Reference in New Issue
Block a user