Created
February 16, 2015 11:27
-
-
Save pferreir/2dcb789cf899e1707760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/indico/web/forms/widgets.py b/indico/web/forms/widgets.py | |
index 8c40bf3..fa7a5a0 100644 | |
--- a/indico/web/forms/widgets.py | |
+++ b/indico/web/forms/widgets.py | |
@@ -16,6 +16,7 @@ | |
from flask import render_template | |
from wtforms.widgets.core import HTMLString, PasswordInput | |
+from wtforms.validators import Length | |
class ConcatWidget(object): | |
@@ -64,7 +65,18 @@ class PasswordWidget(object): | |
single_line = True | |
+ def attrs_for_validators(self, validators): | |
+ attrs = {} | |
+ for validator in validators: | |
+ if isinstance(validator, Length): | |
+ if validator.min >= 0: | |
+ attrs['minlength'] = validator.min | |
+ if validator.max >= 0: | |
+ attrs['maxlength'] = validator.max | |
+ return attrs | |
+ | |
def __call__(self, field, **kwargs): | |
+ kwargs.update(self.attrs_for_validators(field.validators)) | |
return HTMLString(render_template('forms/password_widget.html', field=field, | |
input=PasswordInput(hide_value=False), input_args=kwargs)) | |
diff --git a/indico/web/templates/forms/password_widget.html b/indico/web/templates/forms/password_widget.html | |
index 2c1ee9f..e4ded73 100644 | |
--- a/indico/web/templates/forms/password_widget.html | |
+++ b/indico/web/templates/forms/password_widget.html | |
@@ -1,7 +1,8 @@ | |
<div class="form-row i-password {%- if field.toggle %} toggle {%- endif -%}"> | |
{{ input(field, **input_args) }} | |
{%- if field.toggle -%} | |
- <button id="{{ field.id }}-button" type="button" class="i-button icon-eye"></button> | |
+ <button id="{{ field.id }}-button" type="button" class="i-button icon-eye-blocked" | |
+ title="{% trans %}Click to toggle visibility of password{% endtrans %}"></button> | |
{% endif %} | |
</div> | |
{%- if field.toggle -%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment