import
This commit is contained in:
parent
bc287364ac
commit
4be125353f
@ -12,7 +12,11 @@ def sync_all():
|
|||||||
monitors = Monitor.objects.all()
|
monitors = Monitor.objects.all()
|
||||||
|
|
||||||
for monitor in monitors:
|
for monitor in monitors:
|
||||||
import_all(monitor)
|
ret = import_all(monitor)
|
||||||
|
if not ret:
|
||||||
|
return ret
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def import_all(monitor):
|
def import_all(monitor):
|
||||||
|
@ -41,13 +41,23 @@ class KeywordTable(tables.Table):
|
|||||||
fields = ('id', 'name')
|
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):
|
class MonitoredPathTable(tables.Table):
|
||||||
|
id = tables.LinkColumn('edit_monitor', args=[A('id')])
|
||||||
delete = tables.TemplateColumn("<a href='{% url 'delete_monitor' record.id %}' >" + _('Delete') + "</a>")
|
delete = tables.TemplateColumn("<a href='{% url 'delete_monitor' record.id %}' >" + _('Delete') + "</a>")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Monitor
|
model = Monitor
|
||||||
template_name = 'generic/table_template.html'
|
template_name = 'generic/table_template.html'
|
||||||
fields = ('path', 'last_checked')
|
fields = ('id', 'path', 'last_checked')
|
||||||
|
|
||||||
|
|
||||||
class NewRecipeTable(tables.Table):
|
class NewRecipeTable(tables.Table):
|
||||||
@ -56,4 +66,4 @@ class NewRecipeTable(tables.Table):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = NewRecipe
|
model = NewRecipe
|
||||||
template_name = 'generic/table_template.html'
|
template_name = 'generic/table_template.html'
|
||||||
fields = ('name','path')
|
fields = ('id', 'name', 'path')
|
||||||
|
@ -71,6 +71,8 @@
|
|||||||
class="fas fa-archive"></i> {% trans 'Category' %}</a>
|
class="fas fa-archive"></i> {% trans 'Category' %}</a>
|
||||||
<a class="dropdown-item" href="{% url 'list_keyword' %}"><i
|
<a class="dropdown-item" href="{% url 'list_keyword' %}"><i
|
||||||
class="fas fa-tags"></i> {% trans 'Keyword' %}</a>
|
class="fas fa-tags"></i> {% trans 'Keyword' %}</a>
|
||||||
|
<a class="dropdown-item" href="{% url 'list_import_log' %}"><i
|
||||||
|
class="fas fa-history"></i> {% trans 'Import Log' %}</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
|
@ -12,8 +12,9 @@ urlpatterns = [
|
|||||||
path('new/category', new.CategoryCreate.as_view(), name='new_category'),
|
path('new/category', new.CategoryCreate.as_view(), name='new_category'),
|
||||||
path('new/keyword', new.KeywordCreate.as_view(), name='new_keyword'),
|
path('new/keyword', new.KeywordCreate.as_view(), name='new_keyword'),
|
||||||
|
|
||||||
path('list/keyword', lists.keyword_list, name='list_keyword'),
|
path('list/keyword', lists.keyword, name='list_keyword'),
|
||||||
path('list/category', lists.category_list, name='list_category'),
|
path('list/category', lists.category, name='list_category'),
|
||||||
|
path('list/import', lists.import_log, name='list_import_log'),
|
||||||
|
|
||||||
path('edit/recipe/<int:pk>/', edit.RecipeUpdate.as_view(), name='edit_recipe'),
|
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/keyword/<int:pk>/', edit.KeywordUpdate.as_view(), name='edit_keyword'),
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
from django.contrib import messages
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
from cookbook.models import Recipe
|
from cookbook.models import Recipe
|
||||||
from cookbook.helper import dropbox
|
from cookbook.helper import dropbox
|
||||||
@ -19,5 +21,10 @@ def get_file_link(request, recipe_id):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def dropbox_sync(request):
|
def dropbox_sync(request):
|
||||||
dropbox.sync_all()
|
ret = dropbox.sync_all()
|
||||||
return HttpResponse("Import Successful ... or not ? WIP")
|
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')
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.db.models.functions import Lower
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django_tables2 import RequestConfig
|
from django_tables2 import RequestConfig
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
from cookbook.models import Category, Keyword
|
from cookbook.models import Category, Keyword, ImportLog
|
||||||
from cookbook.tables import CategoryTable, KeywordTable
|
from cookbook.tables import CategoryTable, KeywordTable, ImportLogTable
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def category_list(request):
|
def category(request):
|
||||||
table = CategoryTable(Category.objects.all())
|
table = CategoryTable(Category.objects.all())
|
||||||
RequestConfig(request, paginate={'per_page': 25}).configure(table)
|
RequestConfig(request, paginate={'per_page': 25}).configure(table)
|
||||||
|
|
||||||
@ -16,8 +17,16 @@ def category_list(request):
|
|||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def keyword_list(request):
|
def keyword(request):
|
||||||
table = KeywordTable(Keyword.objects.all())
|
table = KeywordTable(Keyword.objects.all())
|
||||||
RequestConfig(request, paginate={'per_page': 25}).configure(table)
|
RequestConfig(request, paginate={'per_page': 25}).configure(table)
|
||||||
|
|
||||||
return render(request, 'generic/list_template.html', {'title': _("Keyword"), 'table': 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})
|
||||||
|
Loading…
Reference in New Issue
Block a user