Projet

Général

Profil

0001-WIP-25666.patch

Paul Marillonnet, 18 décembre 2018 17:56

Télécharger (2,07 ko)

Voir les différences:

Subject: [PATCH] WIP 25666

 src/authentic2/manager/user_views.py |  7 ++++++-
 src/authentic2/manager/utils.py      | 12 ++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
src/authentic2/manager/user_views.py
32 32
from .forms import (UserSearchForm, UserAddForm, UserEditForm,
33 33
    UserChangePasswordForm, ChooseUserRoleForm, UserRoleSearchForm, UserChangeEmailForm)
34 34
from .resources import UserResource
35
from .utils import get_ou_count
35
from .utils import get_ou_count, get_user_add_policies
36 36
from . import app_settings
37 37

  
38 38

  
......
146 146
                         instance=form.instance, form=form)
147 147
        return response
148 148

  
149
    def get_initial(self, *args, **kwargs):
150
        initial = super(UserAddView, self).get_initial(*args, **kwargs)
151
        initial.update(get_user_add_policies())
152
        return initial
153

  
149 154
user_add = UserAddView.as_view()
150 155

  
151 156

  
src/authentic2/manager/utils.py
3 3
from django_rbac.utils import get_ou_model
4 4

  
5 5
from authentic2.decorators import GlobalCache
6
from authentic2 import app_settings
6 7

  
7 8

  
8 9
def label_from_user(user):
......
26 27
@GlobalCache(timeout=10)
27 28
def get_ou_count():
28 29
    return get_ou_model().objects.count()
30

  
31

  
32
def get_user_add_policies():
33
    defaults =  {
34
        'generate_password': True,
35
        'reset_password_at_next_login': True,
36
        'send_mail': True,
37
    }
38

  
39
    return {key: getattr(app_settings, key.upper(), value)
40
            for key, value in defaults.items()}
29
-