Projet

Général

Profil

0001-forms-PEP8ness-style-30252.patch

Benjamin Dauvergne, 14 février 2019 12:19

Télécharger (3,08 ko)

Voir les différences:

Subject: [PATCH 1/6] forms: PEP8ness, style (#30252)

 src/authentic2/forms/__init__.py | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)
src/authentic2/forms/__init__.py
1
#
2
# Copyright (C) 2010-2019 Entr'ouvert
3
#
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU Affero General Public License as published
6
# by the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU Affero General Public License for more details.
13
#
14
# You should have received a copy of the GNU Affero General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16

  
1 17
import math
2 18

  
3 19
from django import forms
......
93 109
            verified_attributes[av.attribute.name] = True
94 110

  
95 111
        for attribute in self.attributes:
96
            if attribute.name in self.fields and not attribute.name in verified_attributes:
97
                attribute.set_value(self.instance,
98
                        self.cleaned_data[attribute.name])
112
            if attribute.name in self.fields and attribute.name not in verified_attributes:
113
                attribute.set_value(self.instance, self.cleaned_data[attribute.name])
99 114

  
100 115
    def save(self, commit=True):
101 116
        result = super(BaseUserForm, self).save(commit=commit)
......
103 118
            self.save_attributes()
104 119
        else:
105 120
            old = self.save_m2m
121

  
106 122
            def save_m2m(*args, **kwargs):
107 123
                old(*args, **kwargs)
108 124
                self.save_attributes()
......
113 129
class EditProfileForm(NextUrlFormMixin, BaseUserForm):
114 130
    pass
115 131

  
132

  
116 133
def modelform_factory(model, **kwargs):
117 134
    '''Build a modelform for the given model,
118 135

  
......
135 152
                continue
136 153
            d[attribute.name] = attribute.get_form_field()
137 154
        for field in app_settings.A2_REQUIRED_FIELDS:
138
            if not field in required:
155
            if field not in required:
139 156
                required.append(field)
140 157
    if not form or not hasattr(form, 'Meta'):
141 158
        meta_d = {'model': model, 'fields': '__all__'}
......
202 219

  
203 220
        try:
204 221
            super(AuthenticationForm, self).clean()
205
        except:
222
        except Exception:
206 223
            if keys:
207 224
                self.exponential_backoff.failure(*keys)
208 225
            raise
209
-