We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Use Helsinki servicemap in adding Place in LE admin


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `linkedevents/settings.py`
Content:
```
1 """
2 Django base settings for linkedevents project.
3 
4 For more information on this file, see
5 https://docs.djangoproject.com/en/1.6/topics/settings/
6 
7 For the full list of settings and their values, see
8 https://docs.djangoproject.com/en/1.6/ref/settings/
9 """
10 
11 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
12 import os
13 BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
14 
15 # Quick-start development settings - unsuitable for production
16 # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
17 
18 DEBUG = False
19 
20 TEMPLATE_DEBUG = False
21 
22 ALLOWED_HOSTS = []
23 
24 SITE_ID = 1
25 
26 # Application definition
27 
28 INSTALLED_APPS = (
29     'helusers',
30     'django.contrib.sites',
31     'modeltranslation',
32     'django.contrib.admin',
33     'django.contrib.auth',
34     'django.contrib.contenttypes',
35     'django.contrib.sessions',
36     'django.contrib.messages',
37     'django.contrib.staticfiles',
38     'django.contrib.gis',
39     'django.contrib.postgres',
40     'django_extensions',
41     'events',
42     'corsheaders',
43     'rest_framework',
44     'rest_framework_jwt',
45     'mptt',
46     'reversion',
47     'haystack',
48     'raven.contrib.django.raven_compat',
49     'django_cleanup',
50 
51     'allauth',
52     'allauth.account',
53     'allauth.socialaccount',
54     'helusers.providers.helsinki',
55 
56     'helevents',
57     'munigeo',
58 )
59 
60 MIDDLEWARE_CLASSES = (
61     'django.contrib.sessions.middleware.SessionMiddleware',
62     'django.middleware.common.CommonMiddleware',
63     'django.middleware.csrf.CsrfViewMiddleware',
64     'django.contrib.auth.middleware.AuthenticationMiddleware',
65     'corsheaders.middleware.CorsMiddleware',
66     'reversion.middleware.RevisionMiddleware',
67     'django.contrib.messages.middleware.MessageMiddleware',
68     'django.middleware.clickjacking.XFrameOptionsMiddleware',
69 )
70 
71 ROOT_URLCONF = 'linkedevents.urls'
72 
73 WSGI_APPLICATION = 'linkedevents.wsgi.application'
74 
75 # Database
76 # https://docs.djangoproject.com/en/1.6/ref/settings/#databases
77 
78 DATABASES = {
79     'default': {
80         'ENGINE': 'django.contrib.gis.db.backends.postgis',
81         'NAME': 'linkedevents',
82     }
83 }
84 
85 # Internationalization
86 # https://docs.djangoproject.com/en/1.6/topics/i18n/
87 
88 LANGUAGES = (
89     ('fi', 'Finnish'),
90     ('sv', 'Swedish'),
91     ('en', 'English'),
92 )
93 
94 LANGUAGE_CODE = 'fi'
95 
96 TIME_ZONE = 'Europe/Helsinki'
97 
98 SYSTEM_DATA_SOURCE_ID = 'system'
99 
100 
101 USE_I18N = True
102 USE_L10N = True
103 USE_TZ = True
104 
105 LOCALE_PATHS = (
106     os.path.join(BASE_DIR, 'locale'),
107 )
108 
109 IMPORT_FILE_PATH = os.path.join(BASE_DIR, 'data')
110 
111 # Static files (CSS, JavaScript, Images)
112 # https://docs.djangoproject.com/en/1.6/howto/static-files/
113 
114 STATIC_URL = '/static/'
115 
116 MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
117 MEDIA_URL = '/media/'
118 
119 #
120 # Authentication
121 #
122 AUTH_USER_MODEL = 'helevents.User'
123 AUTHENTICATION_BACKENDS = (
124     'django.contrib.auth.backends.ModelBackend',
125     'allauth.account.auth_backends.AuthenticationBackend',
126 )
127 SOCIALACCOUNT_PROVIDERS = {
128     'helsinki': {
129         'VERIFIED_EMAIL': True
130     }
131 }
132 LOGIN_REDIRECT_URL = '/'
133 ACCOUNT_LOGOUT_ON_GET = True
134 SOCIALACCOUNT_ADAPTER = 'helusers.providers.helsinki.provider.SocialAccountAdapter'
135 
136 #
137 # REST Framework
138 #
139 REST_FRAMEWORK = {
140     'PAGE_SIZE': 20,
141     'ORDERING_PARAM': 'sort',
142     'DEFAULT_RENDERER_CLASSES': (
143         'events.renderers.JSONRenderer',
144         'events.renderers.JSONLDRenderer',
145         'rest_framework.renderers.BrowsableAPIRenderer',
146     ),
147     'DEFAULT_PARSER_CLASSES': (
148         'events.parsers.CamelCaseJSONParser',
149         'events.parsers.JSONLDParser',
150         'rest_framework.parsers.FormParser',
151         'rest_framework.parsers.MultiPartParser',
152     ),
153     'DEFAULT_FILTER_BACKENDS': (
154         'rest_framework.filters.DjangoFilterBackend',
155     ),
156     'DEFAULT_PAGINATION_CLASS': 'events.api_pagination.CustomPagination',
157     'DEFAULT_PERMISSION_CLASSES': (
158         'rest_framework.permissions.IsAuthenticatedOrReadOnly',
159     ),
160     'DEFAULT_AUTHENTICATION_CLASSES': (
161         'helusers.jwt.JWTAuthentication',
162     ),
163     'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning',
164     'VIEW_NAME_FUNCTION': 'events.api.get_view_name',
165 }
166 JWT_AUTH = {
167     'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'helusers.jwt.get_user_id_from_payload_handler',
168     # JWT_AUDIENCE and JWT_SECRET_KEY must be set in local_settings.py
169 }
170 
171 
172 CORS_ORIGIN_ALLOW_ALL = True
173 CSRF_COOKIE_NAME = 'linkedevents-csrftoken'
174 SESSION_COOKIE_NAME = 'linkedevents-sessionid'
175 
176 TEMPLATES = [
177     {
178         'BACKEND': 'django.template.backends.django.DjangoTemplates',
179         'DIRS': [
180            os.path.join(BASE_DIR, 'templates'),
181         ],
182         'APP_DIRS': True,
183         'OPTIONS': {
184             'context_processors': [
185                 'django.contrib.auth.context_processors.auth',
186                 'django.template.context_processors.debug',
187                 'django.template.context_processors.i18n',
188                 'django.template.context_processors.media',
189                 'django.template.context_processors.static',
190                 'django.template.context_processors.tz',
191                 'django.contrib.messages.context_processors.messages',
192             ],
193         },
194     },
195 ]
196 
197 
198 POSTGIS_VERSION = (2, 1, 1)
199 
200 # Use ETRS-TM35FIN projection by default
201 PROJECTION_SRID=3067
202 # Bounding box of Finland and then some
203 
204 BOUNDING_BOX = [-548576, 6291456, 1548576, 8388608]
205 
206 CITYSDK_API_SETTINGS = {
207     'CITYSDK_URL': "http://api.tourism.helsinki.citysdk.eu/CitySDK/",
208     'USERNAME': 'admin',
209     'PASSWORD': 'defaultCitySDKPassword',
210     'SRS_URL': 'http://www.opengis.net/def/crs/EPSG/0/%d' % PROJECTION_SRID,
211     'DEFAULT_POI_CATEGORY': '53562f3238653c0a842a3bf7'
212 }
213 
214 HAYSTACK_CONNECTIONS = {
215     'default': {
216         'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'
217     },
218     'default-fi': {
219         'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'
220     },
221     'default-en': {
222         'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'
223     },
224     'default-sv': {
225         'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'
226     }
227 }
228 
229 import bleach
230 BLEACH_ALLOWED_TAGS = bleach.ALLOWED_TAGS + ["p", "div"]
231 
232 from easy_thumbnails.conf import Settings as thumbnail_settings
233 THUMBNAIL_PROCESSORS = (
234     'image_cropping.thumbnail_processors.crop_corners',
235 ) + thumbnail_settings.THUMBNAIL_PROCESSORS
236 
237 # local_settings.py can be used to override environment-specific settings
238 # like database and email that differ between development and production.
239 f = os.path.join(BASE_DIR, "local_settings.py")
240 if os.path.exists(f):
241     import sys
242     import imp
243     module_name = "%s.local_settings" % ROOT_URLCONF.split('.')[0]
244     module = imp.new_module(module_name)
245     module.__file__ = f
246     sys.modules[module_name] = module
247     exec(open(f, "rb").read())
248 
249 if 'SECRET_KEY' not in locals():
250     secret_file = os.path.join(BASE_DIR, '.django_secret')
251     try:
252         SECRET_KEY = open(secret_file).read().strip()
253     except IOError:
254         import random
255         system_random = random.SystemRandom()
256         try:
257             SECRET_KEY = ''.join([system_random.choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(64)])
258             secret = open(secret_file, 'w')
259             import os
260             os.chmod(secret_file, 0o0600)
261             secret.write(SECRET_KEY)
262             secret.close()
263         except IOError:
264             Exception('Please create a %s file with random characters to generate your secret key!' % secret_file)
265
```

