diff --git a/.gitignore b/.gitignore
index cd00b1df..e09e29a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,3 +70,5 @@ secret_settings\.py
*.sqlite3
\.idea/workspace\.xml
+
+cookbook/migrations/
diff --git a/.idea/recipes.iml b/.idea/recipes.iml
index e077f7e4..43fb334e 100644
--- a/.idea/recipes.iml
+++ b/.idea/recipes.iml
@@ -4,10 +4,11 @@
-
+
+
diff --git a/cookbook/forms.py b/cookbook/forms.py
index 24441111..31339f08 100644
--- a/cookbook/forms.py
+++ b/cookbook/forms.py
@@ -91,7 +91,7 @@ class ImportForm(forms.Form):
super(ImportForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_method = 'post'
- self.helper.add_input(Submit('import', _('Import'), css_class='btn-primary'))
+ self.helper.add_input(Submit('import', _('Sync'), css_class='btn-primary'))
class BatchEditForm(forms.Form):
diff --git a/cookbook/migrations/0001_initial.py b/cookbook/migrations/0001_initial.py
deleted file mode 100644
index 044d2279..00000000
--- a/cookbook/migrations/0001_initial.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# Generated by Django 2.0.1 on 2018-01-31 21:52
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- initial = True
-
- dependencies = [
- ]
-
- operations = [
- migrations.CreateModel(
- name='Category',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=64)),
- ('description', models.TextField(default='')),
- ('created_by', models.IntegerField(default=0)),
- ('created_at', models.DateTimeField(auto_now_add=True)),
- ('updated_at', models.DateTimeField(auto_now=True)),
- ],
- ),
- migrations.CreateModel(
- name='Keyword',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=64)),
- ('description', models.TextField(default='')),
- ('created_by', models.IntegerField(default=0)),
- ('created_at', models.DateTimeField(auto_now_add=True)),
- ('updated_at', models.DateTimeField(auto_now=True)),
- ],
- ),
- migrations.CreateModel(
- name='Recipe',
- fields=[
- ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=64)),
- ('created_by', models.IntegerField(default=0)),
- ('created_at', models.DateTimeField(auto_now_add=True)),
- ('updated_at', models.DateTimeField(auto_now=True)),
- ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cookbook.Category')),
- ('keywords', models.ManyToManyField(to='cookbook.Keyword')),
- ],
- ),
- ]
diff --git a/cookbook/migrations/0002_auto_20180201_1457.py b/cookbook/migrations/0002_auto_20180201_1457.py
deleted file mode 100644
index 3c2ce6b8..00000000
--- a/cookbook/migrations/0002_auto_20180201_1457.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Generated by Django 2.0.1 on 2018-02-01 13:57
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cookbook', '0001_initial'),
- ]
-
- operations = [
- migrations.AlterField(
- model_name='category',
- name='description',
- field=models.TextField(blank=True, default=''),
- ),
- migrations.AlterField(
- model_name='keyword',
- name='description',
- field=models.TextField(blank=True, default=''),
- ),
- ]
diff --git a/cookbook/migrations/0003_recipe_path.py b/cookbook/migrations/0003_recipe_path.py
deleted file mode 100644
index 8c74198c..00000000
--- a/cookbook/migrations/0003_recipe_path.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated by Django 2.0.2 on 2018-02-05 18:40
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cookbook', '0002_auto_20180201_1457'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='recipe',
- name='path',
- field=models.CharField(default='', max_length=512),
- preserve_default=False,
- ),
- ]
diff --git a/cookbook/migrations/0004_auto_20180205_2316.py b/cookbook/migrations/0004_auto_20180205_2316.py
deleted file mode 100644
index 7ff2e3fb..00000000
--- a/cookbook/migrations/0004_auto_20180205_2316.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generated by Django 2.0.2 on 2018-02-05 22:16
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cookbook', '0003_recipe_path'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='recipe',
- name='link',
- field=models.CharField(default='', max_length=512),
- ),
- migrations.AlterField(
- model_name='recipe',
- name='keywords',
- field=models.ManyToManyField(blank=True, to='cookbook.Keyword'),
- ),
- migrations.AlterField(
- model_name='recipe',
- name='path',
- field=models.CharField(default='', max_length=512),
- ),
- ]
diff --git a/cookbook/migrations/0005_auto_20180209_1241.py b/cookbook/migrations/0005_auto_20180209_1241.py
deleted file mode 100644
index c9121152..00000000
--- a/cookbook/migrations/0005_auto_20180209_1241.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Generated by Django 2.0.1 on 2018-02-09 11:41
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cookbook', '0004_auto_20180205_2316'),
- ]
-
- operations = [
- migrations.AlterField(
- model_name='category',
- name='name',
- field=models.CharField(max_length=64, unique=True),
- ),
- migrations.AlterField(
- model_name='keyword',
- name='name',
- field=models.CharField(max_length=64, unique=True),
- ),
- ]
diff --git a/cookbook/migrations/0006_auto_20180209_1246.py b/cookbook/migrations/0006_auto_20180209_1246.py
deleted file mode 100644
index d90e9f8d..00000000
--- a/cookbook/migrations/0006_auto_20180209_1246.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Generated by Django 2.0.1 on 2018-02-09 11:46
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cookbook', '0005_auto_20180209_1241'),
- ]
-
- operations = [
- migrations.AlterField(
- model_name='recipe',
- name='category',
- field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='cookbook.Category'),
- ),
- migrations.AlterField(
- model_name='recipe',
- name='link',
- field=models.CharField(blank=True, default='', max_length=512),
- ),
- migrations.AlterField(
- model_name='recipe',
- name='path',
- field=models.CharField(blank=True, default='', max_length=512),
- ),
- ]
diff --git a/cookbook/migrations/0007_auto_20180209_1250.py b/cookbook/migrations/0007_auto_20180209_1250.py
deleted file mode 100644
index 398e8d7a..00000000
--- a/cookbook/migrations/0007_auto_20180209_1250.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Generated by Django 2.0.1 on 2018-02-09 11:50
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cookbook', '0006_auto_20180209_1246'),
- ]
-
- operations = [
- migrations.AlterField(
- model_name='recipe',
- name='category',
- field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.SET_DEFAULT, to='cookbook.Category'),
- ),
- migrations.AlterField(
- model_name='recipe',
- name='link',
- field=models.CharField(default='', max_length=512),
- ),
- migrations.AlterField(
- model_name='recipe',
- name='path',
- field=models.CharField(default='', max_length=512),
- ),
- ]
diff --git a/cookbook/migrations/0008_auto_20180209_1251.py b/cookbook/migrations/0008_auto_20180209_1251.py
deleted file mode 100644
index aec4e817..00000000
--- a/cookbook/migrations/0008_auto_20180209_1251.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated by Django 2.0.1 on 2018-02-09 11:51
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('cookbook', '0007_auto_20180209_1250'),
- ]
-
- operations = [
- migrations.AlterField(
- model_name='recipe',
- name='category',
- field=models.ForeignKey(blank=True, default='', on_delete=django.db.models.deletion.SET_DEFAULT, to='cookbook.Category'),
- ),
- ]
diff --git a/cookbook/migrations/__init__.py b/cookbook/migrations/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/cookbook/models.py b/cookbook/models.py
index 6edfd11f..19b7c215 100644
--- a/cookbook/models.py
+++ b/cookbook/models.py
@@ -39,3 +39,10 @@ class Recipe(models.Model):
@property
def all_tags(self):
return ', '.join([x.name for x in self.keywords.all()])
+
+
+class Monitor(models.Model):
+ path = models.CharField(max_length=512, default="")
+ last_checked = models.DateTimeField()
+ created_at = models.DateTimeField(auto_now_add=True)
+ updated_at = models.DateTimeField(auto_now=True)
diff --git a/cookbook/tables.py b/cookbook/tables.py
index 0e66117b..e5862e3a 100644
--- a/cookbook/tables.py
+++ b/cookbook/tables.py
@@ -20,7 +20,7 @@ class RecipeTable(tables.Table):
class CategoryTable(tables.Table):
- id = tables.LinkColumn('edit_recipe', args=[A('id')])
+ id = tables.LinkColumn('edit_category', args=[A('id')])
class Meta:
model = Category
@@ -29,9 +29,18 @@ class CategoryTable(tables.Table):
class KeywordTable(tables.Table):
- id = tables.LinkColumn('edit_recipe', args=[A('id')])
+ id = tables.LinkColumn('edit_keyword', args=[A('id')])
class Meta:
model = Keyword
template_name = 'generic/table_template.html'
fields = ('id', 'name')
+
+
+class MonitoredPathTable(tables.Table):
+ edit = tables.TemplateColumn("Löschen")
+
+ class Meta:
+ model = Keyword
+ template_name = 'generic/table_template.html'
+ fields = ('path', 'last_checked')
diff --git a/cookbook/templates/batch/import.html b/cookbook/templates/batch/import.html
index 3de2d55d..131ca696 100644
--- a/cookbook/templates/batch/import.html
+++ b/cookbook/templates/batch/import.html
@@ -9,11 +9,13 @@
{% trans 'Import Recipes' %}
- {% trans 'Import Recipes from Dropbox Storage' %}
+ {% trans 'Manage all paths that should be imported' %}
-
+
+ {% render_table monitored_paths %}
+
{% endblock %}
\ No newline at end of file
diff --git a/cookbook/templates/generic/delete_template.html b/cookbook/templates/generic/delete_template.html
new file mode 100644
index 00000000..478fc811
--- /dev/null
+++ b/cookbook/templates/generic/delete_template.html
@@ -0,0 +1,20 @@
+{% extends "base.html" %}
+{% load crispy_forms_tags %}
+{% load i18n %}
+
+{% block title %}{% trans 'Delete' %}{% endblock %}
+
+{% block content %}
+
+
+ {% trans 'Delete' %}
+ {% trans 'Delete this Object' %}
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/cookbook/templates/generic/edit_template.html b/cookbook/templates/generic/edit_template.html
new file mode 100644
index 00000000..affe89e9
--- /dev/null
+++ b/cookbook/templates/generic/edit_template.html
@@ -0,0 +1,20 @@
+{% extends "base.html" %}
+{% load crispy_forms_tags %}
+{% load i18n %}
+
+{% block title %}{% trans 'Edit' %}{% endblock %}
+
+{% block content %}
+
+
+ {% trans 'Edit' %}
+ {% trans 'Edit this Object' %}
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/cookbook/urls.py b/cookbook/urls.py
index 85ad088b..01d4dddb 100644
--- a/cookbook/urls.py
+++ b/cookbook/urls.py
@@ -12,11 +12,14 @@ urlpatterns = [
path('new/keyword', new.keyword, name='new_keyword'),
path('edit/recipe//', edit.recipe, name='edit_recipe'),
- path('edit/category//', edit.category, name='edit_category'),
- path('edit/keyword//', edit.keyword, name='edit_keyword'),
+
+ 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('batch/import', batch.batch_import, name='batch_import'),
path('batch/category', batch.batch_edit, name='batch_edit'),
path('api/get_file_link//', api.get_file_link, name='get_file_link'),
]
+
diff --git a/cookbook/views/api.py b/cookbook/views/api.py
index e5fb598a..3447d977 100644
--- a/cookbook/views/api.py
+++ b/cookbook/views/api.py
@@ -1,9 +1,12 @@
from django.http import HttpResponse
+from django.contrib.auth.decorators import login_required
+
from cookbook.models import Recipe
from cookbook.helper import dropbox
+@login_required
def get_file_link(request, recipe_id):
recipe = Recipe.objects.get(id=recipe_id)
if recipe.link == "":
diff --git a/cookbook/views/batch.py b/cookbook/views/batch.py
index 32cafe9b..bdf54cd5 100644
--- a/cookbook/views/batch.py
+++ b/cookbook/views/batch.py
@@ -1,9 +1,13 @@
+from datetime import datetime
+
from django.contrib.auth.decorators import login_required
from django.shortcuts import redirect, render
+from django_tables2 import RequestConfig
from cookbook.forms import ImportForm, BatchEditForm
from cookbook.helper import dropbox
-from cookbook.models import Recipe, Category
+from cookbook.models import Recipe, Category, Monitor
+from cookbook.tables import MonitoredPathTable
@login_required
@@ -11,12 +15,18 @@ def batch_import(request):
if request.method == "POST":
form = ImportForm(request.POST)
if form.is_valid():
- dropbox.import_all(form.cleaned_data['path'])
- return redirect('index')
+ new_path = Monitor()
+ new_path.path = form.cleaned_data['path']
+ new_path.last_checked = datetime.now()
+ new_path.save()
+ return redirect('batch_import')
else:
form = ImportForm()
- return render(request, 'batch/import.html', {'form': form})
+ monitored_paths = MonitoredPathTable(Monitor.objects.all())
+ RequestConfig(request, paginate={'per_page': 25}).configure(monitored_paths)
+
+ return render(request, 'batch/import.html', {'form': form, 'monitored_paths': monitored_paths})
@login_required
diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py
index 1367b387..7df5531a 100644
--- a/cookbook/views/edit.py
+++ b/cookbook/views/edit.py
@@ -1,11 +1,31 @@
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
from django.utils.translation import gettext as _
+from django.views.generic import UpdateView
from cookbook.forms import EditRecipeForm
-from cookbook.models import Recipe, Category
+from cookbook.models import Recipe, Category, Monitor, Keyword
+
+
+class MonitorUpdate(LoginRequiredMixin, UpdateView):
+ template_name = "generic\edit_template.html"
+ model = Monitor
+ fields = ['path']
+
+
+class CategoryUpdate(LoginRequiredMixin, UpdateView):
+ template_name = "generic\edit_template.html"
+ model = Category
+ fields = ['name', 'description']
+
+
+class KeywordUpdate(LoginRequiredMixin, UpdateView):
+ template_name = "generic\edit_template.html"
+ model = Keyword
+ fields = ['name', 'description']
@login_required
@@ -28,13 +48,3 @@ def recipe(request, recipe_id):
form = EditRecipeForm(instance=recipe_obj)
return render(request, 'edit/recipe.html', {'form': form})
-
-
-@login_required
-def category(request, category_id):
- return render(request, 'index.html')
-
-
-@login_required
-def keyword(request, keyword_id):
- return render(request, 'index.html')
diff --git a/cookbook/views/views.py b/cookbook/views/views.py
index 27a21bcb..c7a70c85 100644
--- a/cookbook/views/views.py
+++ b/cookbook/views/views.py
@@ -1,11 +1,9 @@
-from django.contrib.auth.decorators import login_required
-from django.shortcuts import render, redirect
+from django.shortcuts import render
from django_tables2 import RequestConfig
from cookbook.filters import RecipeFilter
from cookbook.forms import *
-from cookbook.helper import dropbox
-from cookbook.tables import RecipeTable, CategoryTable, KeywordTable
+from cookbook.tables import RecipeTable
def index(request):
diff --git a/recipes/settings.py b/recipes/settings.py
index 9b96e84d..59d90442 100644
--- a/recipes/settings.py
+++ b/recipes/settings.py
@@ -98,7 +98,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
-LANGUAGE_CODE = 'en-us'
+LANGUAGE_CODE = 'DE-de'
TIME_ZONE = 'UTC'