Revision c370d0f7
b/snf-astakos-app/astakos/im/api/backends/lib/django/__init__.py | ||
---|---|---|
46 | 46 |
BaseBackend, SuccessResult, FailureResult) |
47 | 47 |
from astakos.im.api.backends.errors import ( |
48 | 48 |
ItemNotExists, ItemExists, MissingIdentifier, MultipleItemsExist) |
49 |
from astakos.im.functions import activate |
|
49 | 50 |
|
50 | 51 |
from astakos.im.util import reserved_email, model_to_dict |
51 | 52 |
from astakos.im.functions import get_quota |
... | ... | |
144 | 145 |
groups = kwargs.pop('groups', ()) |
145 | 146 |
password = kwargs.pop('password', None) |
146 | 147 |
provider = kwargs.pop('provider', 'local') |
148 |
active = kwargs.pop('active', False) |
|
147 | 149 |
|
148 | 150 |
u = self._create_object(AstakosUser, **kwargs) |
149 | 151 |
|
150 | 152 |
if password: |
151 | 153 |
u.set_password(password) |
154 |
u.save() |
|
155 |
|
|
152 | 156 |
u.permissions = permissions |
153 | 157 |
u.policies = policies |
154 | 158 |
u.extended_groups = groups |
... | ... | |
156 | 160 |
if not u.has_auth_provider(provider): |
157 | 161 |
u.add_auth_provider(provider) |
158 | 162 |
|
163 |
if active: |
|
164 |
activate(u) |
|
165 |
|
|
159 | 166 |
return self._details(u) |
160 | 167 |
|
161 | 168 |
@safe |
... | ... | |
185 | 192 |
except ObjectDoesNotExist, e: |
186 | 193 |
append((service, resource, e)) |
187 | 194 |
return rejected |
188 |
|
|
195 |
|
|
189 | 196 |
@safe |
190 | 197 |
def add_permissions(self, user_id, permissions=()): |
191 | 198 |
user = self._lookup_user(user_id) |
b/snf-astakos-app/astakos/im/management/commands/user-add.py | ||
---|---|---|
98 | 98 |
'last_name':last_name |
99 | 99 |
} |
100 | 100 |
u.update(filter_custom_options(options)) |
101 |
u.pop('active') |
|
102 | 101 |
if not u.get('password'): |
103 | 102 |
u['password'] = AstakosUser.objects.make_random_password() |
104 | 103 |
|
... | ... | |
111 | 110 |
if not r.is_success: |
112 | 111 |
raise CommandError(r.reason) |
113 | 112 |
else: |
114 |
if options['active']: |
|
115 |
user_id = r.data.get('id') |
|
116 |
user = AstakosUser.objects.get(id = user_id) |
|
117 |
activate(user) |
|
118 | 113 |
self.stdout.write('User created successfully ') |
119 | 114 |
if not options.get('password'): |
120 | 115 |
self.stdout.write('with password: %s\n' % u['password']) |
Also available in: Unified diff