mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
display log info
This commit is contained in:
@@ -48,7 +48,8 @@
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col col-md-8">
|
||||
<h3>{{ recipe.name }} <a href="{% url 'edit_recipe' recipe.pk %}" class="d-print-none"><i
|
||||
{% recipe_rating recipe request.user as rating %}
|
||||
<h3>{{ recipe.name }} {{ rating|safe }} <a href="{% url 'edit_recipe' recipe.pk %}" class="d-print-none"><i
|
||||
class="fas fa-pencil-alt"></i></a></h3>
|
||||
</div>
|
||||
<div class="col col-md-4 d-print-none" style="text-align: right">
|
||||
@@ -64,7 +65,8 @@
|
||||
data-placement="top" title="{% trans 'Add to Mealplan' %}"><i
|
||||
class="fas fa-calendar"></i></a>
|
||||
<button class="btn btn-warning" onclick="openCookLogModal({{ recipe.pk }})" data-toggle="tooltip"
|
||||
data-placement="top" title="{% trans 'Log Cooking' %}"><i class="fas fa-clipboard-list"></i></button>
|
||||
data-placement="top" title="{% trans 'Log Cooking' %}"><i class="fas fa-clipboard-list"></i>
|
||||
</button>
|
||||
<a class="btn btn-light" onclick="window.print()" data-toggle="tooltip"
|
||||
data-placement="top" title="{% trans 'Print' %}"><i
|
||||
class="fas fa-print"></i></a>
|
||||
@@ -102,6 +104,10 @@
|
||||
class="badge badge-secondary"><i
|
||||
class="far fa-clock"></i> {% trans 'Waiting time ca.' %} {{ recipe.waiting_time }} min </span>
|
||||
{% endif %}
|
||||
{% recipe_last recipe request.user as last %}
|
||||
{% if last %}
|
||||
<span class="badge badge-primary">{% trans 'Last cooked' %} {{ last|date }}</span>
|
||||
{% endif %}
|
||||
|
||||
{% if recipe.waiting_time and recipe.waiting_time != 0 or recipe.working_time and recipe.working_time != 0 %}
|
||||
<br/>
|
||||
@@ -382,7 +388,7 @@
|
||||
});
|
||||
|
||||
function roundToTwo(num) {
|
||||
return +(Math.round(num + "e+2") + "e-2");
|
||||
return +(Math.round(num + "e+2") + "e-2");
|
||||
}
|
||||
|
||||
function reloadIngredients() {
|
||||
|
||||
@@ -20,14 +20,17 @@
|
||||
{% else %}
|
||||
<img src="{% static 'recipe_no_image.svg' %}"
|
||||
alt="{% trans 'Recipe Image' %}"
|
||||
class="card-img d-none d-lg-block" style="object-fit: inherit; height: 10vh">
|
||||
class="card-img d-none d-lg-block"
|
||||
style="object-fit: inherit; height: 10vh">
|
||||
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ row.cells.name }}</h5>
|
||||
<h5 class="card-title">{{ row.cells.name }}
|
||||
{% recipe_rating row.record request.user as rating %}
|
||||
{{ rating|safe }}
|
||||
</h5>
|
||||
<p class="card-text{% if not row.record.all_tags %} d-none d-lg-block{% endif %}">
|
||||
{{ row.cells.all_tags }}
|
||||
</p>
|
||||
@@ -41,11 +44,17 @@
|
||||
<span
|
||||
class="badge badge-secondary"><i
|
||||
class="far fa-clock"></i> {% trans 'Waiting time ca.' %} {{ row.cells.waiting_time }} min </span>
|
||||
{% endif %}{% if not row.record.internal %}
|
||||
<span class="badge badge-info">{% trans 'External' %} </span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if not row.record.internal %}
|
||||
<span class="badge badge-info">{% trans 'External' %} </span>
|
||||
{% endif %}
|
||||
{% recipe_last row.record request.user as last %}
|
||||
{% if last %}
|
||||
<span class="badge badge-primary">{% trans 'Last cooked' %} {{ last|date }}</span>
|
||||
{% endif %}
|
||||
<span class="badge badge-light">{{ row.cells.edit }}</span>
|
||||
<span class="badge badge-warning"><a href="#" style="color: inherit" onclick="openCookLogModal({{ row.record.pk }})">{% trans 'Log' %}</a></span>
|
||||
<span class="badge badge-warning"><a href="#" style="color: inherit"
|
||||
onclick="openCookLogModal({{ row.record.pk }})">{% trans 'Log' %}</a></span>
|
||||
</small></p>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from django import template
|
||||
import markdown as md
|
||||
import bleach
|
||||
from bleach_whitelist import markdown_tags, markdown_attrs, all_styles, print_attrs
|
||||
import markdown as md
|
||||
from bleach_whitelist import markdown_tags, markdown_attrs
|
||||
from django import template
|
||||
from django.db.models import Avg
|
||||
from django.urls import reverse
|
||||
|
||||
from cookbook.helper.mdx_attributes import MarkdownFormatExtension
|
||||
from cookbook.helper.mdx_urlize import UrlizeExtension
|
||||
from cookbook.models import get_model_name
|
||||
from cookbook.models import get_model_name, CookLog
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@@ -29,6 +30,32 @@ def delete_url(model, pk):
|
||||
@register.filter()
|
||||
def markdown(value):
|
||||
tags = markdown_tags + ['pre', 'table', 'td', 'tr', 'th', 'tbody', 'style', 'thead']
|
||||
parsed_md = md.markdown(value, extensions=['markdown.extensions.fenced_code', 'tables', UrlizeExtension(), MarkdownFormatExtension()])
|
||||
parsed_md = md.markdown(value, extensions=['markdown.extensions.fenced_code', 'tables', UrlizeExtension(), MarkdownFormatExtension()])
|
||||
markdown_attrs['*'] = markdown_attrs['*'] + ['class']
|
||||
return bleach.clean(parsed_md, tags, markdown_attrs)
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def recipe_rating(recipe, user):
|
||||
rating = recipe.cooklog_set.filter(created_by=user).aggregate(Avg('rating'))
|
||||
if rating['rating__avg']:
|
||||
|
||||
rating_stars = ''
|
||||
for i in range(int(rating['rating__avg'])):
|
||||
rating_stars = rating_stars + '<i class="fas fa-star fa-xs"></i>'
|
||||
|
||||
if rating['rating__avg'] % 1 >= 0.5:
|
||||
rating_stars = rating_stars + '<i class="fas fa-star-half-alt fa-xs"></i>'
|
||||
|
||||
return rating_stars
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def recipe_last(recipe, user):
|
||||
last = recipe.cooklog_set.filter(created_by=user).last()
|
||||
if last:
|
||||
return last.created_at
|
||||
else:
|
||||
return ''
|
||||
|
||||
Reference in New Issue
Block a user