Utils Forms

inyoka.utils.forms

This file contains extensions for the django forms like special form fields.

copyright:
  1. 2007-2024 by the Inyoka Team, see AUTHORS for more details.

license:

BSD, see LICENSE for more details.

class inyoka.utils.forms.CaptchaField(*args, **kwargs)
clean(value)

Validate every value in the given list. A value is validated against the corresponding Field in self.fields.

For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), clean() would call DateField.clean(value[0]) and TimeField.clean(value[1]).

compress(data_list)

Return a single value for the given list of values. The values can be assumed to be valid.

For example, if this MultiValueField was instantiated with fields=(DateField(), TimeField()), this might return a datetime object created by combining the date and time in data_list.

widget

alias of CaptchaWidget

class inyoka.utils.forms.CaptchaWidget(attrs=None)
decompress(value)

Return a list of decompressed values for the given compressed value. The given value can be assumed to be valid, but not necessarily non-empty.

property media

Media for a multiwidget is the combination of all media of the subwidgets.

class inyoka.utils.forms.DateTimeField(*, input_formats=None, **kwargs)
clean(value)

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

prepare_value(data)
widget

alias of DateTimeWidget

class inyoka.utils.forms.DateTimeWidget(attrs=None)
input_type = 'text'
property media
render(name, value, attrs=None, renderer=None)

Render the widget as an HTML string.

value_type = 'datetime'
class inyoka.utils.forms.DateWidget(attrs=None)
input_type = 'text'
property media
value_type = 'date'
class inyoka.utils.forms.EmailField(**kwargs)
clean(value)

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

class inyoka.utils.forms.ForumMulitpleChoiceField(*args, **kwargs)
is_category = False
class inyoka.utils.forms.HiddenCaptchaField(*args, **kwargs)
clean(value)

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

widget

alias of HiddenInput

class inyoka.utils.forms.ImageCaptchaField(*args, **kwargs)
clean(value)

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

widget

alias of ImageCaptchaWidget

class inyoka.utils.forms.ImageCaptchaWidget(attrs=None)
get_context(name, value, attrs)
property media
template_name = 'forms/widgets/image_captcha.html'
class inyoka.utils.forms.JabberFormField(*args, **kwargs)
_jabber_re = re.compile('(?xi)(?:[a-z0-9!$\\(\\)*+,;=\\[\\\\\\]\\^`{|}\\-._~]+)@', re.IGNORECASE|re.VERBOSE)
class inyoka.utils.forms.MultiField(fields=(), *args, **kwargs)

This field validates a bunch of values using zero, one or more fields. If the value is just one string, a list is created.

clean(value)

Validates that the value is a list or a tuple.

widget

alias of SelectMultiple

class inyoka.utils.forms.SlugField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)
clean(value)

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

class inyoka.utils.forms.StrippedCharField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)
default_validators = [<function validate_empty_text>]
class inyoka.utils.forms.TimeWidget(attrs=None)
input_type = 'text'
property media
value_type = 'time'
class inyoka.utils.forms.TopicField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)
clean(value)

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

label = 'URL of the topic'
class inyoka.utils.forms.UserField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)

Allows to enter a username as text and validates if the given user exists.

prepare_value(data)

Returns the username from the given data.

data can be: - the a basestring, then it has to be the username, - None, then the field is empty, - an user object, then the username of this user is returned or - an user id, then the user is fetched from the database.

to_python(value)

Return a string.

inyoka.utils.forms.clear_surge_protection(request, form)

Clean errors in parent form so that submitting inherited forms don’t raise any errors.

This function also cleanup the surge protection timer so that we get no nasty hiccups by just submitting an inherited form and sending the whole form afterwards.

inyoka.utils.forms.validate_empty_text(value)
inyoka.utils.forms.validate_gpgkey(value)
inyoka.utils.forms.validate_signature(signature)

Parse a signature and check if it’s valid.