prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Sem acesso anônimo de Documento Acessório de Audiencia Pública 
  <!--- Forneça um resumo geral da _issue_ no título acima -->
  
  ## Comportamento Esperado
  Usuários anônimos poderem acessar documento acessório das Audiências Públicas 
  
  ## Comportamento Atual
  Usuário anônimo não acessa a parte de "Documento Acessório" da Audiência Pública pedindo um login com a aplicação de documento administrativo "Restritiva", acredito que Audiência Pública não deveria se enquadrar nessa regra.
  
  ## Passos para Reproduzir (para bugs)
  <!--- Forneça um link para um exemplo, ou um conjunto de passos inequívocos -->
  <!--- para reproduzir esse bug. Inclua código para reproduzir, se relevante. -->
  1. Com opção de Visibilidade de Documentos Administrativos "Restritiva" -Está deslogado - Institucional - Audiências Públicas - Acessar uma audiência cadastrada - clicar em Documento Acessório
  
  <!-- ## Imagens do Ocorrido -->
  
  ## Seu Ambiente
  <!--- Inclua detalhes relevantes sobre o ambiente em que você presenciou/experienciou o bug. -->
  * Versão usada (_Release_): 3.1.143
  * Nome e versão do navegador: Chrome
  * Nome e versão do Sistema Operacional (desktop ou mobile): Windows 10
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sapl/audiencia/views.py`
  Content:
  ```
  1 import sapl
  2 
  3 from django.http import HttpResponse
  4 from django.core.urlresolvers import reverse
  5 from django.views.decorators.clickjacking import xframe_options_exempt
  6 from django.views.generic import UpdateView
  7 from sapl.crud.base import RP_DETAIL, RP_LIST, Crud, MasterDetailCrud
  8 
  9 from .forms import AudienciaForm, AnexoAudienciaPublicaForm
  10 from .models import AudienciaPublica, AnexoAudienciaPublica
  11 
  12 
  13 def index(request):
  14     return HttpResponse("Audiência  Pública")
  15 
  16 
  17 class AudienciaCrud(Crud):
  18     model = AudienciaPublica
  19     public = [RP_LIST, RP_DETAIL, ]
  20 
  21     class BaseMixin(Crud.BaseMixin):
  22         list_field_names = ['numero', 'nome', 'tipo', 'materia',
  23                             'data'] 
  24         ordering = 'nome', 'numero', 'tipo', 'data'
  25 
  26     class ListView(Crud.ListView):
  27         paginate_by = 10
  28 
  29         def get_context_data(self, **kwargs):
  30             context = super().get_context_data(**kwargs)
  31 
  32             audiencia_materia = {}
  33             for o in context['object_list']:
  34                 # indexado pelo numero da audiencia
  35                 audiencia_materia[str(o.numero)] = o.materia
  36 
  37             for row in context['rows']:
  38                 coluna_materia = row[3] # se mudar a ordem de listagem mudar aqui
  39                 if coluna_materia[0]:
  40                     materia = audiencia_materia[row[0][0]]
  41                     url_materia = reverse('sapl.materia:materialegislativa_detail',
  42                                           kwargs={'pk': materia.id})
  43                     row[3] = (coluna_materia[0], url_materia)
  44             return context
  45 
  46     class CreateView(Crud.CreateView):
  47         form_class = AudienciaForm
  48 
  49         def form_valid(self, form):
  50             return super(Crud.CreateView, self).form_valid(form)
  51 
  52     class UpdateView(Crud.UpdateView):
  53         form_class = AudienciaForm
  54 
  55         def get_initial(self):
  56             initial = super(UpdateView, self).get_initial()
  57             if self.object.materia:
  58                 initial['tipo_materia'] = self.object.materia.tipo.id
  59                 initial['numero_materia'] = self.object.materia.numero
  60                 initial['ano_materia'] = self.object.materia.ano
  61             return initial
  62      
  63     class DeleteView(Crud.DeleteView):
  64         pass
  65 
  66     class DetailView(Crud.DetailView):
  67 
  68         layout_key = 'AudienciaPublicaDetail'
  69 
  70         @xframe_options_exempt
  71         def get(self, request, *args, **kwargs):
  72             return super().get(request, *args, **kwargs)
  73 
  74 
  75 class AudienciaPublicaMixin:
  76 
  77     def has_permission(self):
  78         app_config = sapl.base.models.AppConfig.objects.last()
  79         if app_config and app_config.documentos_administrativos == 'O':
  80             return True
  81 
  82         return super().has_permission()
  83 
  84 
  85 class AnexoAudienciaPublicaCrud(MasterDetailCrud):
  86     model = AnexoAudienciaPublica
  87     parent_field = 'audiencia'
  88     help_topic = 'numeracao_docsacess'
  89 
  90     class BaseMixin(MasterDetailCrud.BaseMixin):
  91         list_field_names = ['assunto']
  92 
  93     class CreateView(MasterDetailCrud.CreateView):
  94         form_class = AnexoAudienciaPublicaForm
  95         layout_key = None
  96 
  97     class UpdateView(MasterDetailCrud.UpdateView):
  98         form_class = AnexoAudienciaPublicaForm
  99 
  100     class ListView(AudienciaPublicaMixin, MasterDetailCrud.ListView):
  101 
  102         def get_queryset(self):
  103             qs = super(MasterDetailCrud.ListView, self).get_queryset()
  104             kwargs = {self.crud.parent_field: self.kwargs['pk']}
  105             return qs.filter(**kwargs).order_by('-data', '-id')
  106 
  107     class DetailView(AudienciaPublicaMixin,
  108                      MasterDetailCrud.DetailView):
  109         pass
  110
  ```
  
  Path: `sapl/audiencia/urls.py`
  Content:
  ```
  1 from django.conf.urls import include, url
  2 from sapl.audiencia.views import (index, AudienciaCrud,AnexoAudienciaPublicaCrud)
  3 
  4 from .apps import AppConfig
  5 
  6 app_name = AppConfig.name
  7 
  8 urlpatterns = [
  9     url(r'^audiencia/', include(AudienciaCrud.get_urls() +
  10     							AnexoAudienciaPublicaCrud.get_urls())),
  11 ]
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sapl/audiencia/urls.py b/sapl/audiencia/urls.py
  --- a/sapl/audiencia/urls.py
  +++ b/sapl/audiencia/urls.py
  @@ -1,11 +1,10 @@
   from django.conf.urls import include, url
  -from sapl.audiencia.views import (index, AudienciaCrud,AnexoAudienciaPublicaCrud)
  +from sapl.audiencia.views import (index, AudienciaCrud, AnexoAudienciaPublicaCrud)
   
   from .apps import AppConfig
   
   app_name = AppConfig.name
   
   urlpatterns = [
  -    url(r'^audiencia/', include(AudienciaCrud.get_urls() +
  -    							AnexoAudienciaPublicaCrud.get_urls())),
  +    url(r'^audiencia/', include(AudienciaCrud.get_urls() + AnexoAudienciaPublicaCrud.get_urls())),
   ]
  \ No newline at end of file
  diff --git a/sapl/audiencia/views.py b/sapl/audiencia/views.py
  --- a/sapl/audiencia/views.py
  +++ b/sapl/audiencia/views.py
  @@ -86,6 +86,7 @@
       model = AnexoAudienciaPublica
       parent_field = 'audiencia'
       help_topic = 'numeracao_docsacess'
  +    public = [RP_LIST, RP_DETAIL, ]
   
       class BaseMixin(MasterDetailCrud.BaseMixin):
           list_field_names = ['assunto']
  @@ -104,7 +105,5 @@
               kwargs = {self.crud.parent_field: self.kwargs['pk']}
               return qs.filter(**kwargs).order_by('-data', '-id')
   
  -    class DetailView(AudienciaPublicaMixin,
  -                     MasterDetailCrud.DetailView):
  +    class DetailView(AudienciaPublicaMixin, MasterDetailCrud.DetailView):
           pass
  -    
  \ No newline at end of file
  
