diff --git a/cookbook/helper/dropbox.py b/cookbook/helper/dropbox.py
index 64edebf4a..1ddb4f8e5 100644
--- a/cookbook/helper/dropbox.py
+++ b/cookbook/helper/dropbox.py
@@ -12,7 +12,11 @@ def sync_all():
monitors = Monitor.objects.all()
for monitor in monitors:
- import_all(monitor)
+ ret = import_all(monitor)
+ if not ret:
+ return ret
+
+ return True
def import_all(monitor):
diff --git a/cookbook/tables.py b/cookbook/tables.py
index 967c9d2c9..62afae9df 100644
--- a/cookbook/tables.py
+++ b/cookbook/tables.py
@@ -41,13 +41,23 @@ class KeywordTable(tables.Table):
fields = ('id', 'name')
+class ImportLogTable(tables.Table):
+ monitor_id = tables.LinkColumn('edit_monitor', args=[A('monitor_id')])
+
+ class Meta:
+ model = ImportLog
+ template_name = 'generic/table_template.html'
+ fields = ('status', 'msg', 'monitor_id', 'created_at')
+
+
class MonitoredPathTable(tables.Table):
+ id = tables.LinkColumn('edit_monitor', args=[A('id')])
delete = tables.TemplateColumn("" + _('Delete') + "")
class Meta:
model = Monitor
template_name = 'generic/table_template.html'
- fields = ('path', 'last_checked')
+ fields = ('id', 'path', 'last_checked')
class NewRecipeTable(tables.Table):
@@ -56,4 +66,4 @@ class NewRecipeTable(tables.Table):
class Meta:
model = NewRecipe
template_name = 'generic/table_template.html'
- fields = ('name','path')
+ fields = ('id', 'name', 'path')
diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html
index 4d938f30d..08c8a1787 100644
--- a/cookbook/templates/base.html
+++ b/cookbook/templates/base.html
@@ -71,6 +71,8 @@
class="fas fa-archive"> {% trans 'Category' %}
{% trans 'Keyword' %}
+ {% trans 'Import Log' %}
diff --git a/cookbook/urls.py b/cookbook/urls.py
index 87ddce92d..14523e3ee 100644
--- a/cookbook/urls.py
+++ b/cookbook/urls.py
@@ -12,8 +12,9 @@ urlpatterns = [
path('new/category', new.CategoryCreate.as_view(), name='new_category'),
path('new/keyword', new.KeywordCreate.as_view(), name='new_keyword'),
- path('list/keyword', lists.keyword_list, name='list_keyword'),
- path('list/category', lists.category_list, name='list_category'),
+ 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('edit/recipe//', edit.RecipeUpdate.as_view(), name='edit_recipe'),
path('edit/keyword//', edit.KeywordUpdate.as_view(), name='edit_keyword'),
diff --git a/cookbook/views/api.py b/cookbook/views/api.py
index 24d8097e0..d6a7a9715 100644
--- a/cookbook/views/api.py
+++ b/cookbook/views/api.py
@@ -1,6 +1,8 @@
+from django.contrib import messages
from django.http import HttpResponse
-
+from django.utils.translation import gettext as _
from django.contrib.auth.decorators import login_required
+from django.shortcuts import redirect
from cookbook.models import Recipe
from cookbook.helper import dropbox
@@ -19,5 +21,10 @@ def get_file_link(request, recipe_id):
@login_required
def dropbox_sync(request):
- dropbox.sync_all()
- return HttpResponse("Import Successful ... or not ? WIP")
+ ret = dropbox.sync_all()
+ if ret:
+ messages.add_message(request, messages.SUCCESS, _('Sync successful!'))
+ return redirect('batch_import')
+ else:
+ messages.add_message(request, messages.ERROR, _('Error synchronizing with Storage'))
+ return redirect('batch_monitor')
diff --git a/cookbook/views/lists.py b/cookbook/views/lists.py
index 4e337d027..67bf07170 100644
--- a/cookbook/views/lists.py
+++ b/cookbook/views/lists.py
@@ -1,14 +1,15 @@
from django.contrib.auth.decorators import login_required
+from django.db.models.functions import Lower
from django.shortcuts import render
from django_tables2 import RequestConfig
from django.utils.translation import gettext as _
-from cookbook.models import Category, Keyword
-from cookbook.tables import CategoryTable, KeywordTable
+from cookbook.models import Category, Keyword, ImportLog
+from cookbook.tables import CategoryTable, KeywordTable, ImportLogTable
@login_required
-def category_list(request):
+def category(request):
table = CategoryTable(Category.objects.all())
RequestConfig(request, paginate={'per_page': 25}).configure(table)
@@ -16,8 +17,16 @@ def category_list(request):
@login_required
-def keyword_list(request):
+def keyword(request):
table = KeywordTable(Keyword.objects.all())
RequestConfig(request, paginate={'per_page': 25}).configure(table)
return render(request, 'generic/list_template.html', {'title': _("Keyword"), 'table': table})
+
+
+@login_required
+def import_log(request):
+ table = ImportLogTable(ImportLog.objects.all().order_by(Lower('created_at').desc()))
+ RequestConfig(request, paginate={'per_page': 25}).configure(table)
+
+ return render(request, 'generic/list_template.html', {'title': _("Import Log"), 'table': table})