Projet

Général

Profil

0001-password-field-add-a-flag-to-disable-strength-indica.patch

Thomas Noël, 26 août 2015 16:40

Télécharger (2,5 ko)

Voir les différences:

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(-)
wcs/fields.py
1657 1657
    count_special = 0
1658 1658
    confirmation = True
1659 1659
    confirmation_title = None
1660
    strength_indicator = True
1660 1661
    formats = ['sha1']
1661 1662
    extra_attributes = ['formats', 'min_length', 'max_length',
1662 1663
            'count_uppercase', 'count_lowercase', 'count_digit',
1663
            'count_special', 'confirmation', 'confirmation_title']
1664
            'count_special', 'confirmation', 'confirmation_title',
1665
            'strength_indicator']
1664 1666

  
1665 1667
    widget_class = PasswordEntryWidget
1666 1668

  
......
1692 1694
        form.add(IntWidget, 'count_special',
1693 1695
                title=_('Minimum number of special characters'),
1694 1696
                value=self.count_special)
1697
        form.add(CheckboxWidget, 'strength_indicator',
1698
                title=_('Add a password strength indicator'),
1699
                value=self.strength_indicator)
1695 1700
        form.add(CheckboxWidget, 'confirmation',
1696 1701
                title=_('Add a confirmation input'),
1697 1702
                value=self.confirmation)
wcs/qommon/form.py
1856 1856
        self.count_special = kwargs.get('count_special', 0)
1857 1857
        self.confirmation = kwargs.get('confirmation', True)
1858 1858
        confirmation_title = kwargs.get('confirmation_title') or _('Confirmation')
1859
        self.strength_indicator = kwargs.get('strength_indicator', True)
1859 1860

  
1860 1861
        self.formats = kwargs.get('formats', ['sha1'])
1861 1862
        if not self.attrs.get('readonly'):
......
1880 1881
                        fake_value, self.name, encoded_value)))
1881 1882

  
1882 1883
    def render_content(self):
1883
        if self.attrs.get('readonly'):
1884
        if self.attrs.get('readonly') or not self.strength_indicator:
1884 1885
            return CompositeWidget.render_content(self)
1885 1886
        get_response().add_javascript(['jquery.js', 'jquery.passstrength.js'])
1886 1887
        r = TemplateIO(html=True)
1887
-