How to use the deform.widget.TextInputWidget function in deform

To help you get started, we’ve selected a few deform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github websauna / websauna / websauna / system / user / schemas.py View on Github external
user_registry = get_user_registry(request)
    user = user_registry.get_by_email(value)

    if not user:
        raise c.Invalid(node, "Cannot reset password for such email: {email}".format(email=value))


class ForgotPasswordSchema(CSRFSchema):
    """Used on forgot password view."""

    email = c.SchemaNode(
        c.Str(),
        title='Email',
        validator=c.All(c.Email(), validate_user_exists_with_email),
        widget=w.TextInputWidget(size=40, maxlength=260, type='email', template="textinput_placeholder"),
        description="The email address under which you have your account. Example: joe@example.com")
github Pylons / deform / deform / widget.py View on Github external
Default: ``readonly/textinput``.


    strip
        If true, during deserialization, strip the value of leading
        and trailing whitespace (default ``True``).
    """

    template = "textarea"
    readonly_template = "readonly/textinput"
    cols = None
    rows = None
    strip = True


class RichTextWidget(TextInputWidget):
    """
    Renders a ``<textarea>`` widget with the
    :term:`TinyMCE Editor`.

    To use this widget the :term:`TinyMCE Editor` library must be
    provided in the page where the widget is rendered. A version of
    :term:`TinyMCE Editor` is included in Deform's ``static`` directory.


    **Attributes/Arguments**

    readonly_template
        The template name used to render the widget in read-only mode.
        Default: ``readonly/richtext``.

    delayed_load</textarea>
github websauna / websauna / websauna / system / form / widgets.py View on Github external
"""Extra widgets.

Mostly for high level integration.
"""
# Standard Library
import json

# Pyramid
import deform
from colander import null

# Websauna
from websauna.utils.slug import uuid_to_slug


class FriendlyUUIDWidget(deform.widget.TextInputWidget):
    """Display both UUID and base64 encoded string of a stored UUID value.

    For :py:class:`websauna.form.field.UUID` Colander type.
    """

    readonly_template = 'readonly/uuid'

    def get_template_values(self, field, cstruct, kw):
        values = {'cstruct': str(cstruct), 'field': field, 'slug': uuid_to_slug(cstruct) if cstruct else ''}
        values.update(kw)
        values.pop('template', None)
        return values


JSON_PREFORMATTED_STYLE = "font-family: monospace"
github hypothesis / h / h / accounts / schemas.py View on Github external
validators.Length(min=USERNAME_MIN_LENGTH,
                              max=USERNAME_MAX_LENGTH),
            colander.Regex(
                USERNAME_PATTERN,
                msg=_("Must have only letters, numbers, periods, and "
                      "underscores.")),
            unique_username,
            unblacklisted_username,
        ),
        title=_('Username'),
        hint=_('Must be between {min} and {max} characters, containing only '
               'letters, numbers, periods, and underscores.').format(
            min=USERNAME_MIN_LENGTH,
            max=USERNAME_MAX_LENGTH
        ),
        widget=deform.widget.TextInputWidget(autofocus=True),
    )
    email = email_node(title=_('Email address'))
    password = new_password_node(title=_('Password'))

    privacy_accepted = colander.SchemaNode(
        colander.Boolean(),
        description=Markup(_privacy_accepted_message()),
        validator=privacy_acceptance_validator,
        widget=deform.widget.CheckboxWidget(
            omit_label=True,
            css_class='form-checkbox--inline'
        ),
    )


class EmailChangeSchema(CSRFSchema):
github sacrud / pyramid_sacrud / pyramid_sacrud / form / widgets.py View on Github external
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2014 uralbash 
#
# Distributed under terms of the MIT license.
import os
from deform.widget import TextInputWidget, TextAreaWidget, CheckboxWidget

cur_path = os.path.dirname(os.path.realpath(__file__))
deform_path = os.path.join(cur_path, '..', 'templates', 'deform')


class ElfinderWidget(TextInputWidget):
    template = os.path.join(deform_path, 'Elfinder.pt')


class HstoreWidget(TextAreaWidget):
    template = os.path.join(deform_path, 'Hstore.pt')


class SlugWidget(TextInputWidget):
    template = os.path.join(deform_path, 'Slug.pt')


class HiddenCheckboxWidget(CheckboxWidget):
    template = os.path.join(deform_path, 'HiddenCheckbox.pt')
