recipes view
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load class_tag %}
|
{% load custom_tags %}
|
||||||
|
|
||||||
{% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %}
|
{% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load class_tag %}
|
{% load custom_tags %}
|
||||||
|
|
||||||
{% block title %}{% trans 'New' %} - {{ title }}{% endblock %}
|
{% block title %}{% trans 'New' %} - {{ title }}{% endblock %}
|
||||||
|
|
||||||
|
14
cookbook/templates/recipe_view.html
Normal file
14
cookbook/templates/recipe_view.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load custom_tags %}
|
||||||
|
|
||||||
|
{% block title %}{% trans 'View' %}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h3>{{ recipe.name }}</h3>
|
||||||
|
|
||||||
|
{{ recipe.instructions | markdown | safe }}
|
||||||
|
|
||||||
|
{% endblock %}
|
@ -1,4 +1,5 @@
|
|||||||
from django import template
|
from django import template
|
||||||
|
import markdown as md
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@ -6,3 +7,8 @@ register = template.Library()
|
|||||||
@register.filter(name='get_class')
|
@register.filter(name='get_class')
|
||||||
def get_class(value):
|
def get_class(value):
|
||||||
return value.__class__.__name__
|
return value.__class__.__name__
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter()
|
||||||
|
def markdown(value):
|
||||||
|
return md.markdown(value, extensions=['markdown.extensions.fenced_code'])
|
@ -8,6 +8,8 @@ urlpatterns = [
|
|||||||
path('', views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
path('test', views.test, name='test'),
|
path('test', views.test, name='test'),
|
||||||
|
|
||||||
|
path('view/recipe/<int:pk>', views.recipe_view, name='view_recipe'),
|
||||||
|
|
||||||
path('new/recipe/', new.RecipeCreate.as_view(), name='new_recipe'),
|
path('new/recipe/', new.RecipeCreate.as_view(), name='new_recipe'),
|
||||||
path('new/recipe_import/<int:import_id>/', new.create_new_external_recipe, name='new_recipe_import'),
|
path('new/recipe_import/<int:import_id>/', new.create_new_external_recipe, name='new_recipe_import'),
|
||||||
path('new/keyword/', new.KeywordCreate.as_view(), name='new_keyword'),
|
path('new/keyword/', new.KeywordCreate.as_view(), name='new_keyword'),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from django.shortcuts import render
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django_tables2 import RequestConfig
|
from django_tables2 import RequestConfig
|
||||||
|
|
||||||
from cookbook.filters import RecipeFilter
|
from cookbook.filters import RecipeFilter
|
||||||
@ -18,5 +19,11 @@ def index(request):
|
|||||||
return render(request, 'index.html')
|
return render(request, 'index.html')
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def recipe_view(request, pk):
|
||||||
|
recipe = get_object_or_404(Recipe, pk=pk)
|
||||||
|
return render(request, 'recipe_view.html', {'recipe': recipe})
|
||||||
|
|
||||||
|
|
||||||
def test(request):
|
def test(request):
|
||||||
return render(request, 'test.html')
|
return render(request, 'test.html')
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
six
|
six
|
||||||
requests
|
requests
|
||||||
|
markdown
|
||||||
django
|
django
|
||||||
django-tables2
|
django-tables2
|
||||||
django-filter
|
django-filter
|
||||||
|
Reference in New Issue
Block a user