diff --git a/cookbook/forms.py b/cookbook/forms.py index 8a2e3e8f0..ecccd9d82 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -237,7 +237,9 @@ class ImportRecipeForm(forms.ModelForm): class RecipeBookForm(forms.ModelForm): class Meta: model = RecipeBook - fields = ('name',) + fields = ('name', 'icon', 'description') + + widgets = {'icon': EmojiPickerTextInput} class MealPlanForm(forms.ModelForm): diff --git a/cookbook/migrations/0038_auto_20200502_1259.py b/cookbook/migrations/0038_auto_20200502_1259.py new file mode 100644 index 000000000..0c0cf98d2 --- /dev/null +++ b/cookbook/migrations/0038_auto_20200502_1259.py @@ -0,0 +1,23 @@ +# Generated by Django 3.0.5 on 2020-05-02 10:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0037_userpreference_search_style'), + ] + + operations = [ + migrations.AddField( + model_name='recipebook', + name='description', + field=models.TextField(blank=True), + ), + migrations.AddField( + model_name='recipebook', + name='icon', + field=models.CharField(blank=True, max_length=16, null=True), + ), + ] diff --git a/cookbook/models.py b/cookbook/models.py index ce25d1e7a..8e3240aa6 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -195,6 +195,8 @@ class RecipeImport(models.Model): class RecipeBook(models.Model): name = models.CharField(max_length=128) + description = models.TextField(blank=True) + icon = models.CharField(max_length=16, blank=True, null=True) created_by = models.ForeignKey(User, on_delete=models.CASCADE) def __str__(self): diff --git a/cookbook/templates/books.html b/cookbook/templates/books.html index 32a95ebb8..9db0d957d 100644 --- a/cookbook/templates/books.html +++ b/cookbook/templates/books.html @@ -16,46 +16,48 @@

- {% for b in book_list %}
-
- -
-
-

- - - -

-
-
-
- -
-
-
- {% if b.recipes %} - - {% else %} - {% trans 'There are no recipes in this book yet.' %} - {% endif %} +
+
+
+
{% if b.book.icon %}{{ b.book.icon }} {% endif %}{{ b.book.name }}
+ {% if b.book.description %} +

{{ b.book.description }}

+ {% endif %} + + {% trans 'Edit' %} + {% trans 'Delete' %} +
+
+ {% if b.recipes %} + + {% else %} +
+

+ {% trans 'There are no recipes in this book yet.' %} +

+
+ {% endif %} +
-
{% endfor %} {% endblock %} \ No newline at end of file diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index 5c845b438..af7e91e19 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -14,7 +14,7 @@ from django.utils.translation import gettext as _ from django.views.generic import UpdateView from cookbook.forms import ExternalRecipeForm, KeywordForm, StorageForm, SyncForm, InternalRecipeForm, CommentForm, \ - MealPlanForm, UnitMergeForm, IngredientMergeForm, IngredientForm + MealPlanForm, UnitMergeForm, IngredientMergeForm, IngredientForm, RecipeBookForm from cookbook.helper.permission_helper import group_required, GroupRequiredMixin from cookbook.helper.permission_helper import OwnerRequiredMixin @@ -255,7 +255,7 @@ class ImportUpdate(GroupRequiredMixin, UpdateView): class RecipeBookUpdate(OwnerRequiredMixin, UpdateView): template_name = "generic/edit_template.html" model = RecipeBook - fields = ['name'] + form_class = RecipeBookForm def get_success_url(self): return reverse('view_books')