diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 4533d3883..aea49d89d 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -94,7 +94,7 @@ urlpatterns_materia = [ url(r'^materia/acessorio-em-lote', DocumentoAcessorioEmLoteView.as_view(), name='acessorio_em_lote'), - url(r'^materia/anexada-em-lote', MateriaAnexadaEmLoteView.as_view(), + url(r'^materia/(?P\d+)/anexada-em-lote', MateriaAnexadaEmLoteView.as_view(), name='anexada_em_lote'), url(r'^materia/primeira-tramitacao-em-lote', PrimeiraTramitacaoEmLoteView.as_view(), diff --git a/sapl/materia/views.py b/sapl/materia/views.py index e31b93086..1f9bfc99c 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -2006,14 +2006,17 @@ class MateriaAnexadaEmLoteView(PermissionRequiredMixin, FilterView): context = super(MateriaAnexadaEmLoteView, self).get_context_data(**kwargs) + context['root_pk'] = self.kwargs['pk'] + + context['subnav_template_name'] = 'materia/subnav.yaml' + + context['title'] = _('Matérias Anexadas em Lote') # Verifica se os campos foram preenchidos if not self.filterset.form.is_valid(): return context qr = self.request.GET.copy() - # context['tipos_docs'] = TipoDocumento.objects.all() - import ipdb; ipdb.set_trace() context['object_list'] = context['object_list'].order_by( 'ano', 'numero') context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' @@ -2030,22 +2033,25 @@ class MateriaAnexadaEmLoteView(PermissionRequiredMixin, FilterView): messages.add_message(request, messages.ERROR, msg) return self.get(request, self.kwargs) - tipo = TipoDocumento.objects.get(descricao=request.POST['tipo']) + data_anexacao = datetime.strptime( + request.POST['data_anexacao'], "%d/%m/%Y").date() - tz = timezone.get_current_timezone() + if request.POST['data_desanexacao'] == '': + data_desanexacao = None + else: + data_desanexacao = datetime.strptime( + request.POST['data_desanexacao'], "%d/%m/%Y").date() for materia_id in marcadas: - doc = DocumentoAcessorio() - doc.materia_id = materia_id - doc.tipo = tipo - doc.arquivo = request.FILES['arquivo'] - doc.nome = request.POST['nome'] - doc.data = tz.localize(datetime.strptime( - request.POST['data'], "%d/%m/%Y")) - doc.autor = request.POST['autor'] - doc.ementa = request.POST['ementa'] - doc.save() - msg = _('Documento(s) criado(s).') + + anexada = Anexada() + anexada.materia_principal = MateriaLegislativa.objects.get(pk = kwargs['pk']) + anexada.materia_anexada = MateriaLegislativa.objects.get(pk = materia_id) + anexada.data_anexacao = data_anexacao + anexada.data_desanexacao = data_desanexacao + anexada.save() + + msg = _('Materia(s) anexada(s).') messages.add_message(request, messages.SUCCESS, msg) return self.get(request, self.kwargs) diff --git a/sapl/templates/materia/anexada_list.html b/sapl/templates/materia/anexada_list.html new file mode 100644 index 000000000..381f402b8 --- /dev/null +++ b/sapl/templates/materia/anexada_list.html @@ -0,0 +1,14 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load common_tags %} + + +{% block more_buttons %} + +{% if perms|get_add_perm:view %} + + {% trans "Adicionar Anexada em Lote" %} + +{% endif %} + +{% endblock more_buttons %} diff --git a/sapl/templates/materia/em_lote/anexada.html b/sapl/templates/materia/em_lote/anexada.html index 738010083..81a930cc1 100644 --- a/sapl/templates/materia/em_lote/anexada.html +++ b/sapl/templates/materia/em_lote/anexada.html @@ -16,65 +16,31 @@ {% endif %}
{% csrf_token %} +
- Documento Acessório
-
-
- - -
-
- - + +
-
- - + +
-
-
-
- - -
-
-
- -
-
-
- - -
-
-
-
-
-
- - -
-
-

- Matérias para inclusão do Documento Acessório + Matérias para Anexar em Lote