verification_info: {"golden_diff": "diff --git a/sapl/audiencia/urls.py b/sapl/audiencia/urls.py\n--- a/sapl/audiencia/urls.py\n+++ b/sapl/audiencia/urls.py\n@@ -1,11 +1,10 @@\n from django.conf.urls import include, url\n-from sapl.audiencia.views import (index, AudienciaCrud,AnexoAudienciaPublicaCrud)\n+from sapl.audiencia.views import (index, AudienciaCrud, AnexoAudienciaPublicaCrud)\n \n from .apps import AppConfig\n \n app_name = AppConfig.name\n \n urlpatterns = [\n-    url(r'^audiencia/', include(AudienciaCrud.get_urls() +\n-    \t\t\t\t\t\t\tAnexoAudienciaPublicaCrud.get_urls())),\n+    url(r'^audiencia/', include(AudienciaCrud.get_urls() + AnexoAudienciaPublicaCrud.get_urls())),\n ]\n\\ No newline at end of file\ndiff --git a/sapl/audiencia/views.py b/sapl/audiencia/views.py\n--- a/sapl/audiencia/views.py\n+++ b/sapl/audiencia/views.py\n@@ -86,6 +86,7 @@\n     model = AnexoAudienciaPublica\n     parent_field = 'audiencia'\n     help_topic = 'numeracao_docsacess'\n+    public = [RP_LIST, RP_DETAIL, ]\n \n     class BaseMixin(MasterDetailCrud.BaseMixin):\n         list_field_names = ['assunto']\n@@ -104,7 +105,5 @@\n             kwargs = {self.crud.parent_field: self.kwargs['pk']}\n             return qs.filter(**kwargs).order_by('-data', '-id')\n \n-    class DetailView(AudienciaPublicaMixin,\n-                     MasterDetailCrud.DetailView):\n+    class DetailView(AudienciaPublicaMixin, MasterDetailCrud.DetailView):\n         pass\n-    \n\\ No newline at end of file\n", "issue": "Sem acesso an\u00f4nimo de Documento Acess\u00f3rio de Audiencia P\u00fablica \n<!--- Forne\u00e7a um resumo geral da _issue_ no t\u00edtulo acima -->\r\n\r\n## Comportamento Esperado\r\nUsu\u00e1rios an\u00f4nimos poderem acessar documento acess\u00f3rio das Audi\u00eancias P\u00fablicas \r\n\r\n## Comportamento Atual\r\nUsu\u00e1rio an\u00f4nimo n\u00e3o acessa a parte de \"Documento Acess\u00f3rio\" da Audi\u00eancia P\u00fablica pedindo um login com a aplica\u00e7\u00e3o de documento administrativo \"Restritiva\", acredito que Audi\u00eancia P\u00fablica n\u00e3o deveria se enquadrar nessa regra.\r\n\r\n## Passos para Reproduzir (para bugs)\r\n<!--- Forne\u00e7a um link para um exemplo, ou um conjunto de passos inequ\u00edvocos -->\r\n<!--- para reproduzir esse bug. Inclua c\u00f3digo para reproduzir, se relevante. -->\r\n1. Com op\u00e7\u00e3o de Visibilidade de Documentos Administrativos \"Restritiva\" -Est\u00e1 deslogado - Institucional - Audi\u00eancias P\u00fablicas - Acessar uma audi\u00eancia cadastrada - clicar em Documento Acess\u00f3rio\r\n\r\n<!-- ## Imagens do Ocorrido -->\r\n\r\n## Seu Ambiente\r\n<!--- Inclua detalhes relevantes sobre o ambiente em que voc\u00ea presenciou/experienciou o bug. -->\r\n* Vers\u00e3o usada (_Release_): 3.1.143\r\n* Nome e vers\u00e3o do navegador: Chrome\r\n* Nome e vers\u00e3o do Sistema Operacional (desktop ou mobile): Windows 10\r\n\n", "before_files": [{"content": "import sapl\n\nfrom django.http import HttpResponse\nfrom django.core.urlresolvers import reverse\nfrom django.views.decorators.clickjacking import xframe_options_exempt\nfrom django.views.generic import UpdateView\nfrom sapl.crud.base import RP_DETAIL, RP_LIST, Crud, MasterDetailCrud\n\nfrom .forms import AudienciaForm, AnexoAudienciaPublicaForm\nfrom .models import AudienciaPublica, AnexoAudienciaPublica\n\n\ndef index(request):\n    return HttpResponse(\"Audi\u00eancia  P\u00fablica\")\n\n\nclass AudienciaCrud(Crud):\n    model = AudienciaPublica\n    public = [RP_LIST, RP_DETAIL, ]\n\n    class BaseMixin(Crud.BaseMixin):\n        list_field_names = ['numero', 'nome', 'tipo', 'materia',\n                            'data'] \n        ordering = 'nome', 'numero', 'tipo', 'data'\n\n    class ListView(Crud.ListView):\n        paginate_by = 10\n\n        def get_context_data(self, **kwargs):\n            context = super().get_context_data(**kwargs)\n\n            audiencia_materia = {}\n            for o in context['object_list']:\n                # indexado pelo numero da audiencia\n                audiencia_materia[str(o.numero)] = o.materia\n\n            for row in context['rows']:\n                coluna_materia = row[3] # se mudar a ordem de listagem mudar aqui\n                if coluna_materia[0]:\n                    materia = audiencia_materia[row[0][0]]\n                    url_materia = reverse('sapl.materia:materialegislativa_detail',\n                                          kwargs={'pk': materia.id})\n                    row[3] = (coluna_materia[0], url_materia)\n            return context\n\n    class CreateView(Crud.CreateView):\n        form_class = AudienciaForm\n\n        def form_valid(self, form):\n            return super(Crud.CreateView, self).form_valid(form)\n\n    class UpdateView(Crud.UpdateView):\n        form_class = AudienciaForm\n\n        def get_initial(self):\n            initial = super(UpdateView, self).get_initial()\n            if self.object.materia:\n                initial['tipo_materia'] = self.object.materia.tipo.id\n                initial['numero_materia'] = self.object.materia.numero\n                initial['ano_materia'] = self.object.materia.ano\n            return initial\n     \n    class DeleteView(Crud.DeleteView):\n        pass\n\n    class DetailView(Crud.DetailView):\n\n        layout_key = 'AudienciaPublicaDetail'\n\n        @xframe_options_exempt\n        def get(self, request, *args, **kwargs):\n            return super().get(request, *args, **kwargs)\n\n\nclass AudienciaPublicaMixin:\n\n    def has_permission(self):\n        app_config = sapl.base.models.AppConfig.objects.last()\n        if app_config and app_config.documentos_administrativos == 'O':\n            return True\n\n        return super().has_permission()\n\n\nclass AnexoAudienciaPublicaCrud(MasterDetailCrud):\n    model = AnexoAudienciaPublica\n    parent_field = 'audiencia'\n    help_topic = 'numeracao_docsacess'\n\n    class BaseMixin(MasterDetailCrud.BaseMixin):\n        list_field_names = ['assunto']\n\n    class CreateView(MasterDetailCrud.CreateView):\n        form_class = AnexoAudienciaPublicaForm\n        layout_key = None\n\n    class UpdateView(MasterDetailCrud.UpdateView):\n        form_class = AnexoAudienciaPublicaForm\n\n    class ListView(AudienciaPublicaMixin, MasterDetailCrud.ListView):\n\n        def get_queryset(self):\n            qs = super(MasterDetailCrud.ListView, self).get_queryset()\n            kwargs = {self.crud.parent_field: self.kwargs['pk']}\n            return qs.filter(**kwargs).order_by('-data', '-id')\n\n    class DetailView(AudienciaPublicaMixin,\n                     MasterDetailCrud.DetailView):\n        pass\n    ", "path": "sapl/audiencia/views.py"}, {"content": "from django.conf.urls import include, url\nfrom sapl.audiencia.views import (index, AudienciaCrud,AnexoAudienciaPublicaCrud)\n\nfrom .apps import AppConfig\n\napp_name = AppConfig.name\n\nurlpatterns = [\n    url(r'^audiencia/', include(AudienciaCrud.get_urls() +\n    \t\t\t\t\t\t\tAnexoAudienciaPublicaCrud.get_urls())),\n]", "path": "sapl/audiencia/urls.py"}], "after_files": [{"content": "import sapl\n\nfrom django.http import HttpResponse\nfrom django.core.urlresolvers import reverse\nfrom django.views.decorators.clickjacking import xframe_options_exempt\nfrom django.views.generic import UpdateView\nfrom sapl.crud.base import RP_DETAIL, RP_LIST, Crud, MasterDetailCrud\n\nfrom .forms import AudienciaForm, AnexoAudienciaPublicaForm\nfrom .models import AudienciaPublica, AnexoAudienciaPublica\n\n\ndef index(request):\n    return HttpResponse(\"Audi\u00eancia  P\u00fablica\")\n\n\nclass AudienciaCrud(Crud):\n    model = AudienciaPublica\n    public = [RP_LIST, RP_DETAIL, ]\n\n    class BaseMixin(Crud.BaseMixin):\n        list_field_names = ['numero', 'nome', 'tipo', 'materia',\n                            'data'] \n        ordering = 'nome', 'numero', 'tipo', 'data'\n\n    class ListView(Crud.ListView):\n        paginate_by = 10\n\n        def get_context_data(self, **kwargs):\n            context = super().get_context_data(**kwargs)\n\n            audiencia_materia = {}\n            for o in context['object_list']:\n                # indexado pelo numero da audiencia\n                audiencia_materia[str(o.numero)] = o.materia\n\n            for row in context['rows']:\n                coluna_materia = row[3] # se mudar a ordem de listagem mudar aqui\n                if coluna_materia[0]:\n                    materia = audiencia_materia[row[0][0]]\n                    url_materia = reverse('sapl.materia:materialegislativa_detail',\n                                          kwargs={'pk': materia.id})\n                    row[3] = (coluna_materia[0], url_materia)\n            return context\n\n    class CreateView(Crud.CreateView):\n        form_class = AudienciaForm\n\n        def form_valid(self, form):\n            return super(Crud.CreateView, self).form_valid(form)\n\n    class UpdateView(Crud.UpdateView):\n        form_class = AudienciaForm\n\n        def get_initial(self):\n            initial = super(UpdateView, self).get_initial()\n            if self.object.materia:\n                initial['tipo_materia'] = self.object.materia.tipo.id\n                initial['numero_materia'] = self.object.materia.numero\n                initial['ano_materia'] = self.object.materia.ano\n            return initial\n     \n    class DeleteView(Crud.DeleteView):\n        pass\n\n    class DetailView(Crud.DetailView):\n\n        layout_key = 'AudienciaPublicaDetail'\n\n        @xframe_options_exempt\n        def get(self, request, *args, **kwargs):\n            return super().get(request, *args, **kwargs)\n\n\nclass AudienciaPublicaMixin:\n\n    def has_permission(self):\n        app_config = sapl.base.models.AppConfig.objects.last()\n        if app_config and app_config.documentos_administrativos == 'O':\n            return True\n\n        return super().has_permission()\n\n\nclass AnexoAudienciaPublicaCrud(MasterDetailCrud):\n    model = AnexoAudienciaPublica\n    parent_field = 'audiencia'\n    help_topic = 'numeracao_docsacess'\n    public = [RP_LIST, RP_DETAIL, ]\n\n    class BaseMixin(MasterDetailCrud.BaseMixin):\n        list_field_names = ['assunto']\n\n    class CreateView(MasterDetailCrud.CreateView):\n        form_class = AnexoAudienciaPublicaForm\n        layout_key = None\n\n    class UpdateView(MasterDetailCrud.UpdateView):\n        form_class = AnexoAudienciaPublicaForm\n\n    class ListView(AudienciaPublicaMixin, MasterDetailCrud.ListView):\n\n        def get_queryset(self):\n            qs = super(MasterDetailCrud.ListView, self).get_queryset()\n            kwargs = {self.crud.parent_field: self.kwargs['pk']}\n            return qs.filter(**kwargs).order_by('-data', '-id')\n\n    class DetailView(AudienciaPublicaMixin, MasterDetailCrud.DetailView):\n        pass\n", "path": "sapl/audiencia/views.py"}, {"content": "from django.conf.urls import include, url\nfrom sapl.audiencia.views import (index, AudienciaCrud, AnexoAudienciaPublicaCrud)\n\nfrom .apps import AppConfig\n\napp_name = AppConfig.name\n\nurlpatterns = [\n    url(r'^audiencia/', include(AudienciaCrud.get_urls() + AnexoAudienciaPublicaCrud.get_urls())),\n]", "path": "sapl/audiencia/urls.py"}]}