-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_settings.py
executable file
·299 lines (258 loc) · 10.7 KB
/
00_settings.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# =============================================================================
# Global settings:
#
# Those which are typically edited during a deployment are in
# 000_config.py & their results parsed into here. Deployers
# shouldn't typically need to edit any settings here.
# =============================================================================
# Keep all our configuration options off the main global variables
# Use response.s3 for one-off variables which are visible in views without explicit passing
s3.formats = Storage()
# Workaround for this Bug in Selenium with FF4:
# http://code.google.com/p/selenium/issues/detail?id=1604
s3.interactive = settings.get_ui_confirm()
s3.base_url = "%s/%s" % (settings.get_base_public_url(),
appname)
s3.download_url = "%s/default/download" % s3.base_url
# -----------------------------------------------------------------------------
# Global variables
#
# Strings to i18n
# Common Labels
#messages["BREADCRUMB"] = ">> "
messages["UNKNOWN_OPT"] = "Unknown"
messages["NONE"] = "-"
messages["OBSOLETE"] = "Obsolete"
messages["OPEN"] = settings.get_ui_label_open()
messages["READ"] = settings.get_ui_label_read()
messages["UPDATE"] = settings.get_ui_label_update()
messages["DELETE"] = "Delete"
messages["COPY"] = "Copy"
messages["NOT_APPLICABLE"] = "N/A"
messages["ADD_PERSON"] = "Create a Person"
messages["ADD_LOCATION"] = "Create Location"
messages["SELECT_LOCATION"] = "Select a location"
messages["COUNTRY"] = "Country"
messages["ORGANISATION"] = "Organization"
messages["AUTOCOMPLETE_HELP"] = "Enter some characters to bring up a list of possible matches"
for u in messages:
if isinstance(messages[u], str):
globals()[u] = T(messages[u])
# CRUD Labels
s3.crud_labels = Storage(OPEN = OPEN,
READ = READ,
UPDATE = UPDATE,
DELETE = DELETE,
COPY = COPY,
NONE = NONE,
)
# Common Error Messages
ERROR["BAD_RECORD"] = "Record not found"
ERROR["BAD_ENDPOINT"] = "Endpoint not found"
ERROR["BAD_METHOD"] = "Unsupported method"
ERROR["BAD_FORMAT"] = "Unsupported data format"
ERROR["BAD_REQUEST"] = "Invalid request"
ERROR["BAD_SOURCE"] = "Invalid data source"
ERROR["BAD_RESOURCE"] = "Resource not found or not valid"
ERROR["INTEGRITY_ERROR"] = "Integrity error: record can not be deleted while it is referenced by other records"
ERROR["METHOD_DISABLED"] = "Method disabled"
ERROR["NO_MATCH"] = "No matching element found in the data source"
ERROR["NOT_IMPLEMENTED"] = "Not implemented"
ERROR["NOT_PERMITTED"] = "Operation not permitted"
ERROR["UNAUTHORISED"] = "Not Authorized"
ERROR["VALIDATION_ERROR"] = "Validation error"
# To get included in <HEAD>
s3.stylesheets = []
s3.external_stylesheets = []
# To get included at the end of <BODY>
s3.scripts = []
s3.scripts_modules = []
s3.js_global = []
s3.jquery_ready = []
#s3.js_foundation = None
# -----------------------------------------------------------------------------
# Languages
#
s3.l10n_languages = settings.get_L10n_languages()
# Default strings are in US English
T.current_languages = ("en", "en-us")
# Check if user has selected a specific language
if get_vars._language:
language = get_vars._language
session.s3.language = language
elif session.s3.language:
# Use the last-selected language
language = session.s3.language
elif auth.is_logged_in():
# Use user preference
language = auth.user.language
else:
# Use system default
language = settings.get_L10n_default_language()
#else:
# # Use what browser requests (default web2py behaviour)
# T.force(T.http_accept_language)
# IE doesn't set request.env.http_accept_language
#if language != "en":
T.force(language)
# Store for views (e.g. Ext)
if language.find("-") == -1:
# Ext peculiarities
if language == "vi":
s3.language = "vn"
elif language == "el":
s3.language = "el_GR"
else:
s3.language = language
else:
lang_parts = language.split("-")
s3.language = "%s_%s" % (lang_parts[0], lang_parts[1].upper())
# List of Languages which use a Right-to-Left script (Arabic, Hebrew, Farsi, Urdu)
if language in ("ar", "prs", "ps", "ur"):
s3.direction = "rtl"
else:
s3.direction = "ltr"
# -----------------------------------------------------------------------------
# Auth
#
auth_settings = auth.settings
auth_settings.lock_keys = False
auth_settings.logging_enabled = settings.get_auth_logging()
auth_settings.expiration = 28800 # seconds
if settings.get_auth_openid():
# Requires http://pypi.python.org/pypi/python-openid/
try:
from gluon.contrib.login_methods.openid_auth import OpenIDAuth
openid_login_form = OpenIDAuth(auth)
from gluon.contrib.login_methods.extended_login_form import ExtendedLoginForm
auth_settings.login_form = ExtendedLoginForm(auth, openid_login_form,
signals=["oid", "janrain_nonce"])
except ImportError:
session.warning = "Library support not available for OpenID"
# Allow use of LDAP accounts for login
# NB Currently this means that change password should be disabled:
#auth_settings.actions_disabled.append("change_password")
# (NB These are not automatically added to PR or to Authenticated role since they enter via the login() method not register())
#from gluon.contrib.login_methods.ldap_auth import ldap_auth
# Require even alternate login methods to register users 1st
#auth_settings.alternate_requires_registration = True
# Active Directory
#auth_settings.login_methods.append(ldap_auth(mode="ad", server="dc.domain.org", base_dn="ou=Users,dc=domain,dc=org"))
# or if not wanting local users at all (no passwords saved within DB):
#auth_settings.login_methods = [ldap_auth(mode="ad", server="dc.domain.org", base_dn="ou=Users,dc=domain,dc=org")]
# Domino
#auth_settings.login_methods.append(ldap_auth(mode="domino", server="domino.domain.org"))
# OpenLDAP
#auth_settings.login_methods.append(ldap_auth(server="directory.sahanafoundation.org", base_dn="ou=users,dc=sahanafoundation,dc=org"))
# Allow use of Email accounts for login
#auth_settings.login_methods.append(email_auth("smtp.gmail.com:587", "@gmail.com"))
# Require captcha verification for registration
#auth.settings.captcha = RECAPTCHA(request, public_key="PUBLIC_KEY", private_key="PRIVATE_KEY")
# Require Email Verification
auth_settings.registration_requires_verification = settings.get_auth_registration_requires_verification()
auth_settings.reset_password_requires_verification = True
# Require Admin approval for self-registered users
auth_settings.registration_requires_approval = settings.get_auth_registration_requires_approval()
# We don't wish to clutter the groups list with 1 per user.
auth_settings.create_user_groups = False
# We need to allow basic logins for Webservices
auth_settings.allow_basic_login = True
auth_settings.logout_onlogout = s3_auth_on_logout
auth_settings.login_onaccept = s3_auth_on_login
# Redirection URLs
auth_settings.on_failed_authorization = URL(c="default", f="user", args="not_authorized")
auth_settings.verify_email_next = URL(c="default", f="index")
if settings.has_module("vol") and \
settings.get_auth_registration_volunteer():
auth_settings.register_next = URL(c="vol", f="person")
auth_settings.lock_keys = True
# -----------------------------------------------------------------------------
# Mail
#
# These settings could be made configurable as part of the Messaging Module
# - however also need to be used by Auth (order issues)
sender = settings.get_mail_sender()
if sender:
mail.settings.sender = sender
mail.settings.server = settings.get_mail_server()
mail.settings.tls = settings.get_mail_server_tls()
mail_server_login = settings.get_mail_server_login()
if mail_server_login:
mail.settings.login = mail_server_login
# Email settings for registration verification and approval
auth_settings.mailer = mail
# -----------------------------------------------------------------------------
# Session
#
# Custom Notifications
response.error = session.error
response.confirmation = session.confirmation
response.information = session.information
response.warning = session.warning
session.error = []
session.confirmation = []
session.information = []
session.warning = []
# Shortcuts for system role IDs, see modules/s3aaa.py/AuthS3
#system_roles = auth.get_system_roles()
#ADMIN = system_roles.ADMIN
#AUTHENTICATED = system_roles.AUTHENTICATED
#ANONYMOUS = system_roles.ANONYMOUS
#EDITOR = system_roles.EDITOR
#MAP_ADMIN = system_roles.MAP_ADMIN
#ORG_ADMIN = system_roles.ORG_ADMIN
#ORG_GROUP_ADMIN = system_roles.ORG_GROUP_ADMIN
if s3.debug:
# Add the developer toolbar from core/tools
s3.toolbar = s3base.s3_dev_toolbar
# -----------------------------------------------------------------------------
# CRUD
#
s3_formstyle = settings.get_ui_formstyle()
s3_formstyle_read = settings.get_ui_formstyle_read()
s3_formstyle_mobile = s3_formstyle
submit_button = T("Save")
s3_crud = s3.crud
s3_crud.formstyle = s3_formstyle
s3_crud.formstyle_read = s3_formstyle_read
s3_crud.submit_button = submit_button
# Optional class for Submit buttons
#s3_crud.submit_style = "submit-button"
s3_crud.confirm_delete = T("Do you really want to delete these records?")
s3_crud.archive_not_delete = settings.get_security_archive_not_delete()
s3_crud.navigate_away_confirm = settings.get_ui_navigate_away_confirm()
# Content Type Headers, default is application/xml for XML formats
# and text/x-json for JSON formats, other content types must be
# specified here:
s3.content_type = Storage(
rss = "application/rss+xml", # RSS
georss = "application/rss+xml", # GeoRSS
kml = "application/vnd.google-earth.kml+xml", # KML
)
# JSON Formats
s3.json_formats = ["geojson", "s3json"]
# CSV Formats
s3.csv_formats = ["s3csv"]
# Datatables default number of rows per page
s3.ROWSPERPAGE = 20
# Valid Extensions for Image Upload fields
s3.IMAGE_EXTENSIONS = ["png", "PNG", "jpg", "JPG", "jpeg", "JPEG"]
# Default CRUD strings
s3.crud_strings = Storage(
label_create = T("Add Record"),
title_display = T("Record Details"),
title_list = T("Records"),
title_update = T("Edit Record"),
title_map = T("Map"),
title_report = T("Report"),
title_upload = T("Import Records"),
label_list_button = T("List Records"),
label_delete_button = T("Delete Record"),
msg_record_created = T("Record added"),
msg_record_modified = T("Record updated"),
msg_record_deleted = T("Record deleted"),
msg_list_empty = T("No Records currently available"),
msg_match = T("Matching Records"),
msg_no_match = T("No Matching Records"),
)
# END =========================================================================