From 8fcafcc25a0ef5244eddc0c6b0e55def595d569f Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 24 Dec 2019 15:06:58 +0100 Subject: [PATCH] bookmarks wip --- cookbook/forms.py | 6 +++ .../0005_recipebook_recipebookentry.py | 32 +++++++++++++++ cookbook/models.py | 10 +++++ cookbook/templates/base.html | 3 ++ cookbook/templates/books.html | 41 +++++++++++++++++++ cookbook/urls.py | 11 +++-- cookbook/views/new.py | 28 +++++++++++-- cookbook/views/views.py | 15 +++++-- 8 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 cookbook/migrations/0005_recipebook_recipebookentry.py create mode 100644 cookbook/templates/books.html diff --git a/cookbook/forms.py b/cookbook/forms.py index 621e02192..811b31f1e 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -76,6 +76,12 @@ class StorageForm(forms.ModelForm): fields = ('name', 'method', 'username', 'password', 'token', 'url') +class RecipeBookForm(forms.ModelForm): + class Meta: + model = RecipeBook + fields = ('name',) + + class SyncForm(forms.ModelForm): class Meta: model = Sync diff --git a/cookbook/migrations/0005_recipebook_recipebookentry.py b/cookbook/migrations/0005_recipebook_recipebookentry.py new file mode 100644 index 000000000..1f546a534 --- /dev/null +++ b/cookbook/migrations/0005_recipebook_recipebookentry.py @@ -0,0 +1,32 @@ +# Generated by Django 2.2.9 on 2019-12-24 11:14 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('cookbook', '0004_storage_created_by'), + ] + + operations = [ + migrations.CreateModel( + name='RecipeBook', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=128)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.CreateModel( + name='RecipeBookEntry', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('book', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cookbook.RecipeBook')), + ('recipe', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cookbook.Recipe')), + ], + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index e284d0328..86a4f3207 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -96,3 +96,13 @@ class RecipeImport(models.Model): def __str__(self): return self.name + + +class RecipeBook(models.Model): + name = models.CharField(max_length=128) + user = models.ForeignKey(User, on_delete=models.CASCADE) + + +class RecipeBookEntry(models.Model): + recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE) + book = models.ForeignKey(RecipeBook, on_delete=models.CASCADE) diff --git a/cookbook/templates/base.html b/cookbook/templates/base.html index 8337df5e9..c0eb00f46 100644 --- a/cookbook/templates/base.html +++ b/cookbook/templates/base.html @@ -72,6 +72,9 @@ {% trans 'Cookbook' %}(current) +