浏览代码

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

Alexis CLEMENT 8 年前
父节点
当前提交
656c350098
共有 2 个文件被更改,包括 14 次插入14 次删除
  1. 0 4
      tracim/tracim/config/app_cfg.py
  2. 14 10
      tracim/tracim/controllers/admin/user.py

+ 0 - 4
tracim/tracim/config/app_cfg.py 查看文件

217
                 'email.notification.from.default_label.'
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
         self.EMAIL_NOTIFICATION_FROM_EMAIL = \
220
         self.EMAIL_NOTIFICATION_FROM_EMAIL = \
225
             tg.config.get('email.notification.from.email')
221
             tg.config.get('email.notification.from.email')
226
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = \
222
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = \

+ 14 - 10
tracim/tracim/controllers/admin/user.py 查看文件

275
     profile = UserProfileAdminRestController()
275
     profile = UserProfileAdminRestController()
276
     workspaces = UserWorkspaceRestController()
276
     workspaces = UserWorkspaceRestController()
277
 
277
 
278
+    PASSWORD_LENGTH = 12
279
+    PASSWORD_CHARACTERS = '0123456789' \
280
+                          'abcdefghijklmonpqrstuvwxyz' \
281
+                          'ABCDEFGHIJKLMONPQRSTUVWXYZ'
282
+
278
     @classmethod
283
     @classmethod
279
     def current_item_id_key_in_context(cls):
284
     def current_item_id_key_in_context(cls):
280
         return 'user_id'
285
         return 'user_id'
354
         tg.redirect(self.url())
359
         tg.redirect(self.url())
355
 
360
 
356
     @classmethod
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
         # character list that will be contained into the password
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
             # This puts a random char from the list above inside
372
             # This puts a random char from the list above inside
369
             # the list of chars and then merges them into a String
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
         return password
376
         return password
373
 
377
 
374
     @tg.expose('tracim.templates.admin.user_getone')
378
     @tg.expose('tracim.templates.admin.user_getone')