github sacrud / pyramid_sacrud / pyramid_sacrud / form / __init__.py View on Github external
def _get_widget_type_by_sa_type(sa_type):
    """
    Returns the deform widget that correspondents to the sqlalchemy type
    'sa_type'.
    """
    return _WIDGETS.get(sa_type) or deform.widget.TextInputWidget
github hypothesis / h / h / schemas / forms / admin / organization.py View on Github external
if _strip_xmlns(root.tag) != "svg":
        raise colander.Invalid(node, _("Logo does not start with <svg> tag"))


class OrganizationSchema(CSRFSchema):

    authority = colander.SchemaNode(colander.String(), title=_("Authority"))

    name = colander.SchemaNode(
        colander.String(),
        title=_("Name"),
        validator=validators.Length(
            ORGANIZATION_NAME_MIN_CHARS, ORGANIZATION_NAME_MAX_CHARS
        ),
        widget=TextInputWidget(max_length=ORGANIZATION_NAME_MAX_CHARS),
    )

    logo = colander.SchemaNode(
        colander.String(),
        title=_("Logo"),
        hint=_(
            "SVG markup for logo. You can get this from a .svg file by"
            " opening it in a text editor and copying the contents."
        ),
        widget=TextAreaWidget(rows=5),
        validator=validate_logo,
        missing=None,
    )</svg>
github websauna / websauna / websauna / system / user / schemas.py View on Github external
widget=w.TextInputWidget(size=40, maxlength=260, type='email'))

    password = c.SchemaNode(
        c.String(),
        validator=c.Length(min=PASSWORD_MIN_LENGTH),
        widget=deform.widget.CheckedPasswordWidget(),
    )


class LoginSchema(CSRFSchema):
    """Login form schema.

    The user can log in both with email and his/her username, though we recommend using emails as users tend to forget their usernames.
    """

    username = c.SchemaNode(c.String(), title='Email', validator=c.All(c.Email()), widget=w.TextInputWidget(size=40, maxlength=260, type='email'))

    password = c.SchemaNode(c.String(), widget=deform.widget.PasswordWidget())


class ResetPasswordSchema(CSRFSchema):
    """Reset password schema."""

    user = c.SchemaNode(
        c.String(),
        missing=c.null,
        widget=deform.widget.TextInputWidget(template='readonly/textinput'))

    password = c.SchemaNode(
        c.String(),
        validator=c.Length(min=2),
        widget=deform.widget.CheckedPasswordWidget()
github eventray-archive / horus / horus / schemas.py View on Github external
c.String(),
        validator=c.Length(min=4),
        widget=deform.widget.CheckedPasswordWidget(),
        description=_("Your password must be harder than a "
                      "dictionary word or proper name!")
    )


class ForgotPasswordSchema(CSRFSchema):
    email = c.SchemaNode(
        c.Str(),
        title=_('Email'),
        validator=c.All(c.Email(), email_exists),
        # type='email' will render an HTML5 email field
        # if you use deform_bootstrap_extra:
        widget=w.TextInputWidget(size=40, maxlength=260, type='email'),
        description=_("The email address under which you have your account. "
                      "Example: joe@example.com"))


class ResetPasswordSchema(CSRFSchema):
    username = c.SchemaNode(
        c.String(),
        missing=c.null,
        widget=deform.widget.TextInputWidget(template='readonly/textinput'))
    password = c.SchemaNode(
        c.String(),
        validator=c.Length(min=2),
        widget=deform.widget.CheckedPasswordWidget()
    )
github websauna / websauna / websauna / system / form / widget.py View on Github external
def deserialize(self, field, pstruct):

        request = self.get_request(field)

        if pstruct is null:
            return null
        if isinstance(pstruct, string_types):
            return (pstruct,)

        der = [self.fix_deserialize_type(obj) for obj in self.get_objects(request, pstruct)]

        return der


class FriendlyUUIDWidget(deform.widget.TextInputWidget):
    """Display both UUID and base64 encoded form of it.

    For :py:class:`websauna.form.field.UUID` Colander type.
    """

    readonly_template = 'readonly/uuid'

    def get_template_values(self, field, cstruct, kw):
        values = {'cstruct':str(cstruct), 'field':field, 'slug':uuid_to_slug(cstruct) if cstruct else ''}
        values.update(kw)
        values.pop('template', None)
        return values