<commit_before>import wtforms
from wtforms import validators

from galerka.view import GalerkaView
from galerka.views.index import TitlePage
from galerka.util import asyncached
from galerka import forms


class RegistrationForm(forms.Form):
    username = wtforms.StringField(
        'Přezdívka',
        [
            validators.Length(min=2, max=30,
                              message='Jméno musí mít 2 až 30 znaků'),
            validators.DataRequired(message='Jméno je povinné'),
        ],
    )
    password = wtforms.PasswordField(
        '<PASSWORD>',
        [
            validators.Length(min=8,
                              message='Heslo by mělo mít minimálně 5 znaků'),
            validators.DataRequired(message='Heslo je povinné'),
        ],
    )
    password2 = wtforms.PasswordField(
        '<PASSWORD>',
        [validators.DataRequired(message='Kontrola hesla je povinná')],
    )


@TitlePage.child('users')
class UsersView(GalerkaView):
    @asyncached
    def title(self):
        return 'Uživatelé'

    @asyncached
    def rendered_contents(self):
        return '...'  # TODO


@UsersView.child('new')
class NewUserView(UsersView):
    @asyncached
    def title(self):
        return 'Nový účet'

    @asyncached
    def rendered_contents(self):
        self.form = form = RegistrationForm(prefix='newuser:')
        print(list(form))
        return (yield from self.render_template('user_new.mako'))<commit_msg>Add no-op POST action to the form<commit_after>import wtforms
from wtforms import validators
from werkzeug.wrappers import Response

from galerka.view import GalerkaView
from galerka.views.index import TitlePage
from galerka.util import asyncached
from galerka import forms


class RegistrationForm(forms.Form):
    username = wtforms.StringField(
        'Přezdívka',
        [
            validators.Length(min=2, max=30,
                              message='Jméno musí mít 2 až 30 znaků'),
            validators.DataRequired(message='Jméno je povinné'),
        ],
    )
    password = wtforms.PasswordField(
        '<PASSWORD>',
        [
            validators.Length(min=8,
                              message='Heslo by mělo mít minimálně 5 znaků'),
            validators.DataRequired(message='Heslo je povinné'),
            validators.EqualTo('password2',
                               message='Heslo a kontrola se musí shodovat'),
        ],
    )
    password2 = wtforms.PasswordField('<PASSWORD>')


@TitlePage.child('users')
class UsersView(GalerkaView):
    @asyncached
    def title(self):
        return 'Uživatelé'

    @asyncached
    def rendered_contents(self):
        return '...'  # TODO


@UsersView.child('new')
class NewUserView(UsersView):
    @asyncached
    def title(self):
        return 'Nový účet'

    @property
    def POST(self):
        self.form = form = RegistrationForm(self.request.form,
                                            prefix='newuser:')
        self.form_valid = form.validate()
        if self.form_valid:
            return super().POST
        else:
            rendered = yield from self.rendered_page
            return Response(rendered, mimetype='text/html')

    @asyncached
    def rendered_contents(self):
        if self.request.environ['REQUEST_METHOD'].upper() == 'POST':
            assert self.form
        else:
            self.form = form = RegistrationForm(prefix='newuser:')
        return (yield from self.render_template('user_new.mako'))
{'fraction_non_alphanumeric': 0.10083549409392106, 'fraction_numerical': 0.005473926822241429, 'mean_word_length': 2.300380228136882, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4000570', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1021, 'n_words': 223}