We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Search and Dataset List Pages:  Move the filter button
Move the filter button on /search and /dataset so that it apears as part of the search input in main nav:
https://cloud.githubusercontent.com/assets/1654485/5780030/a25eaeb6-9da7-11e4-9e5e-bdca79e549ab.png

When open, the filter button remains in the same place but has a "-" added to indicate that it can be closed.  SVGs will be linked below shortly.
- Open filter button: https://drive.google.com/file/d/0Bx1KWNTx8Ij3SW42UEFNaTdFQXc/view?usp=sharing
- Close filter button: https://drive.google.com/file/d/0Bx1KWNTx8Ij3NzdEXzFmRlJZZU0/view?usp=sharing

Let me know if these SVGs cause any problem.  They are filled black, but I can easily change that. 

Default Country Page: graphs section 
Blocked by #2102 and #2103 
Annotated (very annotated) design is here: 
https://docs.google.com/drawings/d/1qOBKZ7IO7zkEMHh2g3ZiAynh5PiAbO-_-SL4rd9uO_M/edit
Implement the section with 5 graphs


--- 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_org_group/ckanext/hdx_org_group/controllers/country_controller.py`
Content:
```
1 '''
2 Created on Jan 13, 2015
3 
4 @author: alexandru-m-g
5 '''
6 import json
7 
8 import logging
9 import datetime as dt
10 
11 import ckan.lib.base as base
12 import ckan.logic as logic
13 import ckan.model as model
14 import ckan.common as common
15 import ckan.controllers.group as group
16 
17 render = base.render
18 abort = base.abort
19 NotFound = logic.NotFound
20 NotAuthorized = logic.NotAuthorized
21 get_action = logic.get_action
22 c = common.c
23 request = common.request
24 _ = common._
25 
26 
27 log = logging.getLogger(__name__)
28 
29 group_type = 'group'
30 
31 indicators_4_charts = ['PVH140', 'PVN010', 'PVW010', 'PVF020',
32                        'PSE160', 'PCX051', 'PVE130', 'PCX060',
33                        'RW002', 'PVE110', 'PVN050', 'PVN070',
34                        'PVW040']
35 # http://localhost:8080/public/api2/values?it=PSP120&it=PSP090&l=CHN&sorting=INDICATOR_TYPE_ASC
36 
37 indicators_4_top_line = ['PSP120', 'PSP090', 'PSE220', 'PSE030',
38                          'CG300']
39 # http://localhost:8080/public/api2/values?it=PSP120&l=CHN&periodType=LATEST_YEAR
40 
41 
42 class CountryController(group.GroupController):
43 
44     def read(self, id):
45         self.get_country(id)
46         self.get_dataset_results(c.group_dict.get('name', id))
47 
48         # activity stream
49         context = {'model': model, 'session': model.Session,
50                    'user': c.user or c.author,
51                    'for_view': True}
52         country_uuid = c.group_dict.get('id', id)
53         self.get_activity_stream(context, country_uuid)
54 
55         return render('country/country.html')
56 
57     def get_country(self, id):
58         if group_type != self.group_type:
59             abort(404, _('Incorrect group type'))
60 
61         context = {'model': model, 'session': model.Session,
62                    'user': c.user or c.author,
63                    'schema': self._db_to_form_schema(group_type=group_type),
64                    'for_view': True}
65         data_dict = {'id': id}
66 
67         try:
68             context['include_datasets'] = False
69             c.group_dict = self._action('group_show')(context, data_dict)
70             c.group = context['group']
71         except NotFound:
72             abort(404, _('Group not found'))
73         except NotAuthorized:
74             abort(401, _('Unauthorized to read group %s') % id)
75 
76 
77     def get_dataset_results(self, country_id):
78         upper_case_id = country_id.upper()
79         top_line_results = self._get_top_line_num(upper_case_id)
80         top_line_data = top_line_results.get('results', [])
81 
82         if not top_line_data:
83             log.warn('No top line numbers found for country: {}'.format(country_id))
84 
85         sorted_top_line_data = sorted(top_line_data,
86                                       key=lambda x: indicators_4_top_line.index(x['indicatorTypeCode']))
87 
88         c.top_line_data_list = sorted_top_line_data
89 
90         chart_results = self._get_chart_data(upper_case_id)
91         chart_data = chart_results.get('results', [])
92         if not chart_data:
93             log.warn('No chart data found for country: {}'.format(country_id))
94         chart_data_dict = {}
95 
96         # for el in chart_data:
97         #     ind_type = el.get('indicatorTypeCode', None)
98         #     if ind_type:
99         #         d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')
100         #         el['datetime'] = d
101         #         if ind_type in chart_data_dict:
102         #             chart_data_dict[ind_type].append(el)
103         #         else:
104         #             chart_data_dict[ind_type] = [el]
105 
106         for el in chart_data:
107             ind_type = el.get('indicatorTypeCode', None)
108             if ind_type:
109                 # d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')
110                 val = {
111                     'date': el.get('time'),
112                     'value': el.get('value')
113                 }
114 
115                 if ind_type in chart_data_dict:
116                     chart_data_dict[ind_type]['data'].append(val);
117                 else:
118                     newel = {
119                         'title': el.get('unitName'),
120                         'code': ind_type,
121                         'data': [val]
122                     }
123                     chart_data_dict[ind_type] = newel
124 
125 
126 
127         # for code in chart_data_dict.keys():
128         #     chart_data_dict[code] = sorted(chart_data_dict[code], key=lambda x: x.get('datetime', None))
129 
130         for code in chart_data_dict.keys():
131             chart_data_dict[code]['data'] = json.dumps(chart_data_dict[code]['data'])
132 
133         chart_data_list = []
134         for code in indicators_4_charts:
135             if code in chart_data_dict and len(chart_data_list) < 5:
136                 chart_data_list.append(chart_data_dict[code])
137 
138         c.chart_data_list = chart_data_list
139 
140         # c.chart_data_dict = chart_data_dict
141 
142     def _get_chart_data(self, country_id):
143         data_dict = {
144             'sorting': 'INDICATOR_TYPE_ASC',
145             'l': country_id,
146             'it': indicators_4_charts
147         }
148         result = get_action('hdx_get_indicator_values')({}, data_dict)
149         return result
150 
151     def _get_top_line_num(self, country_id):
152         data_dict = {
153             'periodType': 'LATEST_YEAR',
154             'l': country_id,
155             'it': indicators_4_top_line
156         }
157         result = get_action('hdx_get_indicator_values')({}, data_dict)
158         return result
159 
160     def get_activity_stream(self, context, country_id):
161         act_data_dict = {'id': country_id, 'limit': 7}
162         c.hdx_group_activities = get_action(
163             'hdx_get_group_activity_list')(context, act_data_dict)
164
```
--- 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_org_group/ckanext/hdx_org_group/controllers/country_controller.py b/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py
--- a/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py
+++ b/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py
@@ -107,18 +107,35 @@
             ind_type = el.get('indicatorTypeCode', None)
             if ind_type:
                 # d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')
+                el_time = el.get('time')
+                el_value = el.get('value')
                 val = {
-                    'date': el.get('time'),
-                    'value': el.get('value')
+                    'date': el_time,
+                    'value': el_value
                 }
 
                 if ind_type in chart_data_dict:
                     chart_data_dict[ind_type]['data'].append(val);
+
+                    last_date = dt.datetime.strptime(chart_data_dict[ind_type]['lastDate'], '%Y-%m-%d')
+                    curr_date = dt.datetime.strptime(el_time, '%Y-%m-%d')
+
+                    if last_date < curr_date:
+                        chart_data_dict[ind_type]['lastDate'] = el_time
+                        chart_data_dict[ind_type]['lastValue'] = el_value
+
                 else:
                     newel = {
-                        'title': el.get('unitName'),
+                        'title': el.get('indicatorTypeName'),
+                        'sourceName': el.get('sourceName'),
+                        'sourceCode': el.get('sourceCode'),
+                        'lastDate': el_time,
+                        'lastValue': el_value,
+                        'unit': el.get('unitName'),
                         'code': ind_type,
-                        'data': [val]
+                        'data': [val],
+                        'datasetLink': '/todo/changeme',
+                        'datasetUpdateDate': 'Jun 21, 1985'
                     }
                     chart_data_dict[ind_type] = newel

{"golden_diff": "diff --git a/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py b/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py\n--- a/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py\n+++ b/ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py\n@@ -107,18 +107,35 @@\n             ind_type = el.get('indicatorTypeCode', None)\n             if ind_type:\n                 # d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')\n+                el_time = el.get('time')\n+                el_value = el.get('value')\n                 val = {\n-                    'date': el.get('time'),\n-                    'value': el.get('value')\n+                    'date': el_time,\n+                    'value': el_value\n                 }\n \n                 if ind_type in chart_data_dict:\n                     chart_data_dict[ind_type]['data'].append(val);\n+\n+                    last_date = dt.datetime.strptime(chart_data_dict[ind_type]['lastDate'], '%Y-%m-%d')\n+                    curr_date = dt.datetime.strptime(el_time, '%Y-%m-%d')\n+\n+                    if last_date < curr_date:\n+                        chart_data_dict[ind_type]['lastDate'] = el_time\n+                        chart_data_dict[ind_type]['lastValue'] = el_value\n+\n                 else:\n                     newel = {\n-                        'title': el.get('unitName'),\n+                        'title': el.get('indicatorTypeName'),\n+                        'sourceName': el.get('sourceName'),\n+                        'sourceCode': el.get('sourceCode'),\n+                        'lastDate': el_time,\n+                        'lastValue': el_value,\n+                        'unit': el.get('unitName'),\n                         'code': ind_type,\n-                        'data': [val]\n+                        'data': [val],\n+                        'datasetLink': '/todo/changeme',\n+                        'datasetUpdateDate': 'Jun 21, 1985'\n                     }\n                     chart_data_dict[ind_type] = newel\n", "issue": "Search and Dataset List Pages:  Move the filter button\nMove the filter button on /search and /dataset so that it apears as part of the search input in main nav:\nhttps://cloud.githubusercontent.com/assets/1654485/5780030/a25eaeb6-9da7-11e4-9e5e-bdca79e549ab.png\n\nWhen open, the filter button remains in the same place but has a \"-\" added to indicate that it can be closed.  SVGs will be linked below shortly.\n- Open filter button: https://drive.google.com/file/d/0Bx1KWNTx8Ij3SW42UEFNaTdFQXc/view?usp=sharing\n- Close filter button: https://drive.google.com/file/d/0Bx1KWNTx8Ij3NzdEXzFmRlJZZU0/view?usp=sharing\n\nLet me know if these SVGs cause any problem.  They are filled black, but I can easily change that. \n\nDefault Country Page: graphs section \nBlocked by #2102 and #2103 \nAnnotated (very annotated) design is here: \nhttps://docs.google.com/drawings/d/1qOBKZ7IO7zkEMHh2g3ZiAynh5PiAbO-_-SL4rd9uO_M/edit\nImplement the section with 5 graphs\n\n", "before_files": [{"content": "'''\nCreated on Jan 13, 2015\n\n@author: alexandru-m-g\n'''\nimport json\n\nimport logging\nimport datetime as dt\n\nimport ckan.lib.base as base\nimport ckan.logic as logic\nimport ckan.model as model\nimport ckan.common as common\nimport ckan.controllers.group as group\n\nrender = base.render\nabort = base.abort\nNotFound = logic.NotFound\nNotAuthorized = logic.NotAuthorized\nget_action = logic.get_action\nc = common.c\nrequest = common.request\n_ = common._\n\n\nlog = logging.getLogger(__name__)\n\ngroup_type = 'group'\n\nindicators_4_charts = ['PVH140', 'PVN010', 'PVW010', 'PVF020',\n                       'PSE160', 'PCX051', 'PVE130', 'PCX060',\n                       'RW002', 'PVE110', 'PVN050', 'PVN070',\n                       'PVW040']\n# http://localhost:8080/public/api2/values?it=PSP120&it=PSP090&l=CHN&sorting=INDICATOR_TYPE_ASC\n\nindicators_4_top_line = ['PSP120', 'PSP090', 'PSE220', 'PSE030',\n                         'CG300']\n# http://localhost:8080/public/api2/values?it=PSP120&l=CHN&periodType=LATEST_YEAR\n\n\nclass CountryController(group.GroupController):\n\n    def read(self, id):\n        self.get_country(id)\n        self.get_dataset_results(c.group_dict.get('name', id))\n\n        # activity stream\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author,\n                   'for_view': True}\n        country_uuid = c.group_dict.get('id', id)\n        self.get_activity_stream(context, country_uuid)\n\n        return render('country/country.html')\n\n    def get_country(self, id):\n        if group_type != self.group_type:\n            abort(404, _('Incorrect group type'))\n\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author,\n                   'schema': self._db_to_form_schema(group_type=group_type),\n                   'for_view': True}\n        data_dict = {'id': id}\n\n        try:\n            context['include_datasets'] = False\n            c.group_dict = self._action('group_show')(context, data_dict)\n            c.group = context['group']\n        except NotFound:\n            abort(404, _('Group not found'))\n        except NotAuthorized:\n            abort(401, _('Unauthorized to read group %s') % id)\n\n\n    def get_dataset_results(self, country_id):\n        upper_case_id = country_id.upper()\n        top_line_results = self._get_top_line_num(upper_case_id)\n        top_line_data = top_line_results.get('results', [])\n\n        if not top_line_data:\n            log.warn('No top line numbers found for country: {}'.format(country_id))\n\n        sorted_top_line_data = sorted(top_line_data,\n                                      key=lambda x: indicators_4_top_line.index(x['indicatorTypeCode']))\n\n        c.top_line_data_list = sorted_top_line_data\n\n        chart_results = self._get_chart_data(upper_case_id)\n        chart_data = chart_results.get('results', [])\n        if not chart_data:\n            log.warn('No chart data found for country: {}'.format(country_id))\n        chart_data_dict = {}\n\n        # for el in chart_data:\n        #     ind_type = el.get('indicatorTypeCode', None)\n        #     if ind_type:\n        #         d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')\n        #         el['datetime'] = d\n        #         if ind_type in chart_data_dict:\n        #             chart_data_dict[ind_type].append(el)\n        #         else:\n        #             chart_data_dict[ind_type] = [el]\n\n        for el in chart_data:\n            ind_type = el.get('indicatorTypeCode', None)\n            if ind_type:\n                # d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')\n                val = {\n                    'date': el.get('time'),\n                    'value': el.get('value')\n                }\n\n                if ind_type in chart_data_dict:\n                    chart_data_dict[ind_type]['data'].append(val);\n                else:\n                    newel = {\n                        'title': el.get('unitName'),\n                        'code': ind_type,\n                        'data': [val]\n                    }\n                    chart_data_dict[ind_type] = newel\n\n\n\n        # for code in chart_data_dict.keys():\n        #     chart_data_dict[code] = sorted(chart_data_dict[code], key=lambda x: x.get('datetime', None))\n\n        for code in chart_data_dict.keys():\n            chart_data_dict[code]['data'] = json.dumps(chart_data_dict[code]['data'])\n\n        chart_data_list = []\n        for code in indicators_4_charts:\n            if code in chart_data_dict and len(chart_data_list) < 5:\n                chart_data_list.append(chart_data_dict[code])\n\n        c.chart_data_list = chart_data_list\n\n        # c.chart_data_dict = chart_data_dict\n\n    def _get_chart_data(self, country_id):\n        data_dict = {\n            'sorting': 'INDICATOR_TYPE_ASC',\n            'l': country_id,\n            'it': indicators_4_charts\n        }\n        result = get_action('hdx_get_indicator_values')({}, data_dict)\n        return result\n\n    def _get_top_line_num(self, country_id):\n        data_dict = {\n            'periodType': 'LATEST_YEAR',\n            'l': country_id,\n            'it': indicators_4_top_line\n        }\n        result = get_action('hdx_get_indicator_values')({}, data_dict)\n        return result\n\n    def get_activity_stream(self, context, country_id):\n        act_data_dict = {'id': country_id, 'limit': 7}\n        c.hdx_group_activities = get_action(\n            'hdx_get_group_activity_list')(context, act_data_dict)\n", "path": "ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py"}], "after_files": [{"content": "'''\nCreated on Jan 13, 2015\n\n@author: alexandru-m-g\n'''\nimport json\n\nimport logging\nimport datetime as dt\n\nimport ckan.lib.base as base\nimport ckan.logic as logic\nimport ckan.model as model\nimport ckan.common as common\nimport ckan.controllers.group as group\n\nrender = base.render\nabort = base.abort\nNotFound = logic.NotFound\nNotAuthorized = logic.NotAuthorized\nget_action = logic.get_action\nc = common.c\nrequest = common.request\n_ = common._\n\n\nlog = logging.getLogger(__name__)\n\ngroup_type = 'group'\n\nindicators_4_charts = ['PVH140', 'PVN010', 'PVW010', 'PVF020',\n                       'PSE160', 'PCX051', 'PVE130', 'PCX060',\n                       'RW002', 'PVE110', 'PVN050', 'PVN070',\n                       'PVW040']\n# http://localhost:8080/public/api2/values?it=PSP120&it=PSP090&l=CHN&sorting=INDICATOR_TYPE_ASC\n\nindicators_4_top_line = ['PSP120', 'PSP090', 'PSE220', 'PSE030',\n                         'CG300']\n# http://localhost:8080/public/api2/values?it=PSP120&l=CHN&periodType=LATEST_YEAR\n\n\nclass CountryController(group.GroupController):\n\n    def read(self, id):\n        self.get_country(id)\n        self.get_dataset_results(c.group_dict.get('name', id))\n\n        # activity stream\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author,\n                   'for_view': True}\n        country_uuid = c.group_dict.get('id', id)\n        self.get_activity_stream(context, country_uuid)\n\n        return render('country/country.html')\n\n    def get_country(self, id):\n        if group_type != self.group_type:\n            abort(404, _('Incorrect group type'))\n\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author,\n                   'schema': self._db_to_form_schema(group_type=group_type),\n                   'for_view': True}\n        data_dict = {'id': id}\n\n        try:\n            context['include_datasets'] = False\n            c.group_dict = self._action('group_show')(context, data_dict)\n            c.group = context['group']\n        except NotFound:\n            abort(404, _('Group not found'))\n        except NotAuthorized:\n            abort(401, _('Unauthorized to read group %s') % id)\n\n\n    def get_dataset_results(self, country_id):\n        upper_case_id = country_id.upper()\n        top_line_results = self._get_top_line_num(upper_case_id)\n        top_line_data = top_line_results.get('results', [])\n\n        if not top_line_data:\n            log.warn('No top line numbers found for country: {}'.format(country_id))\n\n        sorted_top_line_data = sorted(top_line_data,\n                                      key=lambda x: indicators_4_top_line.index(x['indicatorTypeCode']))\n\n        c.top_line_data_list = sorted_top_line_data\n\n        chart_results = self._get_chart_data(upper_case_id)\n        chart_data = chart_results.get('results', [])\n        if not chart_data:\n            log.warn('No chart data found for country: {}'.format(country_id))\n        chart_data_dict = {}\n\n        # for el in chart_data:\n        #     ind_type = el.get('indicatorTypeCode', None)\n        #     if ind_type:\n        #         d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')\n        #         el['datetime'] = d\n        #         if ind_type in chart_data_dict:\n        #             chart_data_dict[ind_type].append(el)\n        #         else:\n        #             chart_data_dict[ind_type] = [el]\n\n        for el in chart_data:\n            ind_type = el.get('indicatorTypeCode', None)\n            if ind_type:\n                # d = dt.datetime.strptime(el.get('time', ''), '%Y-%m-%d')\n                el_time = el.get('time')\n                el_value = el.get('value')\n                val = {\n                    'date': el_time,\n                    'value': el_value\n                }\n\n                if ind_type in chart_data_dict:\n                    chart_data_dict[ind_type]['data'].append(val);\n\n                    last_date = dt.datetime.strptime(chart_data_dict[ind_type]['lastDate'], '%Y-%m-%d')\n                    curr_date = dt.datetime.strptime(el_time, '%Y-%m-%d')\n\n                    if last_date < curr_date:\n                        chart_data_dict[ind_type]['lastDate'] = el_time\n                        chart_data_dict[ind_type]['lastValue'] = el_value\n\n                else:\n                    newel = {\n                        'title': el.get('indicatorTypeName'),\n                        'sourceName': el.get('sourceName'),\n                        'sourceCode': el.get('sourceCode'),\n                        'lastDate': el_time,\n                        'lastValue': el_value,\n                        'unit': el.get('unitName'),\n                        'code': ind_type,\n                        'data': [val],\n                        'datasetLink': '/todo/changeme',\n                        'datasetUpdateDate': 'Jun 21, 1985'\n                    }\n                    chart_data_dict[ind_type] = newel\n\n\n\n        # for code in chart_data_dict.keys():\n        #     chart_data_dict[code] = sorted(chart_data_dict[code], key=lambda x: x.get('datetime', None))\n\n        for code in chart_data_dict.keys():\n            chart_data_dict[code]['data'] = json.dumps(chart_data_dict[code]['data'])\n\n        chart_data_list = []\n        for code in indicators_4_charts:\n            if code in chart_data_dict and len(chart_data_list) < 5:\n                chart_data_list.append(chart_data_dict[code])\n\n        c.chart_data_list = chart_data_list\n\n        # c.chart_data_dict = chart_data_dict\n\n    def _get_chart_data(self, country_id):\n        data_dict = {\n            'sorting': 'INDICATOR_TYPE_ASC',\n            'l': country_id,\n            'it': indicators_4_charts\n        }\n        result = get_action('hdx_get_indicator_values')({}, data_dict)\n        return result\n\n    def _get_top_line_num(self, country_id):\n        data_dict = {\n            'periodType': 'LATEST_YEAR',\n            'l': country_id,\n            'it': indicators_4_top_line\n        }\n        result = get_action('hdx_get_indicator_values')({}, data_dict)\n        return result\n\n    def get_activity_stream(self, context, country_id):\n        act_data_dict = {'id': country_id, 'limit': 7}\n        c.hdx_group_activities = get_action(\n            'hdx_get_group_activity_list')(context, act_data_dict)\n", "path": "ckanext-hdx_org_group/ckanext/hdx_org_group/controllers/country_controller.py"}]}