Views with example content
This commit is contained in:
parent
74869da4bc
commit
3c3456431a
3 changed files with 31 additions and 2 deletions
|
@ -1,10 +1,13 @@
|
|||
from django.urls import path
|
||||
|
||||
from schickmacher.renderer.views import form_view, RenderView, HtmlRenderView
|
||||
from schickmacher.renderer.views import form_view, RenderView,\
|
||||
HtmlRenderView, SampleHTMLView, SamplePDFView
|
||||
|
||||
app_name = 'renderer'
|
||||
urlpatterns = [
|
||||
path("", view=form_view, name="form"),
|
||||
path("render", view=RenderView.as_view(), name="render"),
|
||||
path("renderhtml", view=HtmlRenderView.as_view(), name="renderhtml"),
|
||||
path("samplehtml", view=SampleHTMLView.as_view(), name="samplehtml"),
|
||||
path("samplepdf", view=SamplePDFView.as_view(), name="samplepdf"),
|
||||
]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import FormView, TemplateView
|
||||
from django.views.generic import TemplateView
|
||||
from django_weasyprint import WeasyTemplateView
|
||||
from django.utils.timezone import datetime
|
||||
from markdownx.utils import markdownify
|
||||
|
||||
from schickmacher.renderer.forms import RendererForm
|
||||
|
@ -36,3 +37,22 @@ class HtmlRenderView(TemplateView):
|
|||
|
||||
class RenderView(HtmlRenderView, WeasyTemplateView):
|
||||
pass
|
||||
|
||||
|
||||
class SampleHTMLView(TemplateView):
|
||||
template_name = 'renderer/rendered.html'
|
||||
|
||||
sample_title = 'Test Title 123'
|
||||
sample_date = datetime.now()
|
||||
sample_content = markdownify(open('test.md').read())
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
return {
|
||||
'title': self.sample_title,
|
||||
'date': self.sample_date,
|
||||
'content': self.sample_content
|
||||
}
|
||||
|
||||
|
||||
class SamplePDFView(SampleHTMLView, WeasyTemplateView):
|
||||
pass
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'renderer:form' %}">Renderer</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'renderer:samplehtml' %}">Example HTML</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'renderer:samplepdf' %}">Example PDF</a>
|
||||
</li>
|
||||
{% if request.user.is_authenticated %}
|
||||
<li class="nav-item">
|
||||
{# URL provided by django-allauth/account/urls.py #}
|
||||
|
|
Loading…
Reference in a new issue