We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Error messages
This error is back :)
![displayed-messages](https://cloud.githubusercontent.com/assets/3865844/3357669/b2090544-fad4-11e3-9a5c-53d731325844.png)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py`
Content:
```
1 '''
2 Created on Jun 10, 2014
3 
4 @author: Dan
5 '''
6 import ckan.lib.helpers as h
7 import ckan.controllers.organization as organization
8 import ckan.plugins.toolkit as tk
9 from ckan.common import c, request, _
10 import ckan.lib.base as base
11 import ckanext.hdx_theme.helpers as hdx_h
12 import ckan.lib.mailer as mailer
13 import ckan.model as model
14 
15 class HDXOrgController(base.BaseController):
16 
17     def _send_mail(self, user, sys_admin, org, message = ''):
18         body = _('New request membership\n' \
19         'Full Name: {fn}\n' \
20         'Username: {username}\n' \
21         'Email: {mail}\n' \
22         'Organization: {org}\n' \
23         'Message from user: {msg}\n' \
24         '(This is an automated mail)' \
25         '').format(fn=user['display_name'], username=user['name'], mail=user['email'], org=org, msg=message)
26         
27         mailer.mail_recipient(sys_admin['display_name'], sys_admin['email'], _('New Request Membership'), body)
28         return
29 
30     def request_membership(self, id):
31         '''
32             user_email, name of user, username, organization name,  list with sys-admins emails,
33         '''
34         try:
35             msg = request.params.get('message', '')
36             user = hdx_h.hdx_get_user_info(c.user)
37             context = {'model': model, 'session': model.Session,
38                        'user': c.user or c.author}
39             org_admins = tk.get_action('member_list')(context,{'id':id,'capacity':'admin','object_type':'user'})
40             admins=[]
41             for admin_tuple in org_admins:
42                 admin_id = admin_tuple[0]
43                 admins.append(hdx_h.hdx_get_user_info(admin_id))
44             admins_with_email = (admin for admin in admins if admin['email'])
45             for admin in admins_with_email :
46                 self._send_mail(user, admin, id, msg)
47             h.flash_success(_('Message sent'))
48         except:
49             h.flash_error(_('Request can not be sent. Contact an administrator'))
50         h.redirect_to(controller='organization', action='read', id=id)
51     
52 
53     
54
```

Path: `ckanext-hdx_theme/ckanext/hdx_theme/plugin.py`
Content:
```
1 import ckanext.hdx_theme.licenses as hdx_licenses
2 
3 import ckan.plugins as plugins
4 import ckan.plugins.toolkit as toolkit
5 import ckan.model.package as package
6 import ckan.model.license as license
7 import version
8 
9 import ckanext.hdx_theme.caching as caching
10 import ckanext.hdx_theme.auth as auth
11 
12 
13 def run_on_startup():
14     _generate_license_list()
15     
16     caching.cached_get_group_package_stuff()
17     
18 
19 def _generate_license_list():
20     package.Package._license_register = license.LicenseRegister() 
21     package.Package._license_register.licenses = [
22                                                   license.License(hdx_licenses.LicenseCreativeCommonsIntergovernmentalOrgs()),
23                                                   license.License(license.LicenseCreativeCommonsAttribution()),
24                                                   license.License(license.LicenseCreativeCommonsAttributionShareAlike()),
25                                                   license.License(hdx_licenses.LicenseOtherPublicDomainNoRestrictions()),
26                                                   license.License(hdx_licenses.LicenseHdxMultiple()),
27                                                   license.License(hdx_licenses.LicenseHdxOther())
28                                                   ]
29 
30 class HDXThemePlugin(plugins.SingletonPlugin):
31     plugins.implements(plugins.IConfigurer)
32     plugins.implements(plugins.IRoutes, inherit=True)
33     plugins.implements(plugins.ITemplateHelpers)
34     plugins.implements(plugins.IActions)
35     plugins.implements(plugins.IAuthFunctions)
36     plugins.implements(plugins.IGroupController, inherit=True)
37     plugins.implements(plugins.IMiddleware, inherit=True)
38     
39     def update_config(self, config):
40         toolkit.add_template_directory(config, 'templates')
41         toolkit.add_public_directory(config, 'public')
42         toolkit.add_resource('fanstatic', 'hdx_theme')
43         
44 
45     def before_map(self, map):
46         map.connect('home', '/', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='index')
47         map.connect('/count/dataset', controller='ckanext.hdx_theme.count:CountController', action='dataset')
48         map.connect('/count/country', controller='ckanext.hdx_theme.count:CountController', action='country')
49         map.connect('/count/source', controller='ckanext.hdx_theme.count:CountController', action='source')
50         map.connect('/user/logged_in', controller='ckanext.hdx_theme.login:LoginController', action='logged_in')
51         map.connect('/contribute', controller='ckanext.hdx_theme.login:LoginController', action='contribute')
52         
53         map.connect('/count/test', controller='ckanext.hdx_theme.count:CountController', action='test')
54         
55         map.connect('/organization/{id}/request_membership', controller='ckanext.hdx_theme.org_controller:HDXOrgController', action='request_membership')
56         map.connect('/organization/members/{id}', controller='ckanext.hdx_theme.member_controller:HDXOrgMemberController', action='members')
57         map.connect('/dataset/preselect', controller='ckanext.hdx_theme.preselect_dsform_controller:HDXPreselectOrgController', action='preselect')
58 
59         map.connect('/about/{page}', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='about')
60         return map
61     
62     def create(self, entity):
63         caching.invalidate_group_caches()
64 
65     def edit(self, entity):
66         caching.invalidate_group_caches()
67 
68     def get_helpers(self):
69         from ckanext.hdx_theme import helpers as hdx_helpers
70         return {
71             'is_downloadable': hdx_helpers.is_downloadable,
72             'get_facet_items_dict':hdx_helpers.get_facet_items_dict,
73             'get_last_modifier_user': hdx_helpers.get_last_modifier_user,
74             'get_filtered_params_list':hdx_helpers.get_filtered_params_list,
75             'get_last_revision_package':hdx_helpers.get_last_revision_package,
76             'get_last_modifier_user':hdx_helpers.get_last_modifier_user,
77             'get_last_revision_group':hdx_helpers.get_last_revision_group,
78             'get_group_followers':hdx_helpers.get_group_followers,
79             'get_group_members':hdx_helpers.get_group_members,
80             'markdown_extract_strip':hdx_helpers.markdown_extract_strip,
81             'render_date_from_concat_str':hdx_helpers.render_date_from_concat_str,
82             'hdx_version':hdx_helpers.hdx_version,
83             'hdx_build_nav_icon_with_message':hdx_helpers.hdx_build_nav_icon_with_message,
84             'hdx_num_of_new_related_items':hdx_helpers.hdx_num_of_new_related_items,
85             'hdx_get_extras_element':hdx_helpers.hdx_get_extras_element,
86             'hdx_get_user_info':hdx_helpers.hdx_get_user_info,
87             'hdx_linked_user':hdx_helpers.hdx_linked_user,
88             'hdx_show_singular_plural':hdx_helpers.hdx_show_singular_plural,
89             'hdx_member_roles_list':hdx_helpers.hdx_member_roles_list
90             
91         }
92         
93     def get_actions(self):
94         from ckanext.hdx_theme import actions as hdx_actions
95         return {
96             'organization_list_for_user':hdx_actions.organization_list_for_user, 
97             'cached_group_list': hdx_actions.cached_group_list,
98             'hdx_basic_user_info': hdx_actions.hdx_basic_user_info,
99             'member_list': hdx_actions.member_list,
100             'hdx_get_sys_admins': hdx_actions.hdx_get_sys_admins
101             
102         }
103     def get_auth_functions(self):
104         return {
105                 'hdx_basic_user_info': auth.hdx_basic_user_info
106                 }
107     
108     def make_middleware(self, app, config):
109         run_on_startup()
110         return app
111 
112         
113         
114 
115
```
--- 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/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py b/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py
--- a/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py
+++ b/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py
@@ -12,7 +12,7 @@
 import ckan.lib.mailer as mailer
 import ckan.model as model
 
-class HDXOrgController(base.BaseController):
+class HDXReqsOrgController(base.BaseController):
 
     def _send_mail(self, user, sys_admin, org, message = ''):
         body = _('New request membership\n' \
@@ -27,7 +27,7 @@
         mailer.mail_recipient(sys_admin['display_name'], sys_admin['email'], _('New Request Membership'), body)
         return
 
-    def request_membership(self, id):
+    def request_membership(self, org_id):
         '''
             user_email, name of user, username, organization name,  list with sys-admins emails,
         '''
@@ -36,19 +36,19 @@
             user = hdx_h.hdx_get_user_info(c.user)
             context = {'model': model, 'session': model.Session,
                        'user': c.user or c.author}
-            org_admins = tk.get_action('member_list')(context,{'id':id,'capacity':'admin','object_type':'user'})
+            org_admins = tk.get_action('member_list')(context,{'id':org_id,'capacity':'admin','object_type':'user'})
             admins=[]
             for admin_tuple in org_admins:
                 admin_id = admin_tuple[0]
                 admins.append(hdx_h.hdx_get_user_info(admin_id))
             admins_with_email = (admin for admin in admins if admin['email'])
             for admin in admins_with_email :
-                self._send_mail(user, admin, id, msg)
+                self._send_mail(user, admin, org_id, msg)
             h.flash_success(_('Message sent'))
         except:
             h.flash_error(_('Request can not be sent. Contact an administrator'))
-        h.redirect_to(controller='organization', action='read', id=id)
-    
+        h.redirect_to(controller='organization', action='read', id=org_id)
+        
 
     
     
\ No newline at end of file
diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py b/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py
--- a/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py
+++ b/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py
@@ -52,7 +52,7 @@
         
         map.connect('/count/test', controller='ckanext.hdx_theme.count:CountController', action='test')
         
-        map.connect('/organization/{id}/request_membership', controller='ckanext.hdx_theme.org_controller:HDXOrgController', action='request_membership')
+        map.connect('/organization/{id}/request_membership', controller='ckanext.hdx_theme.org_controller:HDXReqsOrgController', action='request_membership')
         map.connect('/organization/members/{id}', controller='ckanext.hdx_theme.member_controller:HDXOrgMemberController', action='members')
         map.connect('/dataset/preselect', controller='ckanext.hdx_theme.preselect_dsform_controller:HDXPreselectOrgController', action='preselect')

{"golden_diff": "diff --git a/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py b/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py\n--- a/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py\n+++ b/ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py\n@@ -12,7 +12,7 @@\n import ckan.lib.mailer as mailer\n import ckan.model as model\n \n-class HDXOrgController(base.BaseController):\n+class HDXReqsOrgController(base.BaseController):\n \n     def _send_mail(self, user, sys_admin, org, message = ''):\n         body = _('New request membership\\n' \\\n@@ -27,7 +27,7 @@\n         mailer.mail_recipient(sys_admin['display_name'], sys_admin['email'], _('New Request Membership'), body)\n         return\n \n-    def request_membership(self, id):\n+    def request_membership(self, org_id):\n         '''\n             user_email, name of user, username, organization name,  list with sys-admins emails,\n         '''\n@@ -36,19 +36,19 @@\n             user = hdx_h.hdx_get_user_info(c.user)\n             context = {'model': model, 'session': model.Session,\n                        'user': c.user or c.author}\n-            org_admins = tk.get_action('member_list')(context,{'id':id,'capacity':'admin','object_type':'user'})\n+            org_admins = tk.get_action('member_list')(context,{'id':org_id,'capacity':'admin','object_type':'user'})\n             admins=[]\n             for admin_tuple in org_admins:\n                 admin_id = admin_tuple[0]\n                 admins.append(hdx_h.hdx_get_user_info(admin_id))\n             admins_with_email = (admin for admin in admins if admin['email'])\n             for admin in admins_with_email :\n-                self._send_mail(user, admin, id, msg)\n+                self._send_mail(user, admin, org_id, msg)\n             h.flash_success(_('Message sent'))\n         except:\n             h.flash_error(_('Request can not be sent. Contact an administrator'))\n-        h.redirect_to(controller='organization', action='read', id=id)\n-    \n+        h.redirect_to(controller='organization', action='read', id=org_id)\n+        \n \n     \n     \n\\ No newline at end of file\ndiff --git a/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py b/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py\n--- a/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py\n+++ b/ckanext-hdx_theme/ckanext/hdx_theme/plugin.py\n@@ -52,7 +52,7 @@\n         \n         map.connect('/count/test', controller='ckanext.hdx_theme.count:CountController', action='test')\n         \n-        map.connect('/organization/{id}/request_membership', controller='ckanext.hdx_theme.org_controller:HDXOrgController', action='request_membership')\n+        map.connect('/organization/{id}/request_membership', controller='ckanext.hdx_theme.org_controller:HDXReqsOrgController', action='request_membership')\n         map.connect('/organization/members/{id}', controller='ckanext.hdx_theme.member_controller:HDXOrgMemberController', action='members')\n         map.connect('/dataset/preselect', controller='ckanext.hdx_theme.preselect_dsform_controller:HDXPreselectOrgController', action='preselect')\n", "issue": "Error messages\nThis error is back :)\n![displayed-messages](https://cloud.githubusercontent.com/assets/3865844/3357669/b2090544-fad4-11e3-9a5c-53d731325844.png)\n\n", "before_files": [{"content": "'''\nCreated on Jun 10, 2014\n\n@author: Dan\n'''\nimport ckan.lib.helpers as h\nimport ckan.controllers.organization as organization\nimport ckan.plugins.toolkit as tk\nfrom ckan.common import c, request, _\nimport ckan.lib.base as base\nimport ckanext.hdx_theme.helpers as hdx_h\nimport ckan.lib.mailer as mailer\nimport ckan.model as model\n\nclass HDXOrgController(base.BaseController):\n\n    def _send_mail(self, user, sys_admin, org, message = ''):\n        body = _('New request membership\\n' \\\n        'Full Name: {fn}\\n' \\\n        'Username: {username}\\n' \\\n        'Email: {mail}\\n' \\\n        'Organization: {org}\\n' \\\n        'Message from user: {msg}\\n' \\\n        '(This is an automated mail)' \\\n        '').format(fn=user['display_name'], username=user['name'], mail=user['email'], org=org, msg=message)\n        \n        mailer.mail_recipient(sys_admin['display_name'], sys_admin['email'], _('New Request Membership'), body)\n        return\n\n    def request_membership(self, id):\n        '''\n            user_email, name of user, username, organization name,  list with sys-admins emails,\n        '''\n        try:\n            msg = request.params.get('message', '')\n            user = hdx_h.hdx_get_user_info(c.user)\n            context = {'model': model, 'session': model.Session,\n                       'user': c.user or c.author}\n            org_admins = tk.get_action('member_list')(context,{'id':id,'capacity':'admin','object_type':'user'})\n            admins=[]\n            for admin_tuple in org_admins:\n                admin_id = admin_tuple[0]\n                admins.append(hdx_h.hdx_get_user_info(admin_id))\n            admins_with_email = (admin for admin in admins if admin['email'])\n            for admin in admins_with_email :\n                self._send_mail(user, admin, id, msg)\n            h.flash_success(_('Message sent'))\n        except:\n            h.flash_error(_('Request can not be sent. Contact an administrator'))\n        h.redirect_to(controller='organization', action='read', id=id)\n    \n\n    \n    ", "path": "ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py"}, {"content": "import ckanext.hdx_theme.licenses as hdx_licenses\n\nimport ckan.plugins as plugins\nimport ckan.plugins.toolkit as toolkit\nimport ckan.model.package as package\nimport ckan.model.license as license\nimport version\n\nimport ckanext.hdx_theme.caching as caching\nimport ckanext.hdx_theme.auth as auth\n\n\ndef run_on_startup():\n    _generate_license_list()\n    \n    caching.cached_get_group_package_stuff()\n    \n\ndef _generate_license_list():\n    package.Package._license_register = license.LicenseRegister() \n    package.Package._license_register.licenses = [\n                                                  license.License(hdx_licenses.LicenseCreativeCommonsIntergovernmentalOrgs()),\n                                                  license.License(license.LicenseCreativeCommonsAttribution()),\n                                                  license.License(license.LicenseCreativeCommonsAttributionShareAlike()),\n                                                  license.License(hdx_licenses.LicenseOtherPublicDomainNoRestrictions()),\n                                                  license.License(hdx_licenses.LicenseHdxMultiple()),\n                                                  license.License(hdx_licenses.LicenseHdxOther())\n                                                  ]\n\nclass HDXThemePlugin(plugins.SingletonPlugin):\n    plugins.implements(plugins.IConfigurer)\n    plugins.implements(plugins.IRoutes, inherit=True)\n    plugins.implements(plugins.ITemplateHelpers)\n    plugins.implements(plugins.IActions)\n    plugins.implements(plugins.IAuthFunctions)\n    plugins.implements(plugins.IGroupController, inherit=True)\n    plugins.implements(plugins.IMiddleware, inherit=True)\n    \n    def update_config(self, config):\n        toolkit.add_template_directory(config, 'templates')\n        toolkit.add_public_directory(config, 'public')\n        toolkit.add_resource('fanstatic', 'hdx_theme')\n        \n\n    def before_map(self, map):\n        map.connect('home', '/', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='index')\n        map.connect('/count/dataset', controller='ckanext.hdx_theme.count:CountController', action='dataset')\n        map.connect('/count/country', controller='ckanext.hdx_theme.count:CountController', action='country')\n        map.connect('/count/source', controller='ckanext.hdx_theme.count:CountController', action='source')\n        map.connect('/user/logged_in', controller='ckanext.hdx_theme.login:LoginController', action='logged_in')\n        map.connect('/contribute', controller='ckanext.hdx_theme.login:LoginController', action='contribute')\n        \n        map.connect('/count/test', controller='ckanext.hdx_theme.count:CountController', action='test')\n        \n        map.connect('/organization/{id}/request_membership', controller='ckanext.hdx_theme.org_controller:HDXOrgController', action='request_membership')\n        map.connect('/organization/members/{id}', controller='ckanext.hdx_theme.member_controller:HDXOrgMemberController', action='members')\n        map.connect('/dataset/preselect', controller='ckanext.hdx_theme.preselect_dsform_controller:HDXPreselectOrgController', action='preselect')\n\n        map.connect('/about/{page}', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='about')\n        return map\n    \n    def create(self, entity):\n        caching.invalidate_group_caches()\n\n    def edit(self, entity):\n        caching.invalidate_group_caches()\n\n    def get_helpers(self):\n        from ckanext.hdx_theme import helpers as hdx_helpers\n        return {\n            'is_downloadable': hdx_helpers.is_downloadable,\n            'get_facet_items_dict':hdx_helpers.get_facet_items_dict,\n            'get_last_modifier_user': hdx_helpers.get_last_modifier_user,\n            'get_filtered_params_list':hdx_helpers.get_filtered_params_list,\n            'get_last_revision_package':hdx_helpers.get_last_revision_package,\n            'get_last_modifier_user':hdx_helpers.get_last_modifier_user,\n            'get_last_revision_group':hdx_helpers.get_last_revision_group,\n            'get_group_followers':hdx_helpers.get_group_followers,\n            'get_group_members':hdx_helpers.get_group_members,\n            'markdown_extract_strip':hdx_helpers.markdown_extract_strip,\n            'render_date_from_concat_str':hdx_helpers.render_date_from_concat_str,\n            'hdx_version':hdx_helpers.hdx_version,\n            'hdx_build_nav_icon_with_message':hdx_helpers.hdx_build_nav_icon_with_message,\n            'hdx_num_of_new_related_items':hdx_helpers.hdx_num_of_new_related_items,\n            'hdx_get_extras_element':hdx_helpers.hdx_get_extras_element,\n            'hdx_get_user_info':hdx_helpers.hdx_get_user_info,\n            'hdx_linked_user':hdx_helpers.hdx_linked_user,\n            'hdx_show_singular_plural':hdx_helpers.hdx_show_singular_plural,\n            'hdx_member_roles_list':hdx_helpers.hdx_member_roles_list\n            \n        }\n        \n    def get_actions(self):\n        from ckanext.hdx_theme import actions as hdx_actions\n        return {\n            'organization_list_for_user':hdx_actions.organization_list_for_user, \n            'cached_group_list': hdx_actions.cached_group_list,\n            'hdx_basic_user_info': hdx_actions.hdx_basic_user_info,\n            'member_list': hdx_actions.member_list,\n            'hdx_get_sys_admins': hdx_actions.hdx_get_sys_admins\n            \n        }\n    def get_auth_functions(self):\n        return {\n                'hdx_basic_user_info': auth.hdx_basic_user_info\n                }\n    \n    def make_middleware(self, app, config):\n        run_on_startup()\n        return app\n\n        \n        \n\n", "path": "ckanext-hdx_theme/ckanext/hdx_theme/plugin.py"}], "after_files": [{"content": "'''\nCreated on Jun 10, 2014\n\n@author: Dan\n'''\nimport ckan.lib.helpers as h\nimport ckan.controllers.organization as organization\nimport ckan.plugins.toolkit as tk\nfrom ckan.common import c, request, _\nimport ckan.lib.base as base\nimport ckanext.hdx_theme.helpers as hdx_h\nimport ckan.lib.mailer as mailer\nimport ckan.model as model\n\nclass HDXReqsOrgController(base.BaseController):\n\n    def _send_mail(self, user, sys_admin, org, message = ''):\n        body = _('New request membership\\n' \\\n        'Full Name: {fn}\\n' \\\n        'Username: {username}\\n' \\\n        'Email: {mail}\\n' \\\n        'Organization: {org}\\n' \\\n        'Message from user: {msg}\\n' \\\n        '(This is an automated mail)' \\\n        '').format(fn=user['display_name'], username=user['name'], mail=user['email'], org=org, msg=message)\n        \n        mailer.mail_recipient(sys_admin['display_name'], sys_admin['email'], _('New Request Membership'), body)\n        return\n\n    def request_membership(self, org_id):\n        '''\n            user_email, name of user, username, organization name,  list with sys-admins emails,\n        '''\n        try:\n            msg = request.params.get('message', '')\n            user = hdx_h.hdx_get_user_info(c.user)\n            context = {'model': model, 'session': model.Session,\n                       'user': c.user or c.author}\n            org_admins = tk.get_action('member_list')(context,{'id':org_id,'capacity':'admin','object_type':'user'})\n            admins=[]\n            for admin_tuple in org_admins:\n                admin_id = admin_tuple[0]\n                admins.append(hdx_h.hdx_get_user_info(admin_id))\n            admins_with_email = (admin for admin in admins if admin['email'])\n            for admin in admins_with_email :\n                self._send_mail(user, admin, org_id, msg)\n            h.flash_success(_('Message sent'))\n        except:\n            h.flash_error(_('Request can not be sent. Contact an administrator'))\n        h.redirect_to(controller='organization', action='read', id=org_id)\n        \n\n    \n    ", "path": "ckanext-hdx_theme/ckanext/hdx_theme/org_controller.py"}, {"content": "import ckanext.hdx_theme.licenses as hdx_licenses\n\nimport ckan.plugins as plugins\nimport ckan.plugins.toolkit as toolkit\nimport ckan.model.package as package\nimport ckan.model.license as license\nimport version\n\nimport ckanext.hdx_theme.caching as caching\nimport ckanext.hdx_theme.auth as auth\n\n\ndef run_on_startup():\n    _generate_license_list()\n    \n    caching.cached_get_group_package_stuff()\n    \n\ndef _generate_license_list():\n    package.Package._license_register = license.LicenseRegister() \n    package.Package._license_register.licenses = [\n                                                  license.License(hdx_licenses.LicenseCreativeCommonsIntergovernmentalOrgs()),\n                                                  license.License(license.LicenseCreativeCommonsAttribution()),\n                                                  license.License(license.LicenseCreativeCommonsAttributionShareAlike()),\n                                                  license.License(hdx_licenses.LicenseOtherPublicDomainNoRestrictions()),\n                                                  license.License(hdx_licenses.LicenseHdxMultiple()),\n                                                  license.License(hdx_licenses.LicenseHdxOther())\n                                                  ]\n\nclass HDXThemePlugin(plugins.SingletonPlugin):\n    plugins.implements(plugins.IConfigurer)\n    plugins.implements(plugins.IRoutes, inherit=True)\n    plugins.implements(plugins.ITemplateHelpers)\n    plugins.implements(plugins.IActions)\n    plugins.implements(plugins.IAuthFunctions)\n    plugins.implements(plugins.IGroupController, inherit=True)\n    plugins.implements(plugins.IMiddleware, inherit=True)\n    \n    def update_config(self, config):\n        toolkit.add_template_directory(config, 'templates')\n        toolkit.add_public_directory(config, 'public')\n        toolkit.add_resource('fanstatic', 'hdx_theme')\n        \n\n    def before_map(self, map):\n        map.connect('home', '/', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='index')\n        map.connect('/count/dataset', controller='ckanext.hdx_theme.count:CountController', action='dataset')\n        map.connect('/count/country', controller='ckanext.hdx_theme.count:CountController', action='country')\n        map.connect('/count/source', controller='ckanext.hdx_theme.count:CountController', action='source')\n        map.connect('/user/logged_in', controller='ckanext.hdx_theme.login:LoginController', action='logged_in')\n        map.connect('/contribute', controller='ckanext.hdx_theme.login:LoginController', action='contribute')\n        \n        map.connect('/count/test', controller='ckanext.hdx_theme.count:CountController', action='test')\n        \n        map.connect('/organization/{id}/request_membership', controller='ckanext.hdx_theme.org_controller:HDXReqsOrgController', action='request_membership')\n        map.connect('/organization/members/{id}', controller='ckanext.hdx_theme.member_controller:HDXOrgMemberController', action='members')\n        map.connect('/dataset/preselect', controller='ckanext.hdx_theme.preselect_dsform_controller:HDXPreselectOrgController', action='preselect')\n\n        map.connect('/about/{page}', controller='ckanext.hdx_theme.splash_page:SplashPageController', action='about')\n        return map\n    \n    def create(self, entity):\n        caching.invalidate_group_caches()\n\n    def edit(self, entity):\n        caching.invalidate_group_caches()\n\n    def get_helpers(self):\n        from ckanext.hdx_theme import helpers as hdx_helpers\n        return {\n            'is_downloadable': hdx_helpers.is_downloadable,\n            'get_facet_items_dict':hdx_helpers.get_facet_items_dict,\n            'get_last_modifier_user': hdx_helpers.get_last_modifier_user,\n            'get_filtered_params_list':hdx_helpers.get_filtered_params_list,\n            'get_last_revision_package':hdx_helpers.get_last_revision_package,\n            'get_last_modifier_user':hdx_helpers.get_last_modifier_user,\n            'get_last_revision_group':hdx_helpers.get_last_revision_group,\n            'get_group_followers':hdx_helpers.get_group_followers,\n            'get_group_members':hdx_helpers.get_group_members,\n            'markdown_extract_strip':hdx_helpers.markdown_extract_strip,\n            'render_date_from_concat_str':hdx_helpers.render_date_from_concat_str,\n            'hdx_version':hdx_helpers.hdx_version,\n            'hdx_build_nav_icon_with_message':hdx_helpers.hdx_build_nav_icon_with_message,\n            'hdx_num_of_new_related_items':hdx_helpers.hdx_num_of_new_related_items,\n            'hdx_get_extras_element':hdx_helpers.hdx_get_extras_element,\n            'hdx_get_user_info':hdx_helpers.hdx_get_user_info,\n            'hdx_linked_user':hdx_helpers.hdx_linked_user,\n            'hdx_show_singular_plural':hdx_helpers.hdx_show_singular_plural,\n            'hdx_member_roles_list':hdx_helpers.hdx_member_roles_list\n            \n        }\n        \n    def get_actions(self):\n        from ckanext.hdx_theme import actions as hdx_actions\n        return {\n            'organization_list_for_user':hdx_actions.organization_list_for_user, \n            'cached_group_list': hdx_actions.cached_group_list,\n            'hdx_basic_user_info': hdx_actions.hdx_basic_user_info,\n            'member_list': hdx_actions.member_list,\n            'hdx_get_sys_admins': hdx_actions.hdx_get_sys_admins\n            \n        }\n    def get_auth_functions(self):\n        return {\n                'hdx_basic_user_info': auth.hdx_basic_user_info\n                }\n    \n    def make_middleware(self, app, config):\n        run_on_startup()\n        return app\n\n        \n        \n\n", "path": "ckanext-hdx_theme/ckanext/hdx_theme/plugin.py"}]}