prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  After pretend-facility, impersonate disappears from menu
  
  
  </issue>
  <code>
  [start of course/templatetags/coursetags.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 __copyright__ = "Copyright (C) 2016 Dong Zhuang, Andreas Kloeckner"
  4 
  5 __license__ = """
  6 Permission is hereby granted, free of charge, to any person obtaining a copy
  7 of this software and associated documentation files (the "Software"), to deal
  8 in the Software without restriction, including without limitation the rights
  9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10 copies of the Software, and to permit persons to whom the Software is
  11 furnished to do so, subject to the following conditions:
  12 
  13 The above copyright notice and this permission notice shall be included in
  14 all copies or substantial portions of the Software.
  15 
  16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22 THE SOFTWARE.
  23 """
  24 
  25 from django.template import Library, Node, TemplateSyntaxError
  26 from django.utils import translation
  27 
  28 register = Library()
  29 
  30 
  31 # {{{ get language_code in JS traditional naming format
  32 
  33 class GetCurrentLanguageJsFmtNode(Node):
  34     def __init__(self, variable):
  35         self.variable = variable
  36 
  37     def render(self, context):
  38         lang_name = (
  39             translation.to_locale(translation.get_language()).replace("_", "-"))
  40         context[self.variable] = lang_name
  41         return ''
  42 
  43 
  44 @register.tag("get_current_js_lang_name")
  45 def do_get_current_js_lang_name(parser, token):
  46     """
  47     This will store the current language in the context, in js lang format.
  48     This is different with built-in do_get_current_language, which returns
  49     languange name like "en-us", "zh-hans". This method return lang name
  50     "en-US", "zh-Hans",  with the country code capitallized if country code
  51     has 2 characters, and capitalize first if country code has more than 2
  52     characters.
  53 
  54     Usage::
  55 
  56         {% get_current_language_js_lang_format as language %}
  57 
  58     This will fetch the currently active language name with js tradition and
  59     put it's value into the ``language`` context variable.
  60     """
  61     # token.split_contents() isn't useful here because this tag doesn't
  62     # accept variable as arguments
  63     args = token.contents.split()
  64     if len(args) != 3 or args[1] != 'as':
  65         raise TemplateSyntaxError("'get_current_js_lang_name' requires "
  66                 "'as variable' (got %r)" % args)
  67     return GetCurrentLanguageJsFmtNode(args[2])
  68 
  69 
  70 @register.filter(name='js_lang_fallback')
  71 def js_lang_fallback(lang_name, js_name=None):
  72     """
  73     Return the fallback lang name for js files.
  74     :param a :class:`str:`
  75     :param js_name: a :class:`str:`, optional.
  76     :return: a :class:`str:`
  77     """
  78 
  79     # The mapping is crap, we use a special case table to fix it.
  80     if js_name == "fullcalendar":
  81         known_fallback_mapping = {
  82             "zh-hans": "zh-cn",
  83             "zh-hant": "zh-tw"}
  84         return known_fallback_mapping.get(lang_name.lower(), lang_name).lower()
  85 
  86     return lang_name
  87 
  88 # }}}
  89 
  90 
  91 # {{{ filter for participation.has_permission()
  92 
  93 @register.filter(name='has_permission')
  94 def has_permission(participation, arg):
  95     """
  96     Check if a participation instance has specific permission.
  97     :param participation: a :class:`participation:` instance
  98     :param arg: String, with permission and arguments separated by comma
  99     :return: a :class:`bool`
  100     """
  101     has_pperm = False
  102     try:
  103         arg_list = [s.strip() for s in arg.split(",")]
  104         perm = arg_list[0]
  105         argument = None
  106         if len(arg_list) > 1:
  107             argument = arg_list[1]
  108         has_pperm = participation.has_permission(perm, argument)
  109     except Exception:
  110         # fail silently
  111         pass
  112 
  113     return has_pperm
  114 
  115 # }}}
  116 
  117 
  118 @register.filter(name='commit_message_as_html')
  119 def commit_message_as_html(commit_sha, repo):
  120     from course.versioning import _get_commit_message_as_html
  121     return _get_commit_message_as_html(repo, commit_sha)
  122
  [end of course/templatetags/coursetags.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/course/templatetags/coursetags.py b/course/templatetags/coursetags.py
  --- a/course/templatetags/coursetags.py
  +++ b/course/templatetags/coursetags.py
  @@ -115,6 +115,28 @@
   # }}}
   
   
  +@register.filter(name='may_set_fake_time')
  +def may_set_fake_time(user):
  +    """
  +    Check if a user may set fake time.
  +    :param user: a :class:`accounts.User:` instance
  +    :return: a :class:`bool`
  +    """
  +    from course.views import may_set_fake_time as msf
  +    return msf(user)
  +
  +
  +@register.filter(name='may_set_pretend_facility')
  +def may_set_pretend_facility(user):
  +    """
  +    Check if a user may set pretend_facility
  +    :param user: a :class:`accounts.User:` instance
  +    :return: a :class:`bool`
  +    """
  +    from course.views import may_set_pretend_facility as mspf
  +    return mspf(user)
  +
  +
   @register.filter(name='commit_message_as_html')
   def commit_message_as_html(commit_sha, repo):
       from course.versioning import _get_commit_message_as_html
  
verification_info: {"golden_diff": "diff --git a/course/templatetags/coursetags.py b/course/templatetags/coursetags.py\n--- a/course/templatetags/coursetags.py\n+++ b/course/templatetags/coursetags.py\n@@ -115,6 +115,28 @@\n # }}}\n \n \n+@register.filter(name='may_set_fake_time')\n+def may_set_fake_time(user):\n+    \"\"\"\n+    Check if a user may set fake time.\n+    :param user: a :class:`accounts.User:` instance\n+    :return: a :class:`bool`\n+    \"\"\"\n+    from course.views import may_set_fake_time as msf\n+    return msf(user)\n+\n+\n+@register.filter(name='may_set_pretend_facility')\n+def may_set_pretend_facility(user):\n+    \"\"\"\n+    Check if a user may set pretend_facility\n+    :param user: a :class:`accounts.User:` instance\n+    :return: a :class:`bool`\n+    \"\"\"\n+    from course.views import may_set_pretend_facility as mspf\n+    return mspf(user)\n+\n+\n @register.filter(name='commit_message_as_html')\n def commit_message_as_html(commit_sha, repo):\n     from course.versioning import _get_commit_message_as_html\n", "issue": "After pretend-facility, impersonate disappears from menu\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n__copyright__ = \"Copyright (C) 2016 Dong Zhuang, Andreas Kloeckner\"\n\n__license__ = \"\"\"\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\"\"\"\n\nfrom django.template import Library, Node, TemplateSyntaxError\nfrom django.utils import translation\n\nregister = Library()\n\n\n# {{{ get language_code in JS traditional naming format\n\nclass GetCurrentLanguageJsFmtNode(Node):\n    def __init__(self, variable):\n        self.variable = variable\n\n    def render(self, context):\n        lang_name = (\n            translation.to_locale(translation.get_language()).replace(\"_\", \"-\"))\n        context[self.variable] = lang_name\n        return ''\n\n\n@register.tag(\"get_current_js_lang_name\")\ndef do_get_current_js_lang_name(parser, token):\n    \"\"\"\n    This will store the current language in the context, in js lang format.\n    This is different with built-in do_get_current_language, which returns\n    languange name like \"en-us\", \"zh-hans\". This method return lang name\n    \"en-US\", \"zh-Hans\",  with the country code capitallized if country code\n    has 2 characters, and capitalize first if country code has more than 2\n    characters.\n\n    Usage::\n\n        {% get_current_language_js_lang_format as language %}\n\n    This will fetch the currently active language name with js tradition and\n    put it's value into the ``language`` context variable.\n    \"\"\"\n    # token.split_contents() isn't useful here because this tag doesn't\n    # accept variable as arguments\n    args = token.contents.split()\n    if len(args) != 3 or args[1] != 'as':\n        raise TemplateSyntaxError(\"'get_current_js_lang_name' requires \"\n                \"'as variable' (got %r)\" % args)\n    return GetCurrentLanguageJsFmtNode(args[2])\n\n\n@register.filter(name='js_lang_fallback')\ndef js_lang_fallback(lang_name, js_name=None):\n    \"\"\"\n    Return the fallback lang name for js files.\n    :param a :class:`str:`\n    :param js_name: a :class:`str:`, optional.\n    :return: a :class:`str:`\n    \"\"\"\n\n    # The mapping is crap, we use a special case table to fix it.\n    if js_name == \"fullcalendar\":\n        known_fallback_mapping = {\n            \"zh-hans\": \"zh-cn\",\n            \"zh-hant\": \"zh-tw\"}\n        return known_fallback_mapping.get(lang_name.lower(), lang_name).lower()\n\n    return lang_name\n\n# }}}\n\n\n# {{{ filter for participation.has_permission()\n\n@register.filter(name='has_permission')\ndef has_permission(participation, arg):\n    \"\"\"\n    Check if a participation instance has specific permission.\n    :param participation: a :class:`participation:` instance\n    :param arg: String, with permission and arguments separated by comma\n    :return: a :class:`bool`\n    \"\"\"\n    has_pperm = False\n    try:\n        arg_list = [s.strip() for s in arg.split(\",\")]\n        perm = arg_list[0]\n        argument = None\n        if len(arg_list) > 1:\n            argument = arg_list[1]\n        has_pperm = participation.has_permission(perm, argument)\n    except Exception:\n        # fail silently\n        pass\n\n    return has_pperm\n\n# }}}\n\n\n@register.filter(name='commit_message_as_html')\ndef commit_message_as_html(commit_sha, repo):\n    from course.versioning import _get_commit_message_as_html\n    return _get_commit_message_as_html(repo, commit_sha)\n", "path": "course/templatetags/coursetags.py"}]}