revorked import
This commit is contained in:
parent
4be125353f
commit
8d4506da54
@ -60,8 +60,9 @@ class MonitoredPathTable(tables.Table):
|
||||
fields = ('id', 'path', 'last_checked')
|
||||
|
||||
|
||||
class NewRecipeTable(tables.Table):
|
||||
delete = tables.TemplateColumn("<a href='{% url 'delete_new_recipe' record.id %}' >" + _('Delete') + "</a>")
|
||||
class ImportTable(tables.Table):
|
||||
id = tables.LinkColumn('edit_import', args=[A('id')])
|
||||
delete = tables.TemplateColumn("<a href='{% url 'delete_import' record.id %}' >" + _('Delete') + "</a>")
|
||||
|
||||
class Meta:
|
||||
model = NewRecipe
|
||||
|
@ -71,6 +71,8 @@
|
||||
class="fas fa-archive"></i> {% trans 'Category' %}</a>
|
||||
<a class="dropdown-item" href="{% url 'list_keyword' %}"><i
|
||||
class="fas fa-tags"></i> {% trans 'Keyword' %}</a>
|
||||
<a class="dropdown-item" href="{% url 'list_import' %}"><i
|
||||
class="far fa-file-alt"></i> {% trans 'New Recipes' %}</a>
|
||||
<a class="dropdown-item" href="{% url 'list_import_log' %}"><i
|
||||
class="fas fa-history"></i> {% trans 'Import Log' %}</a>
|
||||
</div>
|
||||
@ -83,8 +85,6 @@
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
||||
<a class="dropdown-item" href="{% url 'batch_monitor' %}"><i
|
||||
class="fas fa-sync-alt"></i> {% trans 'Configure Sync' %}</a>
|
||||
<a class="dropdown-item" href="{% url 'batch_import' %}"><i
|
||||
class="fas fa-wrench"></i> {% trans 'Manage imported Recipes' %}</a>
|
||||
<a class="dropdown-item" href="{% url 'batch_edit' %}"><i
|
||||
class="fas fa-edit"></i> {% trans 'Batch Edit' %}</a>
|
||||
</div>
|
||||
|
@ -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/<int:pk>/', edit.RecipeUpdate.as_view(), name='edit_recipe'),
|
||||
path('edit/keyword/<int:pk>/', edit.KeywordUpdate.as_view(), name='edit_keyword'),
|
||||
path('edit/category/<int:pk>/', edit.CategoryUpdate.as_view(), name='edit_category'),
|
||||
path('edit/monitor/<int:pk>/', edit.MonitorUpdate.as_view(), name='edit_monitor'),
|
||||
path('edit/import/<int:pk>/', edit.ImportUpdate.as_view(), name='edit_import'),
|
||||
|
||||
path('delete/recipe/<int:pk>/', edit.RecipeDelete.as_view(), name='delete_recipe'),
|
||||
path('delete/keyword/<int:pk>/', edit.KeywordDelete.as_view(), name='delete_keyword'),
|
||||
path('delete/category/<int:pk>/', edit.CategoryDelete.as_view(), name='delete_category'),
|
||||
path('delete/monitor/<int:pk>/', edit.MonitorDelete.as_view(), name='delete_monitor'),
|
||||
path('delete/new_recipe/<int:pk>/', edit.NewRecipeDelete.as_view(), name='delete_new_recipe'),
|
||||
path('delete/import/<int:pk>/', 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/<int:recipe_id>/', api.get_file_link, name='api_get_file_link'),
|
||||
|
@ -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":
|
||||
|
@ -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
|
@ -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})
|
||||
|
Loading…
Reference in New Issue
Block a user