Add basic form

This commit is contained in:
Jens Kadenbach 2019-09-05 12:20:45 +02:00
parent 6da103b148
commit 8b16fe573c
14 changed files with 424 additions and 11 deletions

View file

@ -73,6 +73,7 @@ THIRD_PARTY_APPS = [
LOCAL_APPS = [ LOCAL_APPS = [
"schickmacher.users.apps.UsersConfig", "schickmacher.users.apps.UsersConfig",
"schickmacher.renderer.apps.RendererConfig",
# Your stuff: custom apps go here # Your stuff: custom apps go here
] ]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps # https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
@ -246,7 +247,7 @@ LOGGING = {
# django-allauth # django-allauth
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", True) ACCOUNT_ALLOW_REGISTRATION = env.bool("DJANGO_ACCOUNT_ALLOW_REGISTRATION", False)
# https://django-allauth.readthedocs.io/en/latest/configuration.html # https://django-allauth.readthedocs.io/en/latest/configuration.html
ACCOUNT_AUTHENTICATION_METHOD = "username" ACCOUNT_AUTHENTICATION_METHOD = "username"
# https://django-allauth.readthedocs.io/en/latest/configuration.html # https://django-allauth.readthedocs.io/en/latest/configuration.html

View file

@ -1,12 +1,12 @@
from django.conf import settings from django.conf import settings
from django.urls import include, path from django.urls import include, path, reverse_lazy
from django.conf.urls.static import static from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.views.generic import TemplateView from django.views.generic import TemplateView, RedirectView
from django.views import defaults as default_views from django.views import defaults as default_views
urlpatterns = [ urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"), path("", RedirectView.as_view(url=reverse_lazy('renderer:form')), name="home"),
path( path(
"about/", TemplateView.as_view(template_name="pages/about.html"), name="about" "about/", TemplateView.as_view(template_name="pages/about.html"), name="about"
), ),
@ -14,6 +14,7 @@ urlpatterns = [
path(settings.ADMIN_URL, admin.site.urls), path(settings.ADMIN_URL, admin.site.urls),
# User management # User management
path("users/", include("schickmacher.users.urls", namespace="users")), path("users/", include("schickmacher.users.urls", namespace="users")),
path("renderer/", include("schickmacher.renderer.urls", namespace="renderer")),
path("accounts/", include("allauth.urls")), path("accounts/", include("allauth.urls")),
# Your stuff: custom urls includes go here # Your stuff: custom urls includes go here
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

0
locale/README.rst Normal file → Executable file
View file

305
locale/de/LC_MESSAGES/django.po Executable file
View file

@ -0,0 +1,305 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-09-05 08:52+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: schickmacher/renderer/apps.py:7
msgid "Renderer"
msgstr "Renderer"
#: schickmacher/renderer/forms.py:6
msgid "Date"
msgstr "Datum"
#: schickmacher/templates/account/account_inactive.html:5
#: schickmacher/templates/account/account_inactive.html:8
msgid "Account Inactive"
msgstr "Account Inaktiv"
#: schickmacher/templates/account/account_inactive.html:10
msgid "This account is inactive."
msgstr "Dieser Account ist deaktiviert"
#: schickmacher/templates/account/email.html:7
msgid "Account"
msgstr "Account"
#: schickmacher/templates/account/email.html:10
msgid "E-mail Addresses"
msgstr "E-Mail Adressen"
#: schickmacher/templates/account/email.html:13
msgid "The following e-mail addresses are associated with your account:"
msgstr "Die folgenden E-Mail Adressen gehören zu ihrem Account"
#: schickmacher/templates/account/email.html:27
msgid "Verified"
msgstr "Verifiziert"
#: schickmacher/templates/account/email.html:29
msgid "Unverified"
msgstr "Nicht verifiziert"
#: schickmacher/templates/account/email.html:31
msgid "Primary"
msgstr "Primär"
#: schickmacher/templates/account/email.html:37
msgid "Make Primary"
msgstr "Als primär festlegen"
#: schickmacher/templates/account/email.html:38
msgid "Re-send Verification"
msgstr "Verifikation erneut versenden"
#: schickmacher/templates/account/email.html:39
msgid "Remove"
msgstr "Entfernen"
#: schickmacher/templates/account/email.html:46
msgid "Warning:"
msgstr "Warnung:"
#: schickmacher/templates/account/email.html:46
msgid ""
"You currently do not have any e-mail address set up. You should really add "
"an e-mail address so you can receive notifications, reset your password, etc."
msgstr ""
"Sie haben zurzeit keine E-Mail Adressen eingerichtet. Sie sollten eine E-Mail "
"Adresse einrichten um Benachrichtigungen zu erhalten, ihr Passwort zurückzusetpen, etc."
#: schickmacher/templates/account/email.html:51
msgid "Add E-mail Address"
msgstr "E-Mail Adresse hinzufügen"
#: schickmacher/templates/account/email.html:56
msgid "Add E-mail"
msgstr "E-Mail hinzufügen"
#: schickmacher/templates/account/email.html:66
msgid "Do you really want to remove the selected e-mail address?"
msgstr "Möchten sie die E-Mail Adresse wirklich entfernen?"
#: schickmacher/templates/account/email_confirm.html:6
#: schickmacher/templates/account/email_confirm.html:10
msgid "Confirm E-mail Address"
msgstr "E-Mail Adresse bestätigen"
#: schickmacher/templates/account/email_confirm.html:16
#, python-format
msgid ""
"Please confirm that <a href=\"mailto:%(email)s\">%(email)s</a> is an e-mail "
"address for user %(user_display)s."
msgstr ""
#: schickmacher/templates/account/email_confirm.html:20
msgid "Confirm"
msgstr ""
#: schickmacher/templates/account/email_confirm.html:27
#, python-format
msgid ""
"This e-mail confirmation link expired or is invalid. Please <a href="
"\"%(email_url)s\">issue a new e-mail confirmation request</a>."
msgstr ""
#: schickmacher/templates/account/login.html:7
#: schickmacher/templates/account/login.html:11
#: schickmacher/templates/account/login.html:44
#: schickmacher/templates/base.html:68
msgid "Sign In"
msgstr ""
#: schickmacher/templates/account/login.html:16
#, python-format
msgid ""
"Please sign in with one\n"
"of your existing third party accounts. Or, <a href=\"%(signup_url)s\">sign "
"up</a>\n"
"for a %(site_name)s account and sign in below:"
msgstr ""
#: schickmacher/templates/account/login.html:26
msgid "or"
msgstr ""
#: schickmacher/templates/account/login.html:33
#, python-format
msgid ""
"If you have not created an account yet, then please\n"
"<a href=\"%(signup_url)s\">sign up</a> first."
msgstr ""
#: schickmacher/templates/account/login.html:43
msgid "Forgot Password?"
msgstr ""
#: schickmacher/templates/account/logout.html:5
#: schickmacher/templates/account/logout.html:8
#: schickmacher/templates/account/logout.html:17
#: schickmacher/templates/base.html:59
msgid "Sign Out"
msgstr ""
#: schickmacher/templates/account/logout.html:10
msgid "Are you sure you want to sign out?"
msgstr ""
#: schickmacher/templates/account/password_change.html:6
#: schickmacher/templates/account/password_change.html:9
#: schickmacher/templates/account/password_change.html:14
#: schickmacher/templates/account/password_reset_from_key.html:5
#: schickmacher/templates/account/password_reset_from_key.html:8
#: schickmacher/templates/account/password_reset_from_key_done.html:4
#: schickmacher/templates/account/password_reset_from_key_done.html:7
msgid "Change Password"
msgstr ""
#: schickmacher/templates/account/password_reset.html:7
#: schickmacher/templates/account/password_reset.html:11
#: schickmacher/templates/account/password_reset_done.html:6
#: schickmacher/templates/account/password_reset_done.html:9
msgid "Password Reset"
msgstr ""
#: schickmacher/templates/account/password_reset.html:16
msgid ""
"Forgotten your password? Enter your e-mail address below, and we'll send you "
"an e-mail allowing you to reset it."
msgstr ""
#: schickmacher/templates/account/password_reset.html:21
msgid "Reset My Password"
msgstr ""
#: schickmacher/templates/account/password_reset.html:24
msgid "Please contact us if you have any trouble resetting your password."
msgstr ""
#: schickmacher/templates/account/password_reset_done.html:15
msgid ""
"We have sent you an e-mail. Please contact us if you do not receive it "
"within a few minutes."
msgstr ""
#: schickmacher/templates/account/password_reset_from_key.html:8
msgid "Bad Token"
msgstr ""
#: schickmacher/templates/account/password_reset_from_key.html:12
#, python-format
msgid ""
"The password reset link was invalid, possibly because it has already been "
"used. Please request a <a href=\"%(passwd_reset_url)s\">new password reset</"
"a>."
msgstr ""
#: schickmacher/templates/account/password_reset_from_key.html:18
msgid "change password"
msgstr ""
#: schickmacher/templates/account/password_reset_from_key.html:21
#: schickmacher/templates/account/password_reset_from_key_done.html:8
msgid "Your password is now changed."
msgstr ""
#: schickmacher/templates/account/password_set.html:6
#: schickmacher/templates/account/password_set.html:9
#: schickmacher/templates/account/password_set.html:14
msgid "Set Password"
msgstr ""
#: schickmacher/templates/account/signup.html:6
msgid "Signup"
msgstr ""
#: schickmacher/templates/account/signup.html:9
#: schickmacher/templates/account/signup.html:19
#: schickmacher/templates/base.html:64
msgid "Sign Up"
msgstr ""
#: schickmacher/templates/account/signup.html:11
#, python-format
msgid ""
"Already have an account? Then please <a href=\"%(login_url)s\">sign in</a>."
msgstr ""
#: schickmacher/templates/account/signup_closed.html:5
#: schickmacher/templates/account/signup_closed.html:8
msgid "Sign Up Closed"
msgstr ""
#: schickmacher/templates/account/signup_closed.html:10
msgid "We are sorry, but the sign up is currently closed."
msgstr ""
#: schickmacher/templates/account/verification_sent.html:5
#: schickmacher/templates/account/verification_sent.html:8
#: schickmacher/templates/account/verified_email_required.html:5
#: schickmacher/templates/account/verified_email_required.html:8
msgid "Verify Your E-mail Address"
msgstr ""
#: schickmacher/templates/account/verification_sent.html:10
msgid ""
"We have sent an e-mail to you for verification. Follow the link provided to "
"finalize the signup process. Please contact us if you do not receive it "
"within a few minutes."
msgstr ""
#: schickmacher/templates/account/verified_email_required.html:12
msgid ""
"This part of the site requires us to verify that\n"
"you are who you claim to be. For this purpose, we require that you\n"
"verify ownership of your e-mail address. "
msgstr ""
#: schickmacher/templates/account/verified_email_required.html:16
msgid ""
"We have sent an e-mail to you for\n"
"verification. Please click on the link inside this e-mail. Please\n"
"contact us if you do not receive it within a few minutes."
msgstr ""
#: schickmacher/templates/account/verified_email_required.html:20
#, python-format
msgid ""
"<strong>Note:</strong> you can still <a href=\"%(email_url)s\">change your e-"
"mail address</a>."
msgstr ""
#: schickmacher/templates/base.html:55
msgid "My Profile"
msgstr ""
#: schickmacher/users/apps.py:7
msgid "Users"
msgstr ""
#: schickmacher/users/forms.py:16
msgid "This username has already been taken."
msgstr ""
#: schickmacher/users/models.py:11
msgid "Name of User"
msgstr ""
#: schickmacher/users/views.py:34
msgid "Infos successfully updated"
msgstr ""

View file

View file

@ -0,0 +1,13 @@
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class RendererConfig(AppConfig):
name = "schickmacher.renderer"
verbose_name = _("Renderer")
def ready(self):
try:
import schickmacher.renderer.signals # noqa F401
except ImportError:
pass

View file

@ -0,0 +1,15 @@
from django.utils.translation import ugettext_lazy as _
from django import forms
from django.utils import timezone
class RendererForm(forms.Form):
date = forms.DateField(label=_('Date'),
initial=lambda: timezone.now().strftime('%Y-%m-%d'),
widget=forms.TextInput(
attrs={'type': 'date'}
))
render_content = forms.CharField(
label=_('Content'), widget=forms.Textarea, max_length=None,
required=False, initial=""
)

View file

@ -0,0 +1,16 @@
from datetime import datetime
import pytest
from django.utils import timezone
from schickmacher.renderer.forms import RendererForm
class TestRendererForm:
def test_form_accepts_content(self):
form = RendererForm({
"date": timezone.now(),
"render_content": "Example **content**"
})
assert form.is_valid()

View file

@ -0,0 +1,8 @@
import pytest
from django.urls import reverse, resolve
def test_form():
assert reverse('renderer:form') == '/renderer/'
assert resolve('/renderer/').view_name == 'renderer:form'

View file

@ -0,0 +1,15 @@
import pytest
from django.test import Client
from django.utils import timezone
pytestmark = pytest.mark.django_db
class TestRendererFormView:
def test_get_empty_form(self, client: Client):
response = client.get('/renderer/')
assert response.status_code == 200
assert response.context['form']['date'].value() \
== timezone.now().strftime('%Y-%m-%d')

View file

@ -0,0 +1,8 @@
from django.urls import path
from schickmacher.renderer.views import form_view
app_name = 'renderer'
urlpatterns = [
path("", view=form_view, name="form")
]

View file

@ -0,0 +1,9 @@
from django.core.handlers.wsgi import WSGIRequest
from django.shortcuts import render
from schickmacher.renderer.forms import RendererForm
def form_view(request: WSGIRequest):
ctx = {"form": RendererForm()}
return render(request, 'renderer/render_form.html', ctx)

View file

@ -16,17 +16,17 @@
<link rel="icon" href="{% static 'images/favicons/favicon.ico' %}"> <link rel="icon" href="{% static 'images/favicons/favicon.ico' %}">
{% block css %} {% block css %}
<!-- Latest compiled and minified Bootstrap CSS --> <!-- Latest compiled and minified Bootstrap CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Your stuff: Third-party CSS libraries go here --> <!-- Your stuff: Third-party CSS libraries go here -->
{% compress css %} {% compress css %}
<!-- This file stores project-specific CSS --> <!-- This file stores project-specific CSS -->
<link href="{% static 'css/project.css' %}" rel="stylesheet"> <link href="{% static 'css/project.css' %}" rel="stylesheet">
{% endcompress %} {% endcompress %}
{% endblock %} {% endblock %}
@ -46,6 +46,9 @@
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="{% url 'home' %}">Home <span class="sr-only">(current)</span></a> <a class="nav-link" href="{% url 'home' %}">Home <span class="sr-only">(current)</span></a>
</li> </li>
<li class="nav-item">
<a class="nav-link" href="{% url 'renderer:form' %}">Renderer</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{% url 'about' %}">About</a> <a class="nav-link" href="{% url 'about' %}">About</a>
</li> </li>
@ -94,14 +97,14 @@
================================================== --> ================================================== -->
<!-- Placed at the end of the document so the pages load faster --> <!-- Placed at the end of the document so the pages load faster -->
{% block javascript %} {% block javascript %}
<!-- Bootstrap JS and its dependencies--> <!-- Bootstrap JS and its dependencies-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- Your stuff: Third-party javascript libraries go here --> <!-- Your stuff: Third-party javascript libraries go here -->
<!-- place project specific Javascript in this file --> <!-- place project specific Javascript in this file -->
{% compress js %} {% compress js %}
@ -111,4 +114,4 @@
{% endblock javascript %} {% endblock javascript %}
</body> </body>
</html> </html>

View file

@ -0,0 +1,19 @@
{% extends "base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% trans "Renderer" %}{% endblock %}
{% block content %}
<h1>{% trans "Renderer" %}</h1>
<form class="form-horizontal" method="post" action="{% url 'renderer:form' %}">
{% csrf_token %}
{{ form|crispy }}
<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">{% trans "Compile" %}</button>
</div>
</div>
</form>
{% endblock %}