diff --git a/schickmacher/renderer/forms.py b/schickmacher/renderer/forms.py index 4817a29..077259f 100644 --- a/schickmacher/renderer/forms.py +++ b/schickmacher/renderer/forms.py @@ -6,6 +6,7 @@ from markdownx.fields import MarkdownxFormField class RendererForm(forms.Form): title = forms.CharField(label=_('Title'), required=False) + show_title = forms.BooleanField(label=_('Show Title'), required=False) date = forms.DateField(label=_('Date'), initial=lambda: timezone.now().strftime('%Y-%m-%d'), widget=forms.TextInput( @@ -14,3 +15,7 @@ class RendererForm(forms.Form): render_content = MarkdownxFormField( label=_('Content'), ) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields['show_title'].initial = True diff --git a/schickmacher/renderer/tests/test_views.py b/schickmacher/renderer/tests/test_views.py index 6860527..a07428e 100644 --- a/schickmacher/renderer/tests/test_views.py +++ b/schickmacher/renderer/tests/test_views.py @@ -24,3 +24,23 @@ class TestRendererFormView: assert b'Example' in response.content assert response.content.startswith(b'%PDF') + def test_html_render(self, client: Client): + response = client.post('/renderer/renderhtml', data={ + 'title': 'Sample Title', + 'date': '2009-11-15', + 'render_content': '# Example', + 'show_title': 'on', + }) + assert b'Sample Title' in response.content + assert b'