Browse Source

Fix qa_check tests

pull/11/merge
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
f426a2f3bd
  1. 7
      norma/urls.py
  2. 33
      norma/views.py

7
norma/urls.py

@ -1,8 +1,5 @@
from django.conf.urls import include, url from django.conf.urls import url
from norma.views import NormaIncluirView, norma_temporario_para_compilacao_crud
from norma.views import (NormaIncluirView, assunto_norma_crud,
norma_temporario_para_compilacao_crud,
tipo_norma_crud)
norma_url_patterns = norma_temporario_para_compilacao_crud.urlpatterns norma_url_patterns = norma_temporario_para_compilacao_crud.urlpatterns

33
norma/views.py

@ -82,11 +82,13 @@ def get_tipos_norma():
+ [(n.id, n.descricao) + [(n.id, n.descricao)
for n in TipoNormaJuridica.objects.all()] for n in TipoNormaJuridica.objects.all()]
def get_esferas(): def get_esferas():
return [('E', 'Estadual'), return [('E', 'Estadual'),
('F', 'Federal'), ('F', 'Federal'),
('M', 'Municipal')] ('M', 'Municipal')]
def get_tipos_materia(): def get_tipos_materia():
return [('', 'Selecione')] \ return [('', 'Selecione')] \
+ [(t.id, t.sigla + ' - ' + t.descricao) + [(t.id, t.sigla + ' - ' + t.descricao)
@ -98,11 +100,12 @@ class HorizontalRadioRenderer(forms.RadioSelect.renderer):
def render(self): def render(self):
return mark_safe(u' '.join([u'%s ' % w for w in self])) return mark_safe(u' '.join([u'%s ' % w for w in self]))
class NormaJuridicaForm(forms.Form): class NormaJuridicaForm(forms.Form):
tipo = forms.ChoiceField(required=True, tipo = forms.ChoiceField(required=True,
label='Tipo', label='Tipo',
choices= get_tipos_norma(), choices=get_tipos_norma(),
widget=forms.Select( widget=forms.Select(
attrs={'class': 'selector'})) attrs={'class': 'selector'}))
@ -144,13 +147,15 @@ class NormaJuridicaForm(forms.Form):
widget=forms.TextInput( widget=forms.TextInput(
attrs={'class': 'dateinput'})) attrs={'class': 'dateinput'}))
veiculo_publicacao = forms.CharField(label='Veiculo Publicação', required=False) veiculo_publicacao = forms.CharField(
label='Veiculo Publicação', required=False)
pg_inicio = forms.CharField(label='Pg. Início', required=False) pg_inicio = forms.CharField(label='Pg. Início', required=False)
pg_fim = forms.CharField(label='Pg. Fim', required=False) pg_fim = forms.CharField(label='Pg. Fim', required=False)
# texto = form.FileUpload(label='Texto', required=False) # TODO: implement file upload # texto = form.FileUpload(label='Texto', required=False) # TODO: implement
# file upload
data_fim_vigencia = forms.DateField(label='Data Fim Vigência', data_fim_vigencia = forms.DateField(label='Data Fim Vigência',
required=False, required=False,
@ -158,11 +163,15 @@ class NormaJuridicaForm(forms.Form):
widget=forms.TextInput( widget=forms.TextInput(
attrs={'class': 'dateinput'})) attrs={'class': 'dateinput'}))
ementa = forms.CharField(label='Ementa', required=True, widget=forms.Textarea) ementa = forms.CharField(
label='Ementa', required=True, widget=forms.Textarea)
indexacao = forms.CharField(
label='Indexação', required=False, widget=forms.Textarea)
indexacao = forms.CharField(label='Indexação', required=False, widget=forms.Textarea) observacao = forms.CharField(
label='Observação', required=False, widget=forms.Textarea)
observacao = forms.CharField(label='Observação', required=False, widget=forms.Textarea)
class NormaIncluirView(FormMixin, GenericView): class NormaIncluirView(FormMixin, GenericView):
template_name = "norma/normajuridica_incluir.html" template_name = "norma/normajuridica_incluir.html"
@ -181,14 +190,16 @@ class NormaIncluirView(FormMixin, GenericView):
if form.is_valid(): if form.is_valid():
norma = NormaJuridica() norma = NormaJuridica()
norma.tipo = TipoNormaJuridica.objects.get(id=form.cleaned_data['tipo']) norma.tipo = TipoNormaJuridica.objects.get(
id=form.cleaned_data['tipo'])
norma.numero = form.cleaned_data['numero'] norma.numero = form.cleaned_data['numero']
norma.ano = form.cleaned_data['ano'] norma.ano = form.cleaned_data['ano']
norma.data = form.cleaned_data['data'] norma.data = form.cleaned_data['data']
norma.esfera = form.cleaned_data['esfera'] norma.esfera = form.cleaned_data['esfera']
norma.complementar = form.cleaned_data['complementar'] norma.complementar = form.cleaned_data['complementar']
if form.cleaned_data['complementar']: if form.cleaned_data['complementar']:
norma.complementar = TipoMateriaLegislativa.objects.get(id=form.cleaned_data['complementar']) norma.complementar = TipoMateriaLegislativa.objects.get(
id=form.cleaned_data['complementar'])
if form.cleaned_data['materia']: if form.cleaned_data['materia']:
norma.materia = form.cleaned_data['materia'] norma.materia = form.cleaned_data['materia']
@ -203,7 +214,8 @@ class NormaIncluirView(FormMixin, GenericView):
norma.data_publicacao = form.cleaned_data['data_publicacao'] norma.data_publicacao = form.cleaned_data['data_publicacao']
if form.cleaned_data['veiculo_publicacao']: if form.cleaned_data['veiculo_publicacao']:
norma.veiculo_publicacao = form.cleaned_data['veiculo_publicacao'] norma.veiculo_publicacao = form.cleaned_data[
'veiculo_publicacao']
if form.cleaned_data['pg_inicio']: if form.cleaned_data['pg_inicio']:
norma.pg_inicio = form.cleaned_data['pg_inicio'] norma.pg_inicio = form.cleaned_data['pg_inicio']
@ -212,7 +224,8 @@ class NormaIncluirView(FormMixin, GenericView):
norma.pg_fim = form.cleaned_data['pg_fim'] norma.pg_fim = form.cleaned_data['pg_fim']
if form.cleaned_data['data_fim_vigencia']: if form.cleaned_data['data_fim_vigencia']:
norma.data_fim_vigencia = form.cleaned_data['data_fim_vigencia'] norma.data_fim_vigencia = form.cleaned_data[
'data_fim_vigencia']
norma.ementa = form.cleaned_data['ementa'] norma.ementa = form.cleaned_data['ementa']

Loading…
Cancel
Save