Revision badcb2a9 snf-astakos-app/astakos/im/auth_providers.py
b/snf-astakos-app/astakos/im/auth_providers.py | ||
---|---|---|
47 | 47 |
|
48 | 48 |
# providers registry |
49 | 49 |
PROVIDERS = {} |
50 |
REQUIRED_PROVIDERS = {} |
|
50 | 51 |
|
51 | 52 |
class AuthProviderBase(type): |
52 | 53 |
|
... | ... | |
62 | 63 |
newcls = super(AuthProviderBase, cls).__new__(cls, name, bases, dct) |
63 | 64 |
if include: |
64 | 65 |
PROVIDERS[type_id] = newcls |
66 |
if newcls().is_required(): |
|
67 |
REQUIRED_PROVIDERS[type_id] = newcls |
|
65 | 68 |
return newcls |
66 | 69 |
|
67 | 70 |
|
... | ... | |
122 | 125 |
return self.is_active() and self.get_setting('CAN_ADD', |
123 | 126 |
self.is_active()) |
124 | 127 |
|
128 |
def is_required(self): |
|
129 |
"""Provider required (user cannot remove the last one)""" |
|
130 |
return self.is_active() and self.get_setting('REQUIRED', False) |
|
131 |
|
|
125 | 132 |
def is_active(self): |
126 | 133 |
return self.module in astakos_settings.IM_MODULES |
127 | 134 |
|
Also available in: Unified diff