-
-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathsettings.py
More file actions
73 lines (66 loc) · 2.05 KB
/
settings.py
File metadata and controls
73 lines (66 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from django.conf import settings
from openwisp_utils.utils import default_or_test
ORGANIZATION_USER_ADMIN = getattr(settings, "OPENWISP_ORGANIZATION_USER_ADMIN", True)
ORGANIZATION_OWNER_ADMIN = getattr(settings, "OPENWISP_ORGANIZATION_OWNER_ADMIN", True)
USERS_AUTH_API = getattr(settings, "OPENWISP_USERS_AUTH_API", True)
USERS_AUTH_THROTTLE_RATE = getattr(
settings,
"OPENWISP_USERS_AUTH_THROTTLE_RATE",
default_or_test(value="20/day", test=None),
)
AUTH_BACKEND_AUTO_PREFIXES = getattr(
settings, "OPENWISP_USERS_AUTH_BACKEND_AUTO_PREFIXES", tuple()
)
def _export_organizations(user):
# _export_organizations reads user.organizations_dict which is populated
# when the user is added to the organization.
return ",".join(
f'({org_id},{perm["is_admin"]})'
for org_id, perm in user.organizations_dict.items()
)
EXPORT_USERS_COMMAND_CONFIG = {
"fields": [
"id",
"username",
"email",
"password",
"first_name",
"last_name",
"is_staff",
"is_active",
"date_joined",
"phone_number",
"birth_date",
"location",
"notes",
"language",
{"name": "organizations", "callable": _export_organizations},
],
"select_related": [],
"prefetch_related": [],
}
USER_PASSWORD_EXPIRATION = getattr(
settings, "OPENWISP_USERS_USER_PASSWORD_EXPIRATION", 0
)
STAFF_USER_PASSWORD_EXPIRATION = getattr(
settings, "OPENWISP_USERS_STAFF_USER_PASSWORD_EXPIRATION", 0
)
# Set the AutocompleteFilter view if it is not defined in the settings
setattr(
settings,
"OPENWISP_AUTOCOMPLETE_FILTER_VIEW",
getattr(
settings,
"OPENWISP_AUTOCOMPLETE_FILTER_VIEW",
"openwisp_users.views.AutocompleteJsonView",
),
)
# if any OAuth/SAML provider is enabled, allow managing keys/secrets
SOCIALACCOUNT_ADMIN_NEEDED = getattr(
settings,
"OPENWISP_USERS_SOCIALACCOUNT_ADMIN_NEEDED",
any(
app.startswith("allauth.socialaccount.providers.")
for app in settings.INSTALLED_APPS
),
)