prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Deal with breadcrumbs
  As Greg mentioned in #296, he hadn't liked the way breadcrumbs repeat current page title (or header) in their last element, for example: page "Event 2015-05-25-something" will have breadcrumbs "Amy / All events / Event 2015-05-25-something".
  
  I took a look at other big websites and how they do breadcrumbs and @gvwilson was right. They don't repeat current site at the end of breadcrumbs.
  
  This means we'd only have breadcrumbs at most 3 links long: Amy / All \* / \* [ / action ], for example:
  
  Was:
  - Amy / All events / Event 2015-05-25-something / Edit
  
  Will be:
  - Amy / All events / Event 2015-05-25-something
  
  But this does not bug me. In case of `All *` pages, we can just as well drop breadcrumbs (because they'd look like "Amy / ").
  
  So I don't really know what to do:
  1. Display breadcrumbs on the same pages as now, but hide the last item.
  2. Display breadcrumbs on the pages that would have more than 1 breadcrumbs.
  3. Drop breadcrumbs completely.
  
  
  </issue>
  <code>
  [start of workshops/templatetags/breadcrumbs.py]
  1 import logging
  2 
  3 from django import template
  4 from django.core.urlresolvers import reverse
  5 from django.utils.encoding import force_text
  6 from django.utils.html import escape
  7 
  8 register = template.Library()
  9 _LOG = logging.getLogger(__name__)
  10 
  11 
  12 @register.simple_tag
  13 def breadcrumb(title, url):
  14     '''
  15     Create a simple anchor with provided text and already-resolved URL.
  16     Example usage:
  17         {% breadcrumb "Title of breadcrumb" resolved_url %}
  18     '''
  19     return create_crumb(title, url)
  20 
  21 
  22 @register.simple_tag
  23 def breadcrumb_url(title, url_name):
  24     '''
  25     Add non-active breadcrumb with specified title.  Second argument should be
  26     a string name of URL that needs to be resolved.
  27     Example usage:
  28         {% breadcrumb_url "Title of breadcrumb" url_name %}
  29     '''
  30     url = reverse(url_name)
  31     return create_crumb(title, url)
  32 
  33 
  34 @register.simple_tag
  35 def breadcrumb_active(title):
  36     '''
  37     Add active breadcrumb, but not in an anchor.
  38     Example usage:
  39         {% breadcrumb_active "Title of breadcrumb" %}
  40     '''
  41     return create_crumb(str(title), url=None, active=True)
  42 
  43 
  44 @register.simple_tag
  45 def breadcrumb_index_all_objects(model):
  46     '''
  47     Add breadcrumb linking to the listing of all objects of specific type.
  48     This tag accepts both models or model instances as an argument.
  49     Example usage:
  50         {% breadcrumb_index_all_objects model %}
  51         {% breadcrumb_index_all_objects person %}
  52     '''
  53     plural = force_text(model._meta.verbose_name_plural)
  54     title = 'All {}'.format(plural)
  55     url_name = 'all_{}'.format(plural)
  56     url = reverse(url_name)
  57     return create_crumb(title, url)
  58 
  59 
  60 @register.simple_tag
  61 def breadcrumb_edit_object(obj):
  62     '''
  63     Add an active breadcrumb with the title "Edit MODEL_NAME".
  64     This tag accepts model instance as an argument.
  65     Example usage:
  66         {% breadcrumb_edit_object person %}
  67     '''
  68     singular = force_text(obj._meta.verbose_name)
  69     title = 'Edit {}'.format(singular)
  70     return create_crumb(title, url=None, active=True)
  71 
  72 
  73 @register.simple_tag
  74 def breadcrumb_new_object(model):
  75     '''
  76     Add an active breadcrumb with the title "Add new MODEL_NAME".
  77     This tag accepts model class as an argument.
  78     Example usage:
  79         {% breadcrumb_new_object person %}
  80     '''
  81     singular = force_text(model._meta.verbose_name)
  82     title = 'Add new {}'.format(singular)
  83     return create_crumb(title, url=None, active=True)
  84 
  85 
  86 @register.simple_tag
  87 def breadcrumb_object(obj):
  88     '''
  89     Add non-active breadcrumb with the title "Add new MODEL_NAME".
  90     This tag accepts model instance as an argument.
  91     Example usage:
  92         {% breadcrumb_object person %}
  93     '''
  94     title = str(obj)
  95     url = obj.get_absolute_url()
  96     return create_crumb(title, url, active=False)
  97 
  98 
  99 @register.simple_tag
  100 def breadcrumb_main_page():
  101     '''
  102     Special case of ``breadcrumb_url``.  In all templates there's always a link
  103     to the main page so I wanted to save everyone thinking & writing by
  104     introducing this helper tag.
  105     Example usage:
  106         {% breadcrumb_main_page %}
  107     '''
  108     title = 'Amy'
  109     url = reverse('index')
  110     return create_crumb(title, url)
  111 
  112 
  113 def create_crumb(title, url=None, active=False):
  114     '''
  115     Helper function that creates breadcrumb.
  116     '''
  117     active_str = ''
  118     if active:
  119         active_str = ' class="active"'
  120 
  121     title = escape(title)
  122     inner_str = title
  123     if url:
  124         inner_str = '<a href="{0}">{1}</a>'.format(url, title)
  125 
  126     crumb = '<li{0}>{1}</li>'.format(active_str, inner_str)
  127 
  128     return crumb
  129
  [end of workshops/templatetags/breadcrumbs.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/workshops/templatetags/breadcrumbs.py b/workshops/templatetags/breadcrumbs.py
  deleted file mode 100644
  --- a/workshops/templatetags/breadcrumbs.py
  +++ /dev/null
  @@ -1,128 +0,0 @@
  -import logging
  -
  -from django import template
  -from django.core.urlresolvers import reverse
  -from django.utils.encoding import force_text
  -from django.utils.html import escape
  -
  -register = template.Library()
  -_LOG = logging.getLogger(__name__)
  -
  -
  -@register.simple_tag
  -def breadcrumb(title, url):
  -    '''
  -    Create a simple anchor with provided text and already-resolved URL.
  -    Example usage:
  -        {% breadcrumb "Title of breadcrumb" resolved_url %}
  -    '''
  -    return create_crumb(title, url)
  -
  -
  -@register.simple_tag
  -def breadcrumb_url(title, url_name):
  -    '''
  -    Add non-active breadcrumb with specified title.  Second argument should be
  -    a string name of URL that needs to be resolved.
  -    Example usage:
  -        {% breadcrumb_url "Title of breadcrumb" url_name %}
  -    '''
  -    url = reverse(url_name)
  -    return create_crumb(title, url)
  -
  -
  -@register.simple_tag
  -def breadcrumb_active(title):
  -    '''
  -    Add active breadcrumb, but not in an anchor.
  -    Example usage:
  -        {% breadcrumb_active "Title of breadcrumb" %}
  -    '''
  -    return create_crumb(str(title), url=None, active=True)
  -
  -
  -@register.simple_tag
  -def breadcrumb_index_all_objects(model):
  -    '''
  -    Add breadcrumb linking to the listing of all objects of specific type.
  -    This tag accepts both models or model instances as an argument.
  -    Example usage:
  -        {% breadcrumb_index_all_objects model %}
  -        {% breadcrumb_index_all_objects person %}
  -    '''
  -    plural = force_text(model._meta.verbose_name_plural)
  -    title = 'All {}'.format(plural)
  -    url_name = 'all_{}'.format(plural)
  -    url = reverse(url_name)
  -    return create_crumb(title, url)
  -
  -
  -@register.simple_tag
  -def breadcrumb_edit_object(obj):
  -    '''
  -    Add an active breadcrumb with the title "Edit MODEL_NAME".
  -    This tag accepts model instance as an argument.
  -    Example usage:
  -        {% breadcrumb_edit_object person %}
  -    '''
  -    singular = force_text(obj._meta.verbose_name)
  -    title = 'Edit {}'.format(singular)
  -    return create_crumb(title, url=None, active=True)
  -
  -
  -@register.simple_tag
  -def breadcrumb_new_object(model):
  -    '''
  -    Add an active breadcrumb with the title "Add new MODEL_NAME".
  -    This tag accepts model class as an argument.
  -    Example usage:
  -        {% breadcrumb_new_object person %}
  -    '''
  -    singular = force_text(model._meta.verbose_name)
  -    title = 'Add new {}'.format(singular)
  -    return create_crumb(title, url=None, active=True)
  -
  -
  -@register.simple_tag
  -def breadcrumb_object(obj):
  -    '''
  -    Add non-active breadcrumb with the title "Add new MODEL_NAME".
  -    This tag accepts model instance as an argument.
  -    Example usage:
  -        {% breadcrumb_object person %}
  -    '''
  -    title = str(obj)
  -    url = obj.get_absolute_url()
  -    return create_crumb(title, url, active=False)
  -
  -
  -@register.simple_tag
  -def breadcrumb_main_page():
  -    '''
  -    Special case of ``breadcrumb_url``.  In all templates there's always a link
  -    to the main page so I wanted to save everyone thinking & writing by
  -    introducing this helper tag.
  -    Example usage:
  -        {% breadcrumb_main_page %}
  -    '''
  -    title = 'Amy'
  -    url = reverse('index')
  -    return create_crumb(title, url)
  -
  -
  -def create_crumb(title, url=None, active=False):
  -    '''
  -    Helper function that creates breadcrumb.
  -    '''
  -    active_str = ''
  -    if active:
  -        active_str = ' class="active"'
  -
  -    title = escape(title)
  -    inner_str = title
  -    if url:
  -        inner_str = '<a href="{0}">{1}</a>'.format(url, title)
  -
  -    crumb = '<li{0}>{1}</li>'.format(active_str, inner_str)
  -
  -    return crumb
  
verification_info: {"golden_diff": "diff --git a/workshops/templatetags/breadcrumbs.py b/workshops/templatetags/breadcrumbs.py\ndeleted file mode 100644\n--- a/workshops/templatetags/breadcrumbs.py\n+++ /dev/null\n@@ -1,128 +0,0 @@\n-import logging\n-\n-from django import template\n-from django.core.urlresolvers import reverse\n-from django.utils.encoding import force_text\n-from django.utils.html import escape\n-\n-register = template.Library()\n-_LOG = logging.getLogger(__name__)\n-\n-\n-@register.simple_tag\n-def breadcrumb(title, url):\n-    '''\n-    Create a simple anchor with provided text and already-resolved URL.\n-    Example usage:\n-        {% breadcrumb \"Title of breadcrumb\" resolved_url %}\n-    '''\n-    return create_crumb(title, url)\n-\n-\n-@register.simple_tag\n-def breadcrumb_url(title, url_name):\n-    '''\n-    Add non-active breadcrumb with specified title.  Second argument should be\n-    a string name of URL that needs to be resolved.\n-    Example usage:\n-        {% breadcrumb_url \"Title of breadcrumb\" url_name %}\n-    '''\n-    url = reverse(url_name)\n-    return create_crumb(title, url)\n-\n-\n-@register.simple_tag\n-def breadcrumb_active(title):\n-    '''\n-    Add active breadcrumb, but not in an anchor.\n-    Example usage:\n-        {% breadcrumb_active \"Title of breadcrumb\" %}\n-    '''\n-    return create_crumb(str(title), url=None, active=True)\n-\n-\n-@register.simple_tag\n-def breadcrumb_index_all_objects(model):\n-    '''\n-    Add breadcrumb linking to the listing of all objects of specific type.\n-    This tag accepts both models or model instances as an argument.\n-    Example usage:\n-        {% breadcrumb_index_all_objects model %}\n-        {% breadcrumb_index_all_objects person %}\n-    '''\n-    plural = force_text(model._meta.verbose_name_plural)\n-    title = 'All {}'.format(plural)\n-    url_name = 'all_{}'.format(plural)\n-    url = reverse(url_name)\n-    return create_crumb(title, url)\n-\n-\n-@register.simple_tag\n-def breadcrumb_edit_object(obj):\n-    '''\n-    Add an active breadcrumb with the title \"Edit MODEL_NAME\".\n-    This tag accepts model instance as an argument.\n-    Example usage:\n-        {% breadcrumb_edit_object person %}\n-    '''\n-    singular = force_text(obj._meta.verbose_name)\n-    title = 'Edit {}'.format(singular)\n-    return create_crumb(title, url=None, active=True)\n-\n-\n-@register.simple_tag\n-def breadcrumb_new_object(model):\n-    '''\n-    Add an active breadcrumb with the title \"Add new MODEL_NAME\".\n-    This tag accepts model class as an argument.\n-    Example usage:\n-        {% breadcrumb_new_object person %}\n-    '''\n-    singular = force_text(model._meta.verbose_name)\n-    title = 'Add new {}'.format(singular)\n-    return create_crumb(title, url=None, active=True)\n-\n-\n-@register.simple_tag\n-def breadcrumb_object(obj):\n-    '''\n-    Add non-active breadcrumb with the title \"Add new MODEL_NAME\".\n-    This tag accepts model instance as an argument.\n-    Example usage:\n-        {% breadcrumb_object person %}\n-    '''\n-    title = str(obj)\n-    url = obj.get_absolute_url()\n-    return create_crumb(title, url, active=False)\n-\n-\n-@register.simple_tag\n-def breadcrumb_main_page():\n-    '''\n-    Special case of ``breadcrumb_url``.  In all templates there's always a link\n-    to the main page so I wanted to save everyone thinking & writing by\n-    introducing this helper tag.\n-    Example usage:\n-        {% breadcrumb_main_page %}\n-    '''\n-    title = 'Amy'\n-    url = reverse('index')\n-    return create_crumb(title, url)\n-\n-\n-def create_crumb(title, url=None, active=False):\n-    '''\n-    Helper function that creates breadcrumb.\n-    '''\n-    active_str = ''\n-    if active:\n-        active_str = ' class=\"active\"'\n-\n-    title = escape(title)\n-    inner_str = title\n-    if url:\n-        inner_str = '<a href=\"{0}\">{1}</a>'.format(url, title)\n-\n-    crumb = '<li{0}>{1}</li>'.format(active_str, inner_str)\n-\n-    return crumb\n", "issue": "Deal with breadcrumbs\nAs Greg mentioned in #296, he hadn't liked the way breadcrumbs repeat current page title (or header) in their last element, for example: page \"Event 2015-05-25-something\" will have breadcrumbs \"Amy / All events / Event 2015-05-25-something\".\n\nI took a look at other big websites and how they do breadcrumbs and @gvwilson was right. They don't repeat current site at the end of breadcrumbs.\n\nThis means we'd only have breadcrumbs at most 3 links long: Amy / All \\* / \\* [ / action ], for example:\n\nWas:\n- Amy / All events / Event 2015-05-25-something / Edit\n\nWill be:\n- Amy / All events / Event 2015-05-25-something\n\nBut this does not bug me. In case of `All *` pages, we can just as well drop breadcrumbs (because they'd look like \"Amy / \").\n\nSo I don't really know what to do:\n1. Display breadcrumbs on the same pages as now, but hide the last item.\n2. Display breadcrumbs on the pages that would have more than 1 breadcrumbs.\n3. Drop breadcrumbs completely.\n\n", "before_files": [{"content": "import logging\n\nfrom django import template\nfrom django.core.urlresolvers import reverse\nfrom django.utils.encoding import force_text\nfrom django.utils.html import escape\n\nregister = template.Library()\n_LOG = logging.getLogger(__name__)\n\n\n@register.simple_tag\ndef breadcrumb(title, url):\n    '''\n    Create a simple anchor with provided text and already-resolved URL.\n    Example usage:\n        {% breadcrumb \"Title of breadcrumb\" resolved_url %}\n    '''\n    return create_crumb(title, url)\n\n\n@register.simple_tag\ndef breadcrumb_url(title, url_name):\n    '''\n    Add non-active breadcrumb with specified title.  Second argument should be\n    a string name of URL that needs to be resolved.\n    Example usage:\n        {% breadcrumb_url \"Title of breadcrumb\" url_name %}\n    '''\n    url = reverse(url_name)\n    return create_crumb(title, url)\n\n\n@register.simple_tag\ndef breadcrumb_active(title):\n    '''\n    Add active breadcrumb, but not in an anchor.\n    Example usage:\n        {% breadcrumb_active \"Title of breadcrumb\" %}\n    '''\n    return create_crumb(str(title), url=None, active=True)\n\n\n@register.simple_tag\ndef breadcrumb_index_all_objects(model):\n    '''\n    Add breadcrumb linking to the listing of all objects of specific type.\n    This tag accepts both models or model instances as an argument.\n    Example usage:\n        {% breadcrumb_index_all_objects model %}\n        {% breadcrumb_index_all_objects person %}\n    '''\n    plural = force_text(model._meta.verbose_name_plural)\n    title = 'All {}'.format(plural)\n    url_name = 'all_{}'.format(plural)\n    url = reverse(url_name)\n    return create_crumb(title, url)\n\n\n@register.simple_tag\ndef breadcrumb_edit_object(obj):\n    '''\n    Add an active breadcrumb with the title \"Edit MODEL_NAME\".\n    This tag accepts model instance as an argument.\n    Example usage:\n        {% breadcrumb_edit_object person %}\n    '''\n    singular = force_text(obj._meta.verbose_name)\n    title = 'Edit {}'.format(singular)\n    return create_crumb(title, url=None, active=True)\n\n\n@register.simple_tag\ndef breadcrumb_new_object(model):\n    '''\n    Add an active breadcrumb with the title \"Add new MODEL_NAME\".\n    This tag accepts model class as an argument.\n    Example usage:\n        {% breadcrumb_new_object person %}\n    '''\n    singular = force_text(model._meta.verbose_name)\n    title = 'Add new {}'.format(singular)\n    return create_crumb(title, url=None, active=True)\n\n\n@register.simple_tag\ndef breadcrumb_object(obj):\n    '''\n    Add non-active breadcrumb with the title \"Add new MODEL_NAME\".\n    This tag accepts model instance as an argument.\n    Example usage:\n        {% breadcrumb_object person %}\n    '''\n    title = str(obj)\n    url = obj.get_absolute_url()\n    return create_crumb(title, url, active=False)\n\n\n@register.simple_tag\ndef breadcrumb_main_page():\n    '''\n    Special case of ``breadcrumb_url``.  In all templates there's always a link\n    to the main page so I wanted to save everyone thinking & writing by\n    introducing this helper tag.\n    Example usage:\n        {% breadcrumb_main_page %}\n    '''\n    title = 'Amy'\n    url = reverse('index')\n    return create_crumb(title, url)\n\n\ndef create_crumb(title, url=None, active=False):\n    '''\n    Helper function that creates breadcrumb.\n    '''\n    active_str = ''\n    if active:\n        active_str = ' class=\"active\"'\n\n    title = escape(title)\n    inner_str = title\n    if url:\n        inner_str = '<a href=\"{0}\">{1}</a>'.format(url, title)\n\n    crumb = '<li{0}>{1}</li>'.format(active_str, inner_str)\n\n    return crumb\n", "path": "workshops/templatetags/breadcrumbs.py"}]}