Mercurial > moin > 2.0
changeset 222:f6b21ea7a2dd
merged main
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Mon, 09 May 2011 19:07:55 +0200 |
parents | faa06b4873dd (current diff) 62452154e3a0 (diff) |
children | 46dc442dabb3 |
files | |
diffstat | 3 files changed, 15 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py Mon May 09 19:06:11 2011 +0200 +++ b/MoinMoin/apps/frontend/views.py Mon May 09 19:07:55 2011 +0200 @@ -1024,8 +1024,8 @@ """ name = 'login' - username = String.using(label=L_('Name'), optional=True).validated_by(Present()) - password = String.using(label=L_('Password'), optional=True).validated_by(Present()) + username = String.using(label=L_('Name'), optional=False).validated_by(Present()) + password = String.using(label=L_('Password'), optional=False).validated_by(Present()) openid = String.using(label=L_('OpenID'), optional=True).validated_by(Present(), URLValidator()) # the submit hidden field
--- a/MoinMoin/templates/forms.html Mon May 09 19:06:11 2011 +0200 +++ b/MoinMoin/templates/forms.html Mon May 09 19:07:55 2011 +0200 @@ -16,12 +16,11 @@ {% endmacro %} {% macro render_field(gen, field, field_type) %} - {% set f_class = "optional" if field.optional else "required" %} <dt> - {{ gen.label(field, class=f_class) }} + {{ gen.label(field) }} </dt> <dd> - {{ gen.input(field, class=f_class, type=field_type) }} + {{ gen.input(field, type=field_type) }} {{ render_errors(field) }} </dd> {% endmacro %} @@ -44,13 +43,13 @@ {% macro render_textcha(gen, form) %} {% if form.textcha_question.value %} <dt> - {{ gen.label(form.textcha, class="required") }} + {{ gen.label(form.textcha) }} </dt> <dd> {# The value of -51 below is the sum of signature length, timestamp and a space (see security/textcha.py) #} {{ form.textcha_question.value[:-51] }} - {{ gen.input(form.textcha_question, class=f_class, type='hidden') }}<br /> - {{ gen.input(form.textcha, class="required") }} + {{ gen.input(form.textcha_question, type='hidden') }}<br /> + {{ gen.input(form.textcha) }} {{ render_errors(form.textcha) }} </dd> {% endif %}
--- a/MoinMoin/util/forms.py Mon May 09 19:06:11 2011 +0200 +++ b/MoinMoin/util/forms.py Mon May 09 19:07:55 2011 +0200 @@ -34,6 +34,12 @@ return contents button_filter.tags = set(['input', 'button']) +def required_filter(tagname, attributes, contents, context, bind): + if (bind is not None and not bind.optional): + attributes[u'class'] = u'required' + attributes[u'required'] = u'required' + return contents +required_filter.tags = set(['input', 'label']) def error_filter_factory(class_='moin-error'): """Returns an HTML generation filter annotating field CSS class on error. @@ -58,5 +64,6 @@ """make an html generator""" return Generator(auto_domid=True, auto_for=True, auto_filter=True, markup_wrapper=Markup, - filters=[label_filter, button_filter, error_filter]) + filters=[label_filter, button_filter, + error_filter, required_filter])