Path: `events/admin.py`
Content:
```
1 from django.conf import settings
2 from django.contrib import admin
3 from django.contrib.admin.widgets import FilteredSelectMultiple
4 from django.contrib.gis import admin as geoadmin
5 from django.contrib.gis.db import models
6 from django.utils.translation import ugettext as _
7 from modeltranslation.admin import TranslationAdmin
8 from reversion.admin import VersionAdmin
9 from events.api import generate_id
10 from events.models import Event, Keyword, Place, Language, \
11     OpeningHoursSpecification, KeywordLabel, Organization, License
12 
13 
14 class BaseAdmin(admin.ModelAdmin):
15     exclude = ("created_by", "modified_by",)
16 
17     def save_model(self, request, obj, form, change):
18         if obj.pk is None:
19             obj.created_by = request.user
20         else:
21             obj.modified_by = request.user
22         obj.save()
23 
24 
25 class EventModelAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):
26     pass
27 
28 
29 class KeywordAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):
30     pass
31 
32 
33 class PlaceAdmin(geoadmin.GeoModelAdmin, BaseAdmin, TranslationAdmin,
34                  VersionAdmin):
35     fieldsets = (
36         (None, {
37             'fields': ('publisher', 'name', 'description', 'info_url', 'position', 'parent')
38 
39         }),
40         (_('Contact info'), {
41             'fields':  ('email', 'telephone', 'contact_type', 'street_address', 'address_locality', 'address_region',
42                         'postal_code', 'post_office_box_num')
43         }),
44     )
45 
46     def __init__(self, model, admin_site):
47         super().__init__(model, admin_site)
48         # use https CDN instead
49         self.openlayers_url = 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js'
50 
51     def save_model(self, request, obj, form, change):
52         system_id = settings.SYSTEM_DATA_SOURCE_ID
53         obj.data_source_id = system_id
54         if not obj.id:
55             obj.id = generate_id(system_id)
56         obj.origin_id = obj.id.split(':')[1]
57 
58         super().save_model(request, obj, form, change)
59 
60 admin.site.register(Place, PlaceAdmin)
61 
62 
63 class OrganizationAdmin(BaseAdmin):
64     list_display = ('name', 'nr_org_admins')
65 
66     formfield_overrides = {
67         models.ManyToManyField: {'widget': FilteredSelectMultiple("ylläpitäjät", is_stacked=False)},
68     }
69     fields = ('admin_users',)
70 
71     def nr_org_admins(self, obj):
72         return obj.admin_users.count()
73     nr_org_admins.short_description = _('Admins')
74 
75 admin.site.register(Organization, OrganizationAdmin)
76 
77 
78 class LanguageAdmin(BaseAdmin, VersionAdmin):
79     pass
80 
81 
82 class PersonAdmin(BaseAdmin, VersionAdmin):
83     pass
84 
85 
86 class LicenseAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):
87     def get_readonly_fields(self, request, obj=None):
88         if obj:
89             return ['id']
90         else:
91             return []
92 
93 admin.site.register(License, LicenseAdmin)
94
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/events/admin.py b/events/admin.py
--- a/events/admin.py
+++ b/events/admin.py
@@ -1,9 +1,9 @@
 from django.conf import settings
 from django.contrib import admin
 from django.contrib.admin.widgets import FilteredSelectMultiple
-from django.contrib.gis import admin as geoadmin
 from django.contrib.gis.db import models
 from django.utils.translation import ugettext as _
+from leaflet.admin import LeafletGeoAdmin
 from modeltranslation.admin import TranslationAdmin
 from reversion.admin import VersionAdmin
 from events.api import generate_id
@@ -30,8 +30,16 @@
     pass
 
 
-class PlaceAdmin(geoadmin.GeoModelAdmin, BaseAdmin, TranslationAdmin,
-                 VersionAdmin):
+class HelsinkiGeoAdmin(LeafletGeoAdmin):
+    settings_overrides = {
+        'DEFAULT_CENTER': (60.171944, 24.941389),
+        'DEFAULT_ZOOM': 11,
+        'MIN_ZOOM': 3,
+        'MAX_ZOOM': 19,
+    }
+
+
+class PlaceAdmin(HelsinkiGeoAdmin, BaseAdmin, TranslationAdmin, VersionAdmin):
     fieldsets = (
         (None, {
             'fields': ('publisher', 'name', 'description', 'info_url', 'position', 'parent')
diff --git a/linkedevents/settings.py b/linkedevents/settings.py
--- a/linkedevents/settings.py
+++ b/linkedevents/settings.py
@@ -55,6 +55,7 @@
 
     'helevents',
     'munigeo',
+    'leaflet',
 )
 
 MIDDLEWARE_CLASSES = (

{"golden_diff": "diff --git a/events/admin.py b/events/admin.py\n--- a/events/admin.py\n+++ b/events/admin.py\n@@ -1,9 +1,9 @@\n from django.conf import settings\n from django.contrib import admin\n from django.contrib.admin.widgets import FilteredSelectMultiple\n-from django.contrib.gis import admin as geoadmin\n from django.contrib.gis.db import models\n from django.utils.translation import ugettext as _\n+from leaflet.admin import LeafletGeoAdmin\n from modeltranslation.admin import TranslationAdmin\n from reversion.admin import VersionAdmin\n from events.api import generate_id\n@@ -30,8 +30,16 @@\n     pass\n \n \n-class PlaceAdmin(geoadmin.GeoModelAdmin, BaseAdmin, TranslationAdmin,\n-                 VersionAdmin):\n+class HelsinkiGeoAdmin(LeafletGeoAdmin):\n+    settings_overrides = {\n+        'DEFAULT_CENTER': (60.171944, 24.941389),\n+        'DEFAULT_ZOOM': 11,\n+        'MIN_ZOOM': 3,\n+        'MAX_ZOOM': 19,\n+    }\n+\n+\n+class PlaceAdmin(HelsinkiGeoAdmin, BaseAdmin, TranslationAdmin, VersionAdmin):\n     fieldsets = (\n         (None, {\n             'fields': ('publisher', 'name', 'description', 'info_url', 'position', 'parent')\ndiff --git a/linkedevents/settings.py b/linkedevents/settings.py\n--- a/linkedevents/settings.py\n+++ b/linkedevents/settings.py\n@@ -55,6 +55,7 @@\n \n     'helevents',\n     'munigeo',\n+    'leaflet',\n )\n \n MIDDLEWARE_CLASSES = (\n", "issue": "Use Helsinki servicemap in adding Place in LE admin\n\n", "before_files": [{"content": "\"\"\"\nDjango base settings for linkedevents project.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/1.6/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/1.6/ref/settings/\n\"\"\"\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nimport os\nBASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/\n\nDEBUG = False\n\nTEMPLATE_DEBUG = False\n\nALLOWED_HOSTS = []\n\nSITE_ID = 1\n\n# Application definition\n\nINSTALLED_APPS = (\n    'helusers',\n    'django.contrib.sites',\n    'modeltranslation',\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'django.contrib.gis',\n    'django.contrib.postgres',\n    'django_extensions',\n    'events',\n    'corsheaders',\n    'rest_framework',\n    'rest_framework_jwt',\n    'mptt',\n    'reversion',\n    'haystack',\n    'raven.contrib.django.raven_compat',\n    'django_cleanup',\n\n    'allauth',\n    'allauth.account',\n    'allauth.socialaccount',\n    'helusers.providers.helsinki',\n\n    'helevents',\n    'munigeo',\n)\n\nMIDDLEWARE_CLASSES = (\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'corsheaders.middleware.CorsMiddleware',\n    'reversion.middleware.RevisionMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n)\n\nROOT_URLCONF = 'linkedevents.urls'\n\nWSGI_APPLICATION = 'linkedevents.wsgi.application'\n\n# Database\n# https://docs.djangoproject.com/en/1.6/ref/settings/#databases\n\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.contrib.gis.db.backends.postgis',\n        'NAME': 'linkedevents',\n    }\n}\n\n# Internationalization\n# https://docs.djangoproject.com/en/1.6/topics/i18n/\n\nLANGUAGES = (\n    ('fi', 'Finnish'),\n    ('sv', 'Swedish'),\n    ('en', 'English'),\n)\n\nLANGUAGE_CODE = 'fi'\n\nTIME_ZONE = 'Europe/Helsinki'\n\nSYSTEM_DATA_SOURCE_ID = 'system'\n\n\nUSE_I18N = True\nUSE_L10N = True\nUSE_TZ = True\n\nLOCALE_PATHS = (\n    os.path.join(BASE_DIR, 'locale'),\n)\n\nIMPORT_FILE_PATH = os.path.join(BASE_DIR, 'data')\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/1.6/howto/static-files/\n\nSTATIC_URL = '/static/'\n\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media')\nMEDIA_URL = '/media/'\n\n#\n# Authentication\n#\nAUTH_USER_MODEL = 'helevents.User'\nAUTHENTICATION_BACKENDS = (\n    'django.contrib.auth.backends.ModelBackend',\n    'allauth.account.auth_backends.AuthenticationBackend',\n)\nSOCIALACCOUNT_PROVIDERS = {\n    'helsinki': {\n        'VERIFIED_EMAIL': True\n    }\n}\nLOGIN_REDIRECT_URL = '/'\nACCOUNT_LOGOUT_ON_GET = True\nSOCIALACCOUNT_ADAPTER = 'helusers.providers.helsinki.provider.SocialAccountAdapter'\n\n#\n# REST Framework\n#\nREST_FRAMEWORK = {\n    'PAGE_SIZE': 20,\n    'ORDERING_PARAM': 'sort',\n    'DEFAULT_RENDERER_CLASSES': (\n        'events.renderers.JSONRenderer',\n        'events.renderers.JSONLDRenderer',\n        'rest_framework.renderers.BrowsableAPIRenderer',\n    ),\n    'DEFAULT_PARSER_CLASSES': (\n        'events.parsers.CamelCaseJSONParser',\n        'events.parsers.JSONLDParser',\n        'rest_framework.parsers.FormParser',\n        'rest_framework.parsers.MultiPartParser',\n    ),\n    'DEFAULT_FILTER_BACKENDS': (\n        'rest_framework.filters.DjangoFilterBackend',\n    ),\n    'DEFAULT_PAGINATION_CLASS': 'events.api_pagination.CustomPagination',\n    'DEFAULT_PERMISSION_CLASSES': (\n        'rest_framework.permissions.IsAuthenticatedOrReadOnly',\n    ),\n    'DEFAULT_AUTHENTICATION_CLASSES': (\n        'helusers.jwt.JWTAuthentication',\n    ),\n    'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning',\n    'VIEW_NAME_FUNCTION': 'events.api.get_view_name',\n}\nJWT_AUTH = {\n    'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'helusers.jwt.get_user_id_from_payload_handler',\n    # JWT_AUDIENCE and JWT_SECRET_KEY must be set in local_settings.py\n}\n\n\nCORS_ORIGIN_ALLOW_ALL = True\nCSRF_COOKIE_NAME = 'linkedevents-csrftoken'\nSESSION_COOKIE_NAME = 'linkedevents-sessionid'\n\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [\n           os.path.join(BASE_DIR, 'templates'),\n        ],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.contrib.auth.context_processors.auth',\n                'django.template.context_processors.debug',\n                'django.template.context_processors.i18n',\n                'django.template.context_processors.media',\n                'django.template.context_processors.static',\n                'django.template.context_processors.tz',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\n\nPOSTGIS_VERSION = (2, 1, 1)\n\n# Use ETRS-TM35FIN projection by default\nPROJECTION_SRID=3067\n# Bounding box of Finland and then some\n\nBOUNDING_BOX = [-548576, 6291456, 1548576, 8388608]\n\nCITYSDK_API_SETTINGS = {\n    'CITYSDK_URL': \"http://api.tourism.helsinki.citysdk.eu/CitySDK/\",\n    'USERNAME': 'admin',\n    'PASSWORD': 'defaultCitySDKPassword',\n    'SRS_URL': 'http://www.opengis.net/def/crs/EPSG/0/%d' % PROJECTION_SRID,\n    'DEFAULT_POI_CATEGORY': '53562f3238653c0a842a3bf7'\n}\n\nHAYSTACK_CONNECTIONS = {\n    'default': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    },\n    'default-fi': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    },\n    'default-en': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    },\n    'default-sv': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    }\n}\n\nimport bleach\nBLEACH_ALLOWED_TAGS = bleach.ALLOWED_TAGS + [\"p\", \"div\"]\n\nfrom easy_thumbnails.conf import Settings as thumbnail_settings\nTHUMBNAIL_PROCESSORS = (\n    'image_cropping.thumbnail_processors.crop_corners',\n) + thumbnail_settings.THUMBNAIL_PROCESSORS\n\n# local_settings.py can be used to override environment-specific settings\n# like database and email that differ between development and production.\nf = os.path.join(BASE_DIR, \"local_settings.py\")\nif os.path.exists(f):\n    import sys\n    import imp\n    module_name = \"%s.local_settings\" % ROOT_URLCONF.split('.')[0]\n    module = imp.new_module(module_name)\n    module.__file__ = f\n    sys.modules[module_name] = module\n    exec(open(f, \"rb\").read())\n\nif 'SECRET_KEY' not in locals():\n    secret_file = os.path.join(BASE_DIR, '.django_secret')\n    try:\n        SECRET_KEY = open(secret_file).read().strip()\n    except IOError:\n        import random\n        system_random = random.SystemRandom()\n        try:\n            SECRET_KEY = ''.join([system_random.choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(64)])\n            secret = open(secret_file, 'w')\n            import os\n            os.chmod(secret_file, 0o0600)\n            secret.write(SECRET_KEY)\n            secret.close()\n        except IOError:\n            Exception('Please create a %s file with random characters to generate your secret key!' % secret_file)\n", "path": "linkedevents/settings.py"}, {"content": "from django.conf import settings\nfrom django.contrib import admin\nfrom django.contrib.admin.widgets import FilteredSelectMultiple\nfrom django.contrib.gis import admin as geoadmin\nfrom django.contrib.gis.db import models\nfrom django.utils.translation import ugettext as _\nfrom modeltranslation.admin import TranslationAdmin\nfrom reversion.admin import VersionAdmin\nfrom events.api import generate_id\nfrom events.models import Event, Keyword, Place, Language, \\\n    OpeningHoursSpecification, KeywordLabel, Organization, License\n\n\nclass BaseAdmin(admin.ModelAdmin):\n    exclude = (\"created_by\", \"modified_by\",)\n\n    def save_model(self, request, obj, form, change):\n        if obj.pk is None:\n            obj.created_by = request.user\n        else:\n            obj.modified_by = request.user\n        obj.save()\n\n\nclass EventModelAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):\n    pass\n\n\nclass KeywordAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):\n    pass\n\n\nclass PlaceAdmin(geoadmin.GeoModelAdmin, BaseAdmin, TranslationAdmin,\n                 VersionAdmin):\n    fieldsets = (\n        (None, {\n            'fields': ('publisher', 'name', 'description', 'info_url', 'position', 'parent')\n\n        }),\n        (_('Contact info'), {\n            'fields':  ('email', 'telephone', 'contact_type', 'street_address', 'address_locality', 'address_region',\n                        'postal_code', 'post_office_box_num')\n        }),\n    )\n\n    def __init__(self, model, admin_site):\n        super().__init__(model, admin_site)\n        # use https CDN instead\n        self.openlayers_url = 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js'\n\n    def save_model(self, request, obj, form, change):\n        system_id = settings.SYSTEM_DATA_SOURCE_ID\n        obj.data_source_id = system_id\n        if not obj.id:\n            obj.id = generate_id(system_id)\n        obj.origin_id = obj.id.split(':')[1]\n\n        super().save_model(request, obj, form, change)\n\nadmin.site.register(Place, PlaceAdmin)\n\n\nclass OrganizationAdmin(BaseAdmin):\n    list_display = ('name', 'nr_org_admins')\n\n    formfield_overrides = {\n        models.ManyToManyField: {'widget': FilteredSelectMultiple(\"yll\u00e4pit\u00e4j\u00e4t\", is_stacked=False)},\n    }\n    fields = ('admin_users',)\n\n    def nr_org_admins(self, obj):\n        return obj.admin_users.count()\n    nr_org_admins.short_description = _('Admins')\n\nadmin.site.register(Organization, OrganizationAdmin)\n\n\nclass LanguageAdmin(BaseAdmin, VersionAdmin):\n    pass\n\n\nclass PersonAdmin(BaseAdmin, VersionAdmin):\n    pass\n\n\nclass LicenseAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):\n    def get_readonly_fields(self, request, obj=None):\n        if obj:\n            return ['id']\n        else:\n            return []\n\nadmin.site.register(License, LicenseAdmin)\n", "path": "events/admin.py"}], "after_files": [{"content": "\"\"\"\nDjango base settings for linkedevents project.\n\nFor more information on this file, see\nhttps://docs.djangoproject.com/en/1.6/topics/settings/\n\nFor the full list of settings and their values, see\nhttps://docs.djangoproject.com/en/1.6/ref/settings/\n\"\"\"\n\n# Build paths inside the project like this: os.path.join(BASE_DIR, ...)\nimport os\nBASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))\n\n# Quick-start development settings - unsuitable for production\n# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/\n\nDEBUG = False\n\nTEMPLATE_DEBUG = False\n\nALLOWED_HOSTS = []\n\nSITE_ID = 1\n\n# Application definition\n\nINSTALLED_APPS = (\n    'helusers',\n    'django.contrib.sites',\n    'modeltranslation',\n    'django.contrib.admin',\n    'django.contrib.auth',\n    'django.contrib.contenttypes',\n    'django.contrib.sessions',\n    'django.contrib.messages',\n    'django.contrib.staticfiles',\n    'django.contrib.gis',\n    'django.contrib.postgres',\n    'django_extensions',\n    'events',\n    'corsheaders',\n    'rest_framework',\n    'rest_framework_jwt',\n    'mptt',\n    'reversion',\n    'haystack',\n    'raven.contrib.django.raven_compat',\n    'django_cleanup',\n\n    'allauth',\n    'allauth.account',\n    'allauth.socialaccount',\n    'helusers.providers.helsinki',\n\n    'helevents',\n    'munigeo',\n    'leaflet',\n)\n\nMIDDLEWARE_CLASSES = (\n    'django.contrib.sessions.middleware.SessionMiddleware',\n    'django.middleware.common.CommonMiddleware',\n    'django.middleware.csrf.CsrfViewMiddleware',\n    'django.contrib.auth.middleware.AuthenticationMiddleware',\n    'corsheaders.middleware.CorsMiddleware',\n    'reversion.middleware.RevisionMiddleware',\n    'django.contrib.messages.middleware.MessageMiddleware',\n    'django.middleware.clickjacking.XFrameOptionsMiddleware',\n)\n\nROOT_URLCONF = 'linkedevents.urls'\n\nWSGI_APPLICATION = 'linkedevents.wsgi.application'\n\n# Database\n# https://docs.djangoproject.com/en/1.6/ref/settings/#databases\n\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.contrib.gis.db.backends.postgis',\n        'NAME': 'linkedevents',\n    }\n}\n\n# Internationalization\n# https://docs.djangoproject.com/en/1.6/topics/i18n/\n\nLANGUAGES = (\n    ('fi', 'Finnish'),\n    ('sv', 'Swedish'),\n    ('en', 'English'),\n)\n\nLANGUAGE_CODE = 'fi'\n\nTIME_ZONE = 'Europe/Helsinki'\n\nSYSTEM_DATA_SOURCE_ID = 'system'\n\n\nUSE_I18N = True\nUSE_L10N = True\nUSE_TZ = True\n\nLOCALE_PATHS = (\n    os.path.join(BASE_DIR, 'locale'),\n)\n\nIMPORT_FILE_PATH = os.path.join(BASE_DIR, 'data')\n\n# Static files (CSS, JavaScript, Images)\n# https://docs.djangoproject.com/en/1.6/howto/static-files/\n\nSTATIC_URL = '/static/'\n\nMEDIA_ROOT = os.path.join(BASE_DIR, 'media')\nMEDIA_URL = '/media/'\n\n#\n# Authentication\n#\nAUTH_USER_MODEL = 'helevents.User'\nAUTHENTICATION_BACKENDS = (\n    'django.contrib.auth.backends.ModelBackend',\n    'allauth.account.auth_backends.AuthenticationBackend',\n)\nSOCIALACCOUNT_PROVIDERS = {\n    'helsinki': {\n        'VERIFIED_EMAIL': True\n    }\n}\nLOGIN_REDIRECT_URL = '/'\nACCOUNT_LOGOUT_ON_GET = True\nSOCIALACCOUNT_ADAPTER = 'helusers.providers.helsinki.provider.SocialAccountAdapter'\n\n#\n# REST Framework\n#\nREST_FRAMEWORK = {\n    'PAGE_SIZE': 20,\n    'ORDERING_PARAM': 'sort',\n    'DEFAULT_RENDERER_CLASSES': (\n        'events.renderers.JSONRenderer',\n        'events.renderers.JSONLDRenderer',\n        'rest_framework.renderers.BrowsableAPIRenderer',\n    ),\n    'DEFAULT_PARSER_CLASSES': (\n        'events.parsers.CamelCaseJSONParser',\n        'events.parsers.JSONLDParser',\n        'rest_framework.parsers.FormParser',\n        'rest_framework.parsers.MultiPartParser',\n    ),\n    'DEFAULT_FILTER_BACKENDS': (\n        'rest_framework.filters.DjangoFilterBackend',\n    ),\n    'DEFAULT_PAGINATION_CLASS': 'events.api_pagination.CustomPagination',\n    'DEFAULT_PERMISSION_CLASSES': (\n        'rest_framework.permissions.IsAuthenticatedOrReadOnly',\n    ),\n    'DEFAULT_AUTHENTICATION_CLASSES': (\n        'helusers.jwt.JWTAuthentication',\n    ),\n    'DEFAULT_VERSIONING_CLASS': 'rest_framework.versioning.URLPathVersioning',\n    'VIEW_NAME_FUNCTION': 'events.api.get_view_name',\n}\nJWT_AUTH = {\n    'JWT_PAYLOAD_GET_USER_ID_HANDLER': 'helusers.jwt.get_user_id_from_payload_handler',\n    # JWT_AUDIENCE and JWT_SECRET_KEY must be set in local_settings.py\n}\n\n\nCORS_ORIGIN_ALLOW_ALL = True\nCSRF_COOKIE_NAME = 'linkedevents-csrftoken'\nSESSION_COOKIE_NAME = 'linkedevents-sessionid'\n\nTEMPLATES = [\n    {\n        'BACKEND': 'django.template.backends.django.DjangoTemplates',\n        'DIRS': [\n           os.path.join(BASE_DIR, 'templates'),\n        ],\n        'APP_DIRS': True,\n        'OPTIONS': {\n            'context_processors': [\n                'django.contrib.auth.context_processors.auth',\n                'django.template.context_processors.debug',\n                'django.template.context_processors.i18n',\n                'django.template.context_processors.media',\n                'django.template.context_processors.static',\n                'django.template.context_processors.tz',\n                'django.contrib.messages.context_processors.messages',\n            ],\n        },\n    },\n]\n\n\nPOSTGIS_VERSION = (2, 1, 1)\n\n# Use ETRS-TM35FIN projection by default\nPROJECTION_SRID=3067\n# Bounding box of Finland and then some\n\nBOUNDING_BOX = [-548576, 6291456, 1548576, 8388608]\n\nCITYSDK_API_SETTINGS = {\n    'CITYSDK_URL': \"http://api.tourism.helsinki.citysdk.eu/CitySDK/\",\n    'USERNAME': 'admin',\n    'PASSWORD': 'defaultCitySDKPassword',\n    'SRS_URL': 'http://www.opengis.net/def/crs/EPSG/0/%d' % PROJECTION_SRID,\n    'DEFAULT_POI_CATEGORY': '53562f3238653c0a842a3bf7'\n}\n\nHAYSTACK_CONNECTIONS = {\n    'default': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    },\n    'default-fi': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    },\n    'default-en': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    },\n    'default-sv': {\n        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine'\n    }\n}\n\nimport bleach\nBLEACH_ALLOWED_TAGS = bleach.ALLOWED_TAGS + [\"p\", \"div\"]\n\nfrom easy_thumbnails.conf import Settings as thumbnail_settings\nTHUMBNAIL_PROCESSORS = (\n    'image_cropping.thumbnail_processors.crop_corners',\n) + thumbnail_settings.THUMBNAIL_PROCESSORS\n\n# local_settings.py can be used to override environment-specific settings\n# like database and email that differ between development and production.\nf = os.path.join(BASE_DIR, \"local_settings.py\")\nif os.path.exists(f):\n    import sys\n    import imp\n    module_name = \"%s.local_settings\" % ROOT_URLCONF.split('.')[0]\n    module = imp.new_module(module_name)\n    module.__file__ = f\n    sys.modules[module_name] = module\n    exec(open(f, \"rb\").read())\n\nif 'SECRET_KEY' not in locals():\n    secret_file = os.path.join(BASE_DIR, '.django_secret')\n    try:\n        SECRET_KEY = open(secret_file).read().strip()\n    except IOError:\n        import random\n        system_random = random.SystemRandom()\n        try:\n            SECRET_KEY = ''.join([system_random.choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(64)])\n            secret = open(secret_file, 'w')\n            import os\n            os.chmod(secret_file, 0o0600)\n            secret.write(SECRET_KEY)\n            secret.close()\n        except IOError:\n            Exception('Please create a %s file with random characters to generate your secret key!' % secret_file)\n", "path": "linkedevents/settings.py"}, {"content": "from django.conf import settings\nfrom django.contrib import admin\nfrom django.contrib.admin.widgets import FilteredSelectMultiple\nfrom django.contrib.gis.db import models\nfrom django.utils.translation import ugettext as _\nfrom leaflet.admin import LeafletGeoAdmin\nfrom modeltranslation.admin import TranslationAdmin\nfrom reversion.admin import VersionAdmin\nfrom events.api import generate_id\nfrom events.models import Event, Keyword, Place, Language, \\\n    OpeningHoursSpecification, KeywordLabel, Organization, License\n\n\nclass BaseAdmin(admin.ModelAdmin):\n    exclude = (\"created_by\", \"modified_by\",)\n\n    def save_model(self, request, obj, form, change):\n        if obj.pk is None:\n            obj.created_by = request.user\n        else:\n            obj.modified_by = request.user\n        obj.save()\n\n\nclass EventModelAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):\n    pass\n\n\nclass KeywordAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):\n    pass\n\n\nclass HelsinkiGeoAdmin(LeafletGeoAdmin):\n    settings_overrides = {\n        'DEFAULT_CENTER': (60.171944, 24.941389),\n        'DEFAULT_ZOOM': 11,\n        'MIN_ZOOM': 3,\n        'MAX_ZOOM': 19,\n    }\n\n\nclass PlaceAdmin(HelsinkiGeoAdmin, BaseAdmin, TranslationAdmin, VersionAdmin):\n    fieldsets = (\n        (None, {\n            'fields': ('publisher', 'name', 'description', 'info_url', 'position', 'parent')\n\n        }),\n        (_('Contact info'), {\n            'fields':  ('email', 'telephone', 'contact_type', 'street_address', 'address_locality', 'address_region',\n                        'postal_code', 'post_office_box_num')\n        }),\n    )\n\n    def __init__(self, model, admin_site):\n        super().__init__(model, admin_site)\n        # use https CDN instead\n        self.openlayers_url = 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js'\n\n    def save_model(self, request, obj, form, change):\n        system_id = settings.SYSTEM_DATA_SOURCE_ID\n        obj.data_source_id = system_id\n        if not obj.id:\n            obj.id = generate_id(system_id)\n        obj.origin_id = obj.id.split(':')[1]\n\n        super().save_model(request, obj, form, change)\n\nadmin.site.register(Place, PlaceAdmin)\n\n\nclass OrganizationAdmin(BaseAdmin):\n    list_display = ('name', 'nr_org_admins')\n\n    formfield_overrides = {\n        models.ManyToManyField: {'widget': FilteredSelectMultiple(\"yll\u00e4pit\u00e4j\u00e4t\", is_stacked=False)},\n    }\n    fields = ('admin_users',)\n\n    def nr_org_admins(self, obj):\n        return obj.admin_users.count()\n    nr_org_admins.short_description = _('Admins')\n\nadmin.site.register(Organization, OrganizationAdmin)\n\n\nclass LanguageAdmin(BaseAdmin, VersionAdmin):\n    pass\n\n\nclass PersonAdmin(BaseAdmin, VersionAdmin):\n    pass\n\n\nclass LicenseAdmin(BaseAdmin, TranslationAdmin, VersionAdmin):\n    def get_readonly_fields(self, request, obj=None):\n        if obj:\n            return ['id']\n        else:\n            return []\n\nadmin.site.register(License, LicenseAdmin)\n", "path": "events/admin.py"}]}