|
4 | 4 | ..note: By design, you can override these settings from your project's |
5 | 5 | settings.py with prefix 'USER_MAP' on the variable e.g |
6 | 6 | 'USER_MAP_USER_ICONS'. |
7 | | -
|
8 | | - For mailing. as the default, it wil use 'DEFAULT_FROM_MAIL' setting from |
9 | | - the project. |
10 | 7 | """ |
11 | 8 | from django.conf import settings |
12 | 9 |
|
13 | | -# PROJECT_NAME: The project name for this apps e.g InaSAFE |
14 | | -default_project_name = 'InaSAFE' |
15 | | -PROJECT_NAME = getattr(settings, 'USER_MAP_PROJECT_NAME', default_project_name) |
16 | 10 |
|
17 | | -# LOGO/BRAND |
18 | | -default_brand_logo = 'user_map/img/logo.png' |
19 | | -BRAND_LOGO = getattr(settings, 'USER_MAP_BRAND_LOGO', default_brand_logo) |
| 11 | +# USER_MODEL: The auth user model is set in project's settings |
| 12 | +USER_MODEL = settings.AUTH_USER_MODEL |
| 13 | + |
| 14 | +# USER MAP Settings |
| 15 | +default_setting = { |
| 16 | + 'project_name': 'Django', |
| 17 | + 'favicon_file': '', |
| 18 | + 'login_view': 'django.contrib.auth.views.login', |
| 19 | + 'marker': { |
| 20 | + # See leaflet icon valid options here: |
| 21 | + # http://leafletjs.com /reference.html#icon-iconurl |
| 22 | + 'iconUrl': 'static/user_map/img/user-icon.png', |
| 23 | + 'shadowUrl': 'static/user_map/img/shadow-icon.png', |
| 24 | + 'iconSize': [19, 32], |
| 25 | + 'shadowSize': [42, 35], |
| 26 | + 'iconAnchor': [10, 0], |
| 27 | + 'shadowAnchor': [12, 0], |
| 28 | + }, |
| 29 | + 'leaflet_config': { |
| 30 | + 'TILES': [( |
| 31 | + # The title |
| 32 | + 'MapQuest', |
| 33 | + # Tile's URL |
| 34 | + 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', |
| 35 | + # More valid leaflet option are passed here |
| 36 | + # See here: http://leafletjs.com/reference.html#tilelayer |
| 37 | + { |
| 38 | + 'attribution': |
| 39 | + '© <a href="http://www.openstreetmap.org" ' |
| 40 | + 'target="_parent">OpenStreetMap' |
| 41 | + '</a> and contributors, under an <a ' |
| 42 | + 'href="http://www.openstreetmap.org/copyright" ' |
| 43 | + 'target="_parent">open license</a>. Tiles Courtesy of ' |
| 44 | + '<a ' |
| 45 | + 'href="http://www.mapquest.com/">MapQuest</a> <img ' |
| 46 | + 'src="http://developer.mapquest.com/content/osm/mq_logo' |
| 47 | + '.png"', |
| 48 | + 'subdomains': '1234' |
| 49 | + |
| 50 | + } |
| 51 | + )] |
| 52 | + }, |
| 53 | + 'roles': [ |
| 54 | + { |
| 55 | + 'id': 1, |
| 56 | + 'name': 'Django User', |
| 57 | + 'badge': 'user_map/img/badge-user.png' |
| 58 | + }, |
| 59 | + { |
| 60 | + 'id': 2, |
| 61 | + 'name': 'Django Trainer', |
| 62 | + 'badge': 'user_map/img/badge-trainer.png' |
| 63 | + }, |
| 64 | + { |
| 65 | + 'id': 3, |
| 66 | + 'name': 'Django Developer', |
| 67 | + 'badge': 'user_map/img/badge-developer.png' |
| 68 | + } |
| 69 | + ], |
| 70 | + 'api_user_fields': [ |
| 71 | + # e.g 'username', 'first_name', 'last_name' |
| 72 | + ], |
| 73 | +} |
| 74 | + |
| 75 | +user_map_settings = getattr(settings, 'USER_MAP', default_setting) |
| 76 | + |
| 77 | +# PROJECT_NAME: The project name for this apps e.g InaSAFE |
| 78 | +PROJECT_NAME = user_map_settings.get( |
| 79 | + 'project_name', default_setting['project_name']) |
20 | 80 |
|
21 | 81 | # FAVICON_FILE: Favicon for this apps |
22 | | -default_favicon_file = 'user_map/img/user-icon.png' |
23 | | -FAVICON_FILE = getattr(settings, 'USER_MAP_FAVICON_FILE', default_favicon_file) |
24 | | - |
25 | | -# USER ROLES: All user roles and their icons |
26 | | -default_user_roles = [ |
27 | | - dict( |
28 | | - name='User', |
29 | | - icon='user_map/img/user-icon.png', |
30 | | - shadow_icon='user_map/img/shadow-icon.png'), |
31 | | - dict( |
32 | | - name='Trainer', |
33 | | - icon='user_map/img/trainer-icon.png', |
34 | | - shadow_icon='user_map/img/shadow-icon.png'), |
35 | | - dict( |
36 | | - name='Developer', |
37 | | - icon='user_map/img/developer-icon.png', |
38 | | - shadow_icon='user_map/img/shadow-icon.png')] |
39 | | -USER_ROLES = getattr(settings, 'USER_MAP_USER_ROLES', default_user_roles) |
40 | | - |
41 | | -# MAIL SENDER |
42 | | -default_mail_sender = 'noreply@inasafe.org' |
43 | | -DEFAULT_FROM_MAIL = getattr(settings, 'DEFAULT_FROM_MAIL', default_mail_sender) |
44 | | - |
45 | | -# LEAFLET CONFIG |
46 | | -default_leaflet_tiles = ( |
47 | | - 'OpenStreetMap', |
48 | | - 'http://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', |
49 | | - ('© <a href="http://www.openstreetmap.org" target="_parent">OpenStreetMap' |
50 | | - '</a> and contributors, under an <a ' |
51 | | - 'href="http://www.openstreetmap.org/copyright" target="_parent">open ' |
52 | | - 'license</a>') |
53 | | -) |
54 | | -LEAFLET_TILES = getattr(settings, 'LEAFLET_TILES', default_leaflet_tiles) |
| 82 | +FAVICON_FILE = user_map_settings.get( |
| 83 | + 'favicon_file', default_setting['favicon_file']) |
| 84 | + |
| 85 | + |
| 86 | +# LOGIN_VIEW: The view to the login page |
| 87 | +LOGIN_VIEW = user_map_settings.get( |
| 88 | + 'login_view', default_setting['login_view']) |
| 89 | + |
| 90 | +# MARKER |
| 91 | +MARKER = user_map_settings.get( |
| 92 | + 'marker', default_setting['marker']) |
| 93 | + |
| 94 | +LEAFLET_CONFIG = user_map_settings.get( |
| 95 | + 'leaflet_config', default_setting['leaflet_config']) |
| 96 | +LEAFLET_TILES = LEAFLET_CONFIG['TILES'] |
| 97 | + |
| 98 | +# ROLES: All user roles and their badges |
| 99 | +ROLES = user_map_settings.get('roles', default_setting['roles']) |
| 100 | + |
| 101 | +# API_USER_FIELDS |
| 102 | +API_USER_FIELDS = user_map_settings.get( |
| 103 | + 'api_user_fields', default_setting['api_user_fields']) |
0 commit comments