prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Implement GA tracking of downloads
  From Luis: 
  
  _I've done some research about how to track the number of downloads in the website. We can track those events using Google Analytics as you suggested. There is a slight change of code that has to be implemented following Google Analytic's developer manual [here](https://developers.google.com/analytics/devguides/collection/analyticsjs/events). It is a bit more refined than copying and pasting code, although at a glance it doesn't seem to be extremely complicated._
  
  
  </issue>
  <code>
  [start of ckanext-metadata_fields/ckanext/metadata_fields/plugin.py]
  1 '''
  2 Created on Apr 10, 2014
  3 
  4 @author:alexandru-m-g
  5 '''
  6 import logging
  7 
  8 import ckan.plugins as plugins
  9 import ckan.plugins.toolkit as tk
  10 from routes.mapper import SubMapper
  11 
  12 import ckanext.metadata_fields.custom_validator as vd
  13 import ckanext.metadata_fields.update as update
  14 
  15 def list_of_all_groups():
  16     groups  = tk.get_action('group_list')(data_dict={'all_fields': True})
  17     return groups
  18 
  19 
  20 class HdxMetadataFieldsPlugin(plugins.SingletonPlugin, tk.DefaultDatasetForm):
  21     plugins.implements(plugins.IConfigurer, inherit=False)
  22     plugins.implements(plugins.IRoutes, inherit=True)
  23     plugins.implements(plugins.IDatasetForm, inherit=False)
  24     plugins.implements(plugins.ITemplateHelpers)
  25     plugins.implements(plugins.IActions)
  26 
  27     def update_config(self, config):
  28         tk.add_template_directory(config, 'templates')
  29 
  30     def before_map(self, map):
  31         with SubMapper(map, controller='ckanext.metadata_fields.dataset_controller:DatasetController') as m:
  32             m.connect('add dataset', '/dataset/new', action='new')
  33             m.connect('/dataset/{action}/{id}',
  34                   requirements=dict(action='|'.join([
  35                       'new_metadata',
  36                       'new_resource',
  37                       ])))
  38         return map
  39         
  40     def is_fallback(self):
  41         return True
  42 
  43     def package_types(self):
  44         # default - no specific package type
  45         return []
  46 
  47     def _modify_package_schema(self, schema):
  48         
  49         schema.update({
  50                 'package_creator': [tk.get_validator('not_empty'),
  51                     tk.get_converter('convert_to_extras')],
  52                 'groups_list': [vd.groups_not_empty],
  53             'caveats' : [tk.get_validator('ignore_missing'),
  54                     tk.get_converter('convert_to_extras')],
  55             'dataset_source' : [tk.get_validator('not_empty'),
  56                     tk.get_converter('convert_to_extras')],
  57             'dataset_date' : [tk.get_validator('ignore_missing'),
  58                     tk.get_converter('convert_to_extras')],
  59             'methodology' : [tk.get_validator('ignore_missing'),
  60                     tk.get_converter('convert_to_extras')],
  61             })
  62 
  63         return schema
  64 
  65 
  66     def create_package_schema(self):
  67         schema = super(HdxMetadataFieldsPlugin, self).create_package_schema()
  68         schema = self._modify_package_schema(schema)
  69         return schema
  70 
  71     def update_package_schema(self):
  72         schema = super(HdxMetadataFieldsPlugin, self).update_package_schema()
  73         schema = self._modify_package_schema(schema)
  74         return schema
  75 
  76     def show_package_schema(self):
  77         schema = super(HdxMetadataFieldsPlugin, self).show_package_schema()
  78 
  79         schema.update({
  80             'package_creator': [tk.get_converter('convert_from_extras'),
  81                 tk.get_validator('ignore_missing')],
  82             'caveats' : [tk.get_converter('convert_from_extras'),
  83                 tk.get_validator('ignore_missing')],
  84             'dataset_source' : [tk.get_converter('convert_from_extras'),
  85                 tk.get_validator('ignore_missing')],
  86             'dataset_date' : [tk.get_converter('convert_from_extras'),
  87                 tk.get_validator('ignore_missing')],
  88             'methodology' : [tk.get_converter('convert_from_extras'),
  89                 tk.get_validator('ignore_missing')],
  90             })
  91         return schema
  92         
  93     
  94     def get_helpers(self):
  95         return {'list_of_all_groups': list_of_all_groups}
  96     
  97     def get_actions(self):
  98         return {'package_update': update.package_update}
  99 
  100 
  101
  [end of ckanext-metadata_fields/ckanext/metadata_fields/plugin.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py b/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py
  --- a/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py
  +++ b/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py
  @@ -47,6 +47,7 @@
       def _modify_package_schema(self, schema):
           
           schema.update({
  +                'notes': [tk.get_validator('not_empty')], #Notes == description. Makes description required
                   'package_creator': [tk.get_validator('not_empty'),
                       tk.get_converter('convert_to_extras')],
                   'groups_list': [vd.groups_not_empty],
  @@ -75,8 +76,8 @@
   
       def show_package_schema(self):
           schema = super(HdxMetadataFieldsPlugin, self).show_package_schema()
  -
           schema.update({
  +            'notes': [tk.get_validator('not_empty')], #Notes == description. Makes description required
               'package_creator': [tk.get_converter('convert_from_extras'),
                   tk.get_validator('ignore_missing')],
               'caveats' : [tk.get_converter('convert_from_extras'),
  
verification_info: {"golden_diff": "diff --git a/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py b/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py\n--- a/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py\n+++ b/ckanext-metadata_fields/ckanext/metadata_fields/plugin.py\n@@ -47,6 +47,7 @@\n     def _modify_package_schema(self, schema):\n         \n         schema.update({\n+                'notes': [tk.get_validator('not_empty')], #Notes == description. Makes description required\n                 'package_creator': [tk.get_validator('not_empty'),\n                     tk.get_converter('convert_to_extras')],\n                 'groups_list': [vd.groups_not_empty],\n@@ -75,8 +76,8 @@\n \n     def show_package_schema(self):\n         schema = super(HdxMetadataFieldsPlugin, self).show_package_schema()\n-\n         schema.update({\n+            'notes': [tk.get_validator('not_empty')], #Notes == description. Makes description required\n             'package_creator': [tk.get_converter('convert_from_extras'),\n                 tk.get_validator('ignore_missing')],\n             'caveats' : [tk.get_converter('convert_from_extras'),\n", "issue": "Implement GA tracking of downloads\nFrom Luis: \n\n_I've done some research about how to track the number of downloads in the website. We can track those events using Google Analytics as you suggested. There is a slight change of code that has to be implemented following Google Analytic's developer manual [here](https://developers.google.com/analytics/devguides/collection/analyticsjs/events). It is a bit more refined than copying and pasting code, although at a glance it doesn't seem to be extremely complicated._\n\n", "before_files": [{"content": "'''\nCreated on Apr 10, 2014\n\n@author:alexandru-m-g\n'''\nimport logging\n\nimport ckan.plugins as plugins\nimport ckan.plugins.toolkit as tk\nfrom routes.mapper import SubMapper\n\nimport ckanext.metadata_fields.custom_validator as vd\nimport ckanext.metadata_fields.update as update\n\ndef list_of_all_groups():\n    groups  = tk.get_action('group_list')(data_dict={'all_fields': True})\n    return groups\n\n\nclass HdxMetadataFieldsPlugin(plugins.SingletonPlugin, tk.DefaultDatasetForm):\n    plugins.implements(plugins.IConfigurer, inherit=False)\n    plugins.implements(plugins.IRoutes, inherit=True)\n    plugins.implements(plugins.IDatasetForm, inherit=False)\n    plugins.implements(plugins.ITemplateHelpers)\n    plugins.implements(plugins.IActions)\n\n    def update_config(self, config):\n        tk.add_template_directory(config, 'templates')\n\n    def before_map(self, map):\n        with SubMapper(map, controller='ckanext.metadata_fields.dataset_controller:DatasetController') as m:\n            m.connect('add dataset', '/dataset/new', action='new')\n            m.connect('/dataset/{action}/{id}',\n                  requirements=dict(action='|'.join([\n                      'new_metadata',\n                      'new_resource',\n                      ])))\n        return map\n        \n    def is_fallback(self):\n        return True\n\n    def package_types(self):\n        # default - no specific package type\n        return []\n\n    def _modify_package_schema(self, schema):\n        \n        schema.update({\n                'package_creator': [tk.get_validator('not_empty'),\n                    tk.get_converter('convert_to_extras')],\n                'groups_list': [vd.groups_not_empty],\n            'caveats' : [tk.get_validator('ignore_missing'),\n                    tk.get_converter('convert_to_extras')],\n            'dataset_source' : [tk.get_validator('not_empty'),\n                    tk.get_converter('convert_to_extras')],\n            'dataset_date' : [tk.get_validator('ignore_missing'),\n                    tk.get_converter('convert_to_extras')],\n            'methodology' : [tk.get_validator('ignore_missing'),\n                    tk.get_converter('convert_to_extras')],\n            })\n\n        return schema\n\n\n    def create_package_schema(self):\n        schema = super(HdxMetadataFieldsPlugin, self).create_package_schema()\n        schema = self._modify_package_schema(schema)\n        return schema\n\n    def update_package_schema(self):\n        schema = super(HdxMetadataFieldsPlugin, self).update_package_schema()\n        schema = self._modify_package_schema(schema)\n        return schema\n\n    def show_package_schema(self):\n        schema = super(HdxMetadataFieldsPlugin, self).show_package_schema()\n\n        schema.update({\n            'package_creator': [tk.get_converter('convert_from_extras'),\n                tk.get_validator('ignore_missing')],\n            'caveats' : [tk.get_converter('convert_from_extras'),\n                tk.get_validator('ignore_missing')],\n            'dataset_source' : [tk.get_converter('convert_from_extras'),\n                tk.get_validator('ignore_missing')],\n            'dataset_date' : [tk.get_converter('convert_from_extras'),\n                tk.get_validator('ignore_missing')],\n            'methodology' : [tk.get_converter('convert_from_extras'),\n                tk.get_validator('ignore_missing')],\n            })\n        return schema\n        \n    \n    def get_helpers(self):\n        return {'list_of_all_groups': list_of_all_groups}\n    \n    def get_actions(self):\n        return {'package_update': update.package_update}\n\n\n", "path": "ckanext-metadata_fields/ckanext/metadata_fields/plugin.py"}]}