From e5e3507ee5d46a9a899d2979a842eccfaf3d5847 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 26 Aug 2015 16:39:53 +0200 Subject: [PATCH] password field: add a flag to disable strength indicator (#8111) --- wcs/fields.py | 7 ++++++- wcs/qommon/form.py | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/wcs/fields.py b/wcs/fields.py index 9225cc3..9705279 100644 --- a/wcs/fields.py +++ b/wcs/fields.py @@ -1657,10 +1657,12 @@ class PasswordField(WidgetField): count_special = 0 confirmation = True confirmation_title = None + strength_indicator = True formats = ['sha1'] extra_attributes = ['formats', 'min_length', 'max_length', 'count_uppercase', 'count_lowercase', 'count_digit', - 'count_special', 'confirmation', 'confirmation_title'] + 'count_special', 'confirmation', 'confirmation_title', + 'strength_indicator'] widget_class = PasswordEntryWidget @@ -1692,6 +1694,9 @@ class PasswordField(WidgetField): form.add(IntWidget, 'count_special', title=_('Minimum number of special characters'), value=self.count_special) + form.add(CheckboxWidget, 'strength_indicator', + title=_('Add a password strength indicator'), + value=self.strength_indicator) form.add(CheckboxWidget, 'confirmation', title=_('Add a confirmation input'), value=self.confirmation) diff --git a/wcs/qommon/form.py b/wcs/qommon/form.py index 7897b5c..fc19358 100644 --- a/wcs/qommon/form.py +++ b/wcs/qommon/form.py @@ -1856,6 +1856,7 @@ class PasswordEntryWidget(CompositeWidget): self.count_special = kwargs.get('count_special', 0) self.confirmation = kwargs.get('confirmation', True) confirmation_title = kwargs.get('confirmation_title') or _('Confirmation') + self.strength_indicator = kwargs.get('strength_indicator', True) self.formats = kwargs.get('formats', ['sha1']) if not self.attrs.get('readonly'): @@ -1880,7 +1881,7 @@ class PasswordEntryWidget(CompositeWidget): fake_value, self.name, encoded_value))) def render_content(self): - if self.attrs.get('readonly'): + if self.attrs.get('readonly') or not self.strength_indicator: return CompositeWidget.render_content(self) get_response().add_javascript(['jquery.js', 'jquery.passstrength.js']) r = TemplateIO(html=True) -- 2.5.0