From 4be125353f5bf20c302d386dddd8df38114429ec Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 6 May 2018 21:33:24 +0200 Subject: [PATCH] import --- cookbook/helper/dropbox.py | 6 +++++- cookbook/tables.py | 14 ++++++++++++-- cookbook/templates/base.html | 2 ++ cookbook/urls.py | 5 +++-- cookbook/views/api.py | 13 ++++++++++--- cookbook/views/lists.py | 17 +++++++++++++---- 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/cookbook/helper/dropbox.py b/cookbook/helper/dropbox.py index 64edebf4..1ddb4f8e 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 967c9d2c..62afae9d 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 4d938f30..08c8a178 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' %}