diff --git a/cookbook/tables.py b/cookbook/tables.py
index 62afae9df..76b95e815 100644
--- a/cookbook/tables.py
+++ b/cookbook/tables.py
@@ -60,8 +60,9 @@ class MonitoredPathTable(tables.Table):
fields = ('id', 'path', 'last_checked')
-class NewRecipeTable(tables.Table):
- delete = tables.TemplateColumn("" + _('Delete') + "")
+class ImportTable(tables.Table):
+ id = tables.LinkColumn('edit_import', args=[A('id')])
+ delete = tables.TemplateColumn("" + _('Delete') + "")
class Meta:
model = NewRecipe
diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html
index 08c8a1787..8e55a21f1 100644
--- a/cookbook/templates/base.html
+++ b/cookbook/templates/base.html
@@ -71,6 +71,8 @@
class="fas fa-archive"> {% trans 'Category' %}
{% trans 'Keyword' %}
+ {% trans 'New Recipes' %}
{% trans 'Import Log' %}
@@ -83,8 +85,6 @@
diff --git a/cookbook/urls.py b/cookbook/urls.py
index 14523e3ee..d43cb4440 100644
--- a/cookbook/urls.py
+++ b/cookbook/urls.py
@@ -14,22 +14,23 @@ urlpatterns = [
path('list/keyword', lists.keyword, name='list_keyword'),
path('list/category', lists.category, name='list_category'),
- path('list/import', lists.import_log, name='list_import_log'),
+ path('list/import_log', lists.import_log, name='list_import_log'),
+ path('list/import', lists.new_recipe, name='list_import'),
path('edit/recipe//', edit.RecipeUpdate.as_view(), name='edit_recipe'),
path('edit/keyword//', edit.KeywordUpdate.as_view(), name='edit_keyword'),
path('edit/category//', edit.CategoryUpdate.as_view(), name='edit_category'),
path('edit/monitor//', edit.MonitorUpdate.as_view(), name='edit_monitor'),
+ path('edit/import//', edit.ImportUpdate.as_view(), name='edit_import'),
path('delete/recipe//', edit.RecipeDelete.as_view(), name='delete_recipe'),
path('delete/keyword//', edit.KeywordDelete.as_view(), name='delete_keyword'),
path('delete/category//', edit.CategoryDelete.as_view(), name='delete_category'),
path('delete/monitor//', edit.MonitorDelete.as_view(), name='delete_monitor'),
- path('delete/new_recipe//', edit.NewRecipeDelete.as_view(), name='delete_new_recipe'),
+ path('delete/import//', edit.ImportDelete.as_view(), name='delete_import'),
path('batch/monitor', batch.batch_monitor, name='batch_monitor'),
path('batch/category', batch.batch_edit, name='batch_edit'),
- path('batch/import', batch.batch_import, name='batch_import'),
path('batch/import/all', batch.batch_import_all, name='batch_import_all'),
path('api/get_file_link//', api.get_file_link, name='api_get_file_link'),
diff --git a/cookbook/views/batch.py b/cookbook/views/batch.py
index 055eb11c5..107bde066 100644
--- a/cookbook/views/batch.py
+++ b/cookbook/views/batch.py
@@ -6,7 +6,7 @@ from django_tables2 import RequestConfig
from cookbook.forms import MonitorForm, BatchEditForm, NewRecipe
from cookbook.models import Recipe, Category, Monitor
-from cookbook.tables import MonitoredPathTable, NewRecipeTable
+from cookbook.tables import MonitoredPathTable
@login_required
@@ -28,14 +28,6 @@ def batch_monitor(request):
return render(request, 'batch/monitor.html', {'form': form, 'monitored_paths': monitored_paths})
-@login_required
-def batch_import(request):
- imported_recipes = NewRecipeTable(NewRecipe.objects.all())
- RequestConfig(request, paginate={'per_page': 25}).configure(imported_recipes)
-
- return render(request, 'batch/import.html', {'imported_recipes': imported_recipes})
-
-
@login_required
def batch_import_all(request):
if request.method == "POST":
diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py
index 42b87d648..580ff6ed6 100644
--- a/cookbook/views/edit.py
+++ b/cookbook/views/edit.py
@@ -1,7 +1,5 @@
-from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
-from django.shortcuts import redirect, render
from django.urls import reverse_lazy, reverse
from django.utils.translation import gettext as _
from django.views.generic import UpdateView, DeleteView
@@ -52,6 +50,20 @@ class KeywordUpdate(LoginRequiredMixin, UpdateView):
return context
+class ImportUpdate(LoginRequiredMixin, UpdateView):
+ template_name = "generic\edit_template.html"
+ model = NewRecipe
+ fields = ['name', 'path']
+
+ def get_success_url(self):
+ return reverse('edit_import', kwargs={'pk': self.object.pk})
+
+ def get_context_data(self, **kwargs):
+ context = super(ImportUpdate, self).get_context_data(**kwargs)
+ context['title'] = _("Import")
+ return context
+
+
class RecipeUpdate(LoginRequiredMixin, UpdateView):
model = Recipe
form_class = EditRecipeForm
@@ -86,6 +98,17 @@ class RecipeDelete(LoginRequiredMixin, DeleteView):
return context
+class ImportDelete(LoginRequiredMixin, DeleteView):
+ template_name = "generic\delete_template.html"
+ model = NewRecipe
+ success_url = reverse_lazy('index')
+
+ def get_context_data(self, **kwargs):
+ context = super(ImportDelete, self).get_context_data(**kwargs)
+ context['title'] = _("Import")
+ return context
+
+
class MonitorDelete(LoginRequiredMixin, DeleteView):
template_name = "generic\delete_template.html"
model = Monitor
@@ -116,15 +139,4 @@ class KeywordDelete(LoginRequiredMixin, DeleteView):
def get_context_data(self, **kwargs):
context = super(KeywordDelete, self).get_context_data(**kwargs)
context['title'] = _("Keyword")
- return context
-
-
-class NewRecipeDelete(LoginRequiredMixin, DeleteView):
- template_name = "generic\delete_template.html"
- model = NewRecipe
- success_url = reverse_lazy('batch_import')
-
- def get_context_data(self, **kwargs):
- context = super(NewRecipeDelete, self).get_context_data(**kwargs)
- context['title'] = _("Import Recipe")
- return context
+ return context
\ No newline at end of file
diff --git a/cookbook/views/lists.py b/cookbook/views/lists.py
index 67bf07170..cbfb6e6e7 100644
--- a/cookbook/views/lists.py
+++ b/cookbook/views/lists.py
@@ -4,8 +4,8 @@ from django.shortcuts import render
from django_tables2 import RequestConfig
from django.utils.translation import gettext as _
-from cookbook.models import Category, Keyword, ImportLog
-from cookbook.tables import CategoryTable, KeywordTable, ImportLogTable
+from cookbook.models import Category, Keyword, ImportLog, NewRecipe
+from cookbook.tables import CategoryTable, KeywordTable, ImportLogTable, ImportTable
@login_required
@@ -30,3 +30,11 @@ def import_log(request):
RequestConfig(request, paginate={'per_page': 25}).configure(table)
return render(request, 'generic/list_template.html', {'title': _("Import Log"), 'table': table})
+
+
+@login_required
+def new_recipe(request):
+ table = ImportTable(NewRecipe.objects.all())
+ RequestConfig(request, paginate={'per_page': 25}).configure(table)
+
+ return render(request, 'generic/list_template.html', {'title': _("Import"), 'table': table})