|
|
@ -5,8 +5,8 @@ from django.http import HttpResponseRedirect |
|
|
|
from django.shortcuts import redirect |
|
|
|
from django.views.generic import CreateView, FormView, ListView, UpdateView |
|
|
|
|
|
|
|
from compilacao.views import IntegracaoTaView |
|
|
|
import crud.base |
|
|
|
from compilacao.views import IntegracaoTaView |
|
|
|
from crud.base import Crud, make_pagination |
|
|
|
from materia.models import MateriaLegislativa |
|
|
|
|
|
|
@ -24,6 +24,17 @@ class NormaCrud(Crud): |
|
|
|
model = NormaJuridica |
|
|
|
help_path = 'norma_juridica' |
|
|
|
|
|
|
|
class UpdateView(crud.base.CrudUpdateView): |
|
|
|
form_class = NormaJuridicaForm |
|
|
|
|
|
|
|
def get_initial(self): |
|
|
|
norma = NormaJuridica.objects.get(id=self.kwargs['pk']) |
|
|
|
if norma.materia: |
|
|
|
self.initial['tipo_materia'] = norma.materia.tipo |
|
|
|
self.initial['ano_materia'] = norma.materia.ano |
|
|
|
self.initial['numero_materia'] = norma.materia.numero |
|
|
|
return self.initial.copy() |
|
|
|
|
|
|
|
class CreateView(crud.base.CrudCreateView): |
|
|
|
form_class = NormaJuridicaForm |
|
|
|
|
|
|
@ -121,57 +132,6 @@ class PesquisaNormaListView(ListView): |
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
# class NormaIncluirView(CreateView): |
|
|
|
# template_name = "norma/normajuridica_incluir.html" |
|
|
|
# form_class = NormaJuridicaForm |
|
|
|
# success_url = reverse_lazy('norma:normajuridica_list') |
|
|
|
# |
|
|
|
# def get_success_url(self): |
|
|
|
# return reverse_lazy('norma:norma_pesquisa') |
|
|
|
# |
|
|
|
# def form_valid(self, form): |
|
|
|
# norma = form.save(commit=False) |
|
|
|
# norma.timestamp = datetime.now() |
|
|
|
# if form.cleaned_data['tipo_materia']: |
|
|
|
# materia = MateriaLegislativa.objects.get( |
|
|
|
# tipo_id=form.data['tipo_materia'], |
|
|
|
# numero=form.data['numero_materia'], |
|
|
|
# ano=form.data['ano_materia']) |
|
|
|
# norma.materia = materia |
|
|
|
# norma.save() |
|
|
|
# return HttpResponseRedirect(self.get_success_url()) |
|
|
|
# |
|
|
|
# |
|
|
|
# class NormaEditView(UpdateView): |
|
|
|
# template_name = "norma/normajuridica_incluir.html" |
|
|
|
# form_class = NormaJuridicaForm |
|
|
|
# model = NormaJuridica |
|
|
|
# success_url = reverse_lazy('norma:pesquisa_norma') |
|
|
|
# |
|
|
|
# def get_initial(self): |
|
|
|
# data = super(NormaEditView, self).get_initial() |
|
|
|
# norma = NormaJuridica.objects.get(id=self.kwargs['pk']) |
|
|
|
# if norma.materia: |
|
|
|
# data.update({ |
|
|
|
# 'tipo_materia': norma.materia.tipo, |
|
|
|
# 'numero_materia': norma.materia.numero, |
|
|
|
# 'ano_materia': norma.materia.ano, |
|
|
|
# }) |
|
|
|
# return data |
|
|
|
# |
|
|
|
# def form_valid(self, form): |
|
|
|
# norma = form.save(commit=False) |
|
|
|
# norma.timestamp = datetime.now() |
|
|
|
# if form.cleaned_data['tipo_materia']: |
|
|
|
# materia = MateriaLegislativa.objects.get( |
|
|
|
# tipo_id=form.data['tipo_materia'], |
|
|
|
# numero=form.data['numero_materia'], |
|
|
|
# ano=form.data['ano_materia']) |
|
|
|
# norma.materia = materia |
|
|
|
# norma.save() |
|
|
|
# return HttpResponseRedirect(self.get_success_url()) |
|
|
|
|
|
|
|
|
|
|
|
class NormaTaView(IntegracaoTaView): |
|
|
|
model = NormaJuridica |
|
|
|
model_type_foreignkey = TipoNormaJuridica |
|
|
|