prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Integração do SAPL 3.1 e Portal Modelo
  
  
  </issue>
  <code>
  [start of sapl/base/templatetags/common_tags.py]
  1 from compressor.utils import get_class
  2 from django import template
  3 
  4 from sapl.base.models import AppConfig
  5 from sapl.materia.models import DocumentoAcessorio, MateriaLegislativa
  6 from sapl.norma.models import NormaJuridica
  7 from sapl.parlamentares.models import Filiacao
  8 
  9 register = template.Library()
  10 
  11 
  12 @register.simple_tag
  13 def field_verbose_name(instance, field_name):
  14     return instance._meta.get_field(field_name).verbose_name
  15 
  16 
  17 @register.simple_tag
  18 def fieldclass_verbose_name(class_name, field_name):
  19     cls = get_class(class_name)
  20     return cls._meta.get_field(field_name).verbose_name
  21 
  22 
  23 @register.simple_tag
  24 def model_verbose_name(class_name):
  25     model = get_class(class_name)
  26     return model._meta.verbose_name
  27 
  28 
  29 @register.simple_tag
  30 def model_verbose_name_plural(class_name):
  31     model = get_class(class_name)
  32     return model._meta.verbose_name_plural
  33 
  34 
  35 @register.filter
  36 def lookup(d, key):
  37     return d[key] if key in d else []
  38 
  39 
  40 @register.filter
  41 def isinst(value, class_str):
  42     classe = value.__class__.__name__
  43     return classe == class_str
  44 
  45 
  46 @register.filter
  47 def get_add_perm(value, arg):
  48     perm = value
  49     view = arg
  50 
  51     try:
  52         nome_app = view.__class__.model._meta.app_label
  53     except AttributeError:
  54         return None
  55     nome_model = view.__class__.model.__name__.lower()
  56     can_add = '.add_' + nome_model
  57 
  58     return perm.__contains__(nome_app + can_add)
  59 
  60 
  61 @register.filter
  62 def get_change_perm(value, arg):
  63     perm = value
  64     view = arg
  65 
  66     try:
  67         nome_app = view.__class__.model._meta.app_label
  68     except AttributeError:
  69         return None
  70     nome_model = view.__class__.model.__name__.lower()
  71     can_change = '.change_' + nome_model
  72 
  73     return perm.__contains__(nome_app + can_change)
  74 
  75 
  76 @register.filter
  77 def get_delete_perm(value, arg):
  78     perm = value
  79     view = arg
  80 
  81     try:
  82         nome_app = view.__class__.model._meta.app_label
  83     except AttributeError:
  84         return None
  85     nome_model = view.__class__.model.__name__.lower()
  86     can_delete = '.delete_' + nome_model
  87 
  88     return perm.__contains__(nome_app + can_delete)
  89 
  90 
  91 @register.filter
  92 def ultima_filiacao(value):
  93     parlamentar = value
  94 
  95     ultima_filiacao = Filiacao.objects.filter(
  96         parlamentar=parlamentar).order_by('-data').first()
  97 
  98     if ultima_filiacao:
  99         return ultima_filiacao.partido
  100     else:
  101         return None
  102 
  103 
  104 @register.filter
  105 def get_config_attr(attribute):
  106     return AppConfig.attr(attribute)
  107 
  108 
  109 @register.filter
  110 def str2intabs(value):
  111     if not isinstance(value, str):
  112         return ''
  113     try:
  114         v = int(value)
  115         v = abs(v)
  116         return v
  117     except:
  118         return ''
  119 
  120 
  121 @register.filter
  122 def url(value):
  123     if value.startswith('http://') or value.startswith('https://'):
  124         return True
  125     return False
  126 
  127 
  128 @register.filter
  129 def cronometro_to_seconds(value):
  130     if not AppConfig.attr('cronometro_' + value):
  131         return 0
  132 
  133     m, s, x = AppConfig.attr(
  134         'cronometro_' + value).isoformat().split(':')
  135 
  136     return 60 * int(m) + int(s)
  137 
  138 
  139 @register.filter
  140 def to_list_pk(object_list):
  141     return [o.pk for o in object_list]
  142 
  143 
  144 @register.filter
  145 def search_get_model(object):
  146     if type(object) == MateriaLegislativa:
  147         return 'm'
  148     elif type(object) == DocumentoAcessorio:
  149         return 'd'
  150     elif type(object) == NormaJuridica:
  151         return 'n'
  152 
  153     return None
  154
  [end of sapl/base/templatetags/common_tags.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/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py
  --- a/sapl/base/templatetags/common_tags.py
  +++ b/sapl/base/templatetags/common_tags.py
  @@ -117,6 +117,23 @@
       except:
           return ''
   
  +@register.filter
  +def has_iframe(request):
  +
  +    iframe = request.session.get('iframe', False)
  +    if not iframe and 'iframe' in request.GET:
  +        ival = request.GET['iframe']
  +        if ival and int(ival) == 1:
  +            request.session['iframe'] = True
  +            return True
  +    elif 'iframe' in request.GET:
  +        ival = request.GET['iframe']
  +        if ival and int(ival) == 0:
  +            del request.session['iframe']
  +            return False
  +
  +    return iframe
  +
   
   @register.filter
   def url(value):
  
verification_info: {"golden_diff": "diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py\n--- a/sapl/base/templatetags/common_tags.py\n+++ b/sapl/base/templatetags/common_tags.py\n@@ -117,6 +117,23 @@\n     except:\n         return ''\n \n+@register.filter\n+def has_iframe(request):\n+\n+    iframe = request.session.get('iframe', False)\n+    if not iframe and 'iframe' in request.GET:\n+        ival = request.GET['iframe']\n+        if ival and int(ival) == 1:\n+            request.session['iframe'] = True\n+            return True\n+    elif 'iframe' in request.GET:\n+        ival = request.GET['iframe']\n+        if ival and int(ival) == 0:\n+            del request.session['iframe']\n+            return False\n+\n+    return iframe\n+\n \n @register.filter\n def url(value):\n", "issue": "Integra\u00e7\u00e3o do SAPL 3.1 e Portal Modelo\n\n", "before_files": [{"content": "from compressor.utils import get_class\nfrom django import template\n\nfrom sapl.base.models import AppConfig\nfrom sapl.materia.models import DocumentoAcessorio, MateriaLegislativa\nfrom sapl.norma.models import NormaJuridica\nfrom sapl.parlamentares.models import Filiacao\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef field_verbose_name(instance, field_name):\n    return instance._meta.get_field(field_name).verbose_name\n\n\n@register.simple_tag\ndef fieldclass_verbose_name(class_name, field_name):\n    cls = get_class(class_name)\n    return cls._meta.get_field(field_name).verbose_name\n\n\n@register.simple_tag\ndef model_verbose_name(class_name):\n    model = get_class(class_name)\n    return model._meta.verbose_name\n\n\n@register.simple_tag\ndef model_verbose_name_plural(class_name):\n    model = get_class(class_name)\n    return model._meta.verbose_name_plural\n\n\n@register.filter\ndef lookup(d, key):\n    return d[key] if key in d else []\n\n\n@register.filter\ndef isinst(value, class_str):\n    classe = value.__class__.__name__\n    return classe == class_str\n\n\n@register.filter\ndef get_add_perm(value, arg):\n    perm = value\n    view = arg\n\n    try:\n        nome_app = view.__class__.model._meta.app_label\n    except AttributeError:\n        return None\n    nome_model = view.__class__.model.__name__.lower()\n    can_add = '.add_' + nome_model\n\n    return perm.__contains__(nome_app + can_add)\n\n\n@register.filter\ndef get_change_perm(value, arg):\n    perm = value\n    view = arg\n\n    try:\n        nome_app = view.__class__.model._meta.app_label\n    except AttributeError:\n        return None\n    nome_model = view.__class__.model.__name__.lower()\n    can_change = '.change_' + nome_model\n\n    return perm.__contains__(nome_app + can_change)\n\n\n@register.filter\ndef get_delete_perm(value, arg):\n    perm = value\n    view = arg\n\n    try:\n        nome_app = view.__class__.model._meta.app_label\n    except AttributeError:\n        return None\n    nome_model = view.__class__.model.__name__.lower()\n    can_delete = '.delete_' + nome_model\n\n    return perm.__contains__(nome_app + can_delete)\n\n\n@register.filter\ndef ultima_filiacao(value):\n    parlamentar = value\n\n    ultima_filiacao = Filiacao.objects.filter(\n        parlamentar=parlamentar).order_by('-data').first()\n\n    if ultima_filiacao:\n        return ultima_filiacao.partido\n    else:\n        return None\n\n\n@register.filter\ndef get_config_attr(attribute):\n    return AppConfig.attr(attribute)\n\n\n@register.filter\ndef str2intabs(value):\n    if not isinstance(value, str):\n        return ''\n    try:\n        v = int(value)\n        v = abs(v)\n        return v\n    except:\n        return ''\n\n\n@register.filter\ndef url(value):\n    if value.startswith('http://') or value.startswith('https://'):\n        return True\n    return False\n\n\n@register.filter\ndef cronometro_to_seconds(value):\n    if not AppConfig.attr('cronometro_' + value):\n        return 0\n\n    m, s, x = AppConfig.attr(\n        'cronometro_' + value).isoformat().split(':')\n\n    return 60 * int(m) + int(s)\n\n\n@register.filter\ndef to_list_pk(object_list):\n    return [o.pk for o in object_list]\n\n\n@register.filter\ndef search_get_model(object):\n    if type(object) == MateriaLegislativa:\n        return 'm'\n    elif type(object) == DocumentoAcessorio:\n        return 'd'\n    elif type(object) == NormaJuridica:\n        return 'n'\n\n    return None\n", "path": "sapl/base/templatetags/common_tags.py"}]}