Skip to content

Commit

Permalink
Merge pull request #497 from smilerz/recipe_description
Browse files Browse the repository at this point in the history
Recipe description
  • Loading branch information
vabene1111 authored Mar 18, 2021
2 parents 69a51e0 + ce8524b commit 6ab8d6b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cookbook/static/vue/js/recipe_view.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cookbook/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Meta:
model = Recipe
template_name = 'recipes_table.html'
fields = (
'id', 'name', 'all_tags', 'image', 'instructions',
'id', 'name', 'all_tags', 'description', 'image', 'instructions',
'working_time', 'waiting_time', 'internal'
)

Expand Down
23 changes: 10 additions & 13 deletions cookbook/templates/forms/edit_internal_recipe.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ <h3>{% trans 'Edit Recipe' %}</h3>
<input class="form-control" id="id_name" v-model="recipe.name">
</div>
</div>
<div class="row">
<div class="col-12">
<label for="id_description">
{% trans 'Description' %}
</label>
<textarea id="id_description" class="form-control" v-model="recipe.description"
maxlength="512"></textarea>

</div>
</div>
<br/>

<div class="row">
Expand Down Expand Up @@ -90,19 +100,6 @@ <h3>{% trans 'Edit Recipe' %}</h3>
</div>
</div>

<div class="row">
<div class="col-12">
<label for="id_description">
{% trans 'Description' %}
</label>
<textarea id="id_description" class="form-control" v-model="recipe.description"
maxlength="512"></textarea>

</div>

</div>


<template v-if="recipe !== undefined">
<div class="row" v-if="recipe.nutrition" style="margin-top: 1vh">
<div class="col-md-12">
Expand Down
15 changes: 12 additions & 3 deletions cookbook/templates/recipes_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
{% block table %}
<table {% render_attrs table.attrs class="table" %}>
{% for row in table.paginated_rows %}
<div class="card" style="margin-top: 2px;">
<div class="card" style="margin-top: 1px;">
<div class="row no-gutters">
<div class="col-md-4">
<a href="{% url 'view_recipe' row.cells.id %}">
{% if row.cells.image|length > 1 %}
<img src=" {{ row.cells.image }}" alt="{% trans 'Recipe Image' %}"
class="card-img" style="object-fit: cover;height: 130px">
class="card-img" style="object-fit:cover;height: 160px">
{% else %}
<img src="{% static 'assets/recipe_no_image.svg' %}"
alt="{% trans 'Recipe Image' %}"
Expand All @@ -31,10 +31,15 @@
<div class="card-body">
<div class="d-flex">
<div class="flex-fill">
<h5 class="card-title">{{ row.cells.name }}
<h5 class="card-title p-0 m-0">{{ row.cells.name }}
{% recipe_rating row.record request.user as rating %}
{{ rating|safe }}
</h5>
{%if row.record.description|length > 0 %}
<p class="card-subtitle p-0 m-0 text-muted" style="height:3em; overflow:hidden;">
{{ row.cells.description }}
</p>
{% endif %}
<p class="card-text{% if not row.record.keywords %} d-none d-lg-block{% endif %}">
{% for x in row.record.keywords.all %}
<span class="badge badge-pill badge-light">{{ x }}</span>
Expand Down Expand Up @@ -80,6 +85,10 @@ <h5 class="card-title">{{ row.cells.name }}
onclick="openCookLogModal({{ row.record.pk }})"><i
class="fas fa-clipboard-list fa-fw"></i> {% trans 'Log Cooking' %}
</button>
<a class="dropdown-item"
href="{% url 'delete_recipe' row.record.pk %}"><i
class="fas fa-trash fa-fw"></i> {% trans 'Delete' %}
</a>

</div>
</div>
Expand Down
14 changes: 14 additions & 0 deletions cookbook/templates/url_import.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
<input id="id_name" class="form-control" v-model="recipe_data.name">
</div>

<div class="form-group">
<label for="id_description">{% trans 'Recipe Description' %}</label>
<textarea id="id_description" class="form-control" v-model="recipe_data.description"
rows="4"></textarea>
</div>

<div class="row">
<div class="col col-md-6" v-if="recipe_data.image !== ''">
<img v-bind:src="recipe_data.image" alt="{% trans 'Recipe Image' %}"
Expand Down Expand Up @@ -351,6 +357,14 @@ <h5 class="card-title">{% trans 'Information' %}</h5>
})
},
importRecipe: function () {
if (this.recipe_data.name.length > 128) {
this.makeToast(gettext('Error'), gettext('Recipe name is longer than 128 characters'), 'danger')
return;
}
if (this.recipe_data.description.length > 512) {
this.makeToast(gettext('Error'), gettext('Recipe description is longer than 512 characters'), 'danger')
return;
}
if (this.importing_recipe) {
this.makeToast(gettext('Error'), gettext('Already importing the selected recipe, please wait!'), 'danger')
return;
Expand Down
1 change: 1 addition & 0 deletions cookbook/views/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def import_url(request):

recipe = Recipe.objects.create(
name=data['name'],
description=data['description'],
waiting_time=data['cookTime'],
working_time=data['prepTime'],
servings=data['servings'],
Expand Down
10 changes: 5 additions & 5 deletions vue/src/apps/RecipeView/RecipeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
</div>
</div>

<div style="text-align: center">
<keywords :recipe="recipe"></keywords>
</div>

<div class="row" style="margin-top: 8px">
<div class="my-auto">
<div class="col-12" style="text-align: center">
<i>{{ recipe.description }}</i>
</div>
</div>

<div style="text-align: center">
<keywords :recipe="recipe"></keywords>
</div>

<hr/>
<div class="row">
<div class="col col-md-3">
Expand Down

0 comments on commit 6ab8d6b

Please sign in to comment.