Pārlūkot izejas kodu

Changed declaration of generate password(cls) to generate_password(cls, [arguments = default values])

Alexis CLEMENT 8 gadus atpakaļ
vecāks
revīzija
656c350098

+ 0 - 4
tracim/tracim/config/app_cfg.py Parādīt failu

@@ -217,10 +217,6 @@ class CFG(object):
217 217
                 'email.notification.from.default_label.'
218 218
             )
219 219
 
220
-        self.AUTO_GENERATED_PASSWORD_LENGTH = tg.config.get(
221
-            'tracim.password.length'
222
-        )
223
-
224 220
         self.EMAIL_NOTIFICATION_FROM_EMAIL = \
225 221
             tg.config.get('email.notification.from.email')
226 222
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = \

+ 14 - 10
tracim/tracim/controllers/admin/user.py Parādīt failu

@@ -275,6 +275,11 @@ class UserRestController(TIMRestController):
275 275
     profile = UserProfileAdminRestController()
276 276
     workspaces = UserWorkspaceRestController()
277 277
 
278
+    PASSWORD_LENGTH = 12
279
+    PASSWORD_CHARACTERS = '0123456789' \
280
+                          'abcdefghijklmonpqrstuvwxyz' \
281
+                          'ABCDEFGHIJKLMONPQRSTUVWXYZ'
282
+
278 283
     @classmethod
279 284
     def current_item_id_key_in_context(cls):
280 285
         return 'user_id'
@@ -354,21 +359,20 @@ class UserRestController(TIMRestController):
354 359
         tg.redirect(self.url())
355 360
 
356 361
     @classmethod
357
-    def generate_password(cls):
358
-        # Characters available to generate a password
359
-        characters = '0123456789' \
360
-                     'abcdefghijklmonpqrstuvwxyz' \
361
-                     'ABCDEFGHIJKLMONPQRSTUVWXYZ'
362
+    def generate_password(
363
+            cls,
364
+            password_length = PASSWORD_LENGTH,
365
+            password_char = PASSWORD_CHARACTERS
366
+            ):
362 367
 
363 368
         # character list that will be contained into the password
364
-        list_char = []
369
+        char_list = []
365 370
 
366
-        pass_length = int(CFG.get_instance().AUTO_GENERATED_PASSWORD_LENGTH)
367
-        for j in range(0, pass_length):
371
+        for j in range(0, password_length):
368 372
             # This puts a random char from the list above inside
369 373
             # the list of chars and then merges them into a String
370
-            list_char.append(random.choice(characters))
371
-            password = ''.join(list_char)
374
+            char_list.append(random.choice(password_char))
375
+            password = ''.join(char_list)
372 376
         return password
373 377
 
374 378
     @tg.expose('tracim.templates.admin.user_getone')