prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Tag pages still use old templates
  /tag
  
  
  </issue>
  <code>
  [start of ckan/controllers/tag.py]
  1 from pylons.i18n import _
  2 from pylons import request, c
  3 
  4 import ckan.logic as logic
  5 import ckan.model as model
  6 import ckan.lib.base as base
  7 import ckan.lib.helpers as h
  8 
  9 
  10 LIMIT = 25
  11 
  12 
  13 class TagController(base.BaseController):
  14 
  15     def __before__(self, action, **env):
  16         base.BaseController.__before__(self, action, **env)
  17         try:
  18             context = {'model': model, 'user': c.user or c.author}
  19             logic.check_access('site_read', context)
  20         except logic.NotAuthorized:
  21             base.abort(401, _('Not authorized to see this page'))
  22 
  23     def index(self):
  24         c.q = request.params.get('q', '')
  25 
  26         context = {'model': model, 'session': model.Session,
  27                    'user': c.user or c.author, 'for_view': True}
  28 
  29         data_dict = {'all_fields': True}
  30 
  31         if c.q:
  32             page = int(request.params.get('page', 1))
  33             data_dict['q'] = c.q
  34             data_dict['limit'] = LIMIT
  35             data_dict['offset'] = (page - 1) * LIMIT
  36             data_dict['return_objects'] = True
  37 
  38         results = logic.get_action('tag_list')(context, data_dict)
  39 
  40         if c.q:
  41             c.page = h.Page(
  42                 collection=results,
  43                 page=page,
  44                 item_count=len(results),
  45                 items_per_page=LIMIT
  46             )
  47             c.page.items = results
  48         else:
  49             c.page = h.AlphaPage(
  50                 collection=results,
  51                 page=request.params.get('page', 'A'),
  52                 alpha_attribute='name',
  53                 other_text=_('Other'),
  54             )
  55 
  56         return base.render('tag/index.html')
  57 
  58     def read(self, id):
  59         context = {'model': model, 'session': model.Session,
  60                    'user': c.user or c.author, 'for_view': True}
  61 
  62         data_dict = {'id': id}
  63         try:
  64             c.tag = logic.get_action('tag_show')(context, data_dict)
  65         except logic.NotFound:
  66             base.abort(404, _('Tag not found'))
  67 
  68         return base.render('tag/read.html')
  69
  [end of ckan/controllers/tag.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/ckan/controllers/tag.py b/ckan/controllers/tag.py
  --- a/ckan/controllers/tag.py
  +++ b/ckan/controllers/tag.py
  @@ -1,5 +1,5 @@
   from pylons.i18n import _
  -from pylons import request, c
  +from pylons import request, c, config
   
   import ckan.logic as logic
   import ckan.model as model
  @@ -65,4 +65,7 @@
           except logic.NotFound:
               base.abort(404, _('Tag not found'))
   
  -        return base.render('tag/read.html')
  +        if h.asbool(config.get('ckan.legacy_templates', False)):
  +            return base.render('tag/read.html')
  +        else:
  +            h.redirect_to(controller='package', action='search', tags=c.tag.get('name'))
  
verification_info: {"golden_diff": "diff --git a/ckan/controllers/tag.py b/ckan/controllers/tag.py\n--- a/ckan/controllers/tag.py\n+++ b/ckan/controllers/tag.py\n@@ -1,5 +1,5 @@\n from pylons.i18n import _\n-from pylons import request, c\n+from pylons import request, c, config\n \n import ckan.logic as logic\n import ckan.model as model\n@@ -65,4 +65,7 @@\n         except logic.NotFound:\n             base.abort(404, _('Tag not found'))\n \n-        return base.render('tag/read.html')\n+        if h.asbool(config.get('ckan.legacy_templates', False)):\n+            return base.render('tag/read.html')\n+        else:\n+            h.redirect_to(controller='package', action='search', tags=c.tag.get('name'))\n", "issue": "Tag pages still use old templates\n/tag\n\n", "before_files": [{"content": "from pylons.i18n import _\nfrom pylons import request, c\n\nimport ckan.logic as logic\nimport ckan.model as model\nimport ckan.lib.base as base\nimport ckan.lib.helpers as h\n\n\nLIMIT = 25\n\n\nclass TagController(base.BaseController):\n\n    def __before__(self, action, **env):\n        base.BaseController.__before__(self, action, **env)\n        try:\n            context = {'model': model, 'user': c.user or c.author}\n            logic.check_access('site_read', context)\n        except logic.NotAuthorized:\n            base.abort(401, _('Not authorized to see this page'))\n\n    def index(self):\n        c.q = request.params.get('q', '')\n\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True}\n\n        data_dict = {'all_fields': True}\n\n        if c.q:\n            page = int(request.params.get('page', 1))\n            data_dict['q'] = c.q\n            data_dict['limit'] = LIMIT\n            data_dict['offset'] = (page - 1) * LIMIT\n            data_dict['return_objects'] = True\n\n        results = logic.get_action('tag_list')(context, data_dict)\n\n        if c.q:\n            c.page = h.Page(\n                collection=results,\n                page=page,\n                item_count=len(results),\n                items_per_page=LIMIT\n            )\n            c.page.items = results\n        else:\n            c.page = h.AlphaPage(\n                collection=results,\n                page=request.params.get('page', 'A'),\n                alpha_attribute='name',\n                other_text=_('Other'),\n            )\n\n        return base.render('tag/index.html')\n\n    def read(self, id):\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True}\n\n        data_dict = {'id': id}\n        try:\n            c.tag = logic.get_action('tag_show')(context, data_dict)\n        except logic.NotFound:\n            base.abort(404, _('Tag not found'))\n\n        return base.render('tag/read.html')\n", "path": "ckan/controllers/tag.py"}]}