diff --git a/cookbook/forms.py b/cookbook/forms.py index 811b31f1..88e26abb 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -45,6 +45,8 @@ class InternalRecipeForm(forms.ModelForm): class CommentForm(forms.ModelForm): + prefix = 'comment' + class Meta: model = Comment fields = ('text',) @@ -82,6 +84,14 @@ class RecipeBookForm(forms.ModelForm): fields = ('name',) +class RecipeBookEntryForm(forms.ModelForm): + prefix = 'bookmark' + + class Meta: + model = RecipeBookEntry + fields = ('book',) + + class SyncForm(forms.ModelForm): class Meta: model = Sync diff --git a/cookbook/models.py b/cookbook/models.py index 86a4f320..0e549f43 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -102,7 +102,13 @@ class RecipeBook(models.Model): name = models.CharField(max_length=128) user = models.ForeignKey(User, on_delete=models.CASCADE) + def __str__(self): + return self.name + class RecipeBookEntry(models.Model): recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE) book = models.ForeignKey(RecipeBook, on_delete=models.CASCADE) + + def __str__(self): + return self.recipe.name diff --git a/cookbook/templates/books.html b/cookbook/templates/books.html index b207c1ff..f2ff3baf 100644 --- a/cookbook/templates/books.html +++ b/cookbook/templates/books.html @@ -29,13 +29,22 @@
- Test - {% for r in b.recipes %} - {{ r }} - {% endfor %} + {% if b.recipes %} + + + {% else %} + {% trans 'There are no recipes in this book yet.' %} + + {% endif %}

{% endfor %} + + {% include 'include/recipe_open_modal.html' %} {% endblock %} \ No newline at end of file diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 84f4fedb..662c5ae2 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -12,8 +12,16 @@ {% endblock %} {% block content %} +
+
+

{{ recipe.name }}

+
+
+ +
+
-

{{ recipe.name }}

{% if recipe.storage %} {% trans 'in' %} {{ recipe.storage.name }}
@@ -125,7 +133,7 @@
{% csrf_token %}
- +
@@ -147,10 +155,36 @@ {% include 'include/recipe_open_modal.html' %} {% endif %} + + +