Browse Source

Fix QA complains

pull/11/merge
Edward Ribeiro 9 years ago
parent
commit
d3c666860b
  1. 4
      protocoloadm/urls.py
  2. 81
      protocoloadm/views.py

4
protocoloadm/urls.py

@ -1,10 +1,10 @@
from django.conf.urls import include, url from django.conf.urls import include, url
from protocoloadm.views import (AnularProtocoloAdmView, from protocoloadm.views import (AnularProtocoloAdmView,
DetailDocumentoAdministrativo, DetailDocumentoAdministrativo,
DocumentoAcessorioAdministrativoView, DocumentoAcessorioAdministrativoView,
PesquisarDocumentoAdministrativo, PesquisarDocumentoAdministrativo,
ProposicaoReceberView, ProposicaoReceberView, ProposicaoView,
ProposicaoView,
ProposicoesIncorporadasView, ProposicoesIncorporadasView,
ProposicoesNaoIncorporadasView, ProposicoesNaoIncorporadasView,
ProposicoesNaoRecebidasView, ProposicoesNaoRecebidasView,

81
protocoloadm/views.py

@ -2,7 +2,7 @@ from datetime import date, datetime
from re import sub from re import sub
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit, HTML from crispy_forms.layout import ButtonHolder, Fieldset, Layout, Submit
from django import forms from django import forms
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -16,14 +16,10 @@ from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, ListView from django.views.generic import DetailView, ListView
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from django.views.generic import FormView
from django.views.generic import DetailView
from vanilla import GenericView from vanilla import GenericView
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Field
from materia.models import Proposicao, TipoMateriaLegislativa from materia.models import Proposicao, TipoMateriaLegislativa
from sapl.crud import build_crud from sapl.crud import build_crud
from vanilla import GenericView
from .models import (Autor, DocumentoAcessorioAdministrativo, from .models import (Autor, DocumentoAcessorioAdministrativo,
DocumentoAdministrativo, Protocolo, DocumentoAdministrativo, Protocolo,
@ -523,6 +519,7 @@ class ProposicoesNaoRecebidasView(ListView):
def get_queryset(self): def get_queryset(self):
return Proposicao.objects.filter(data_envio__isnull=False, status='E') return Proposicao.objects.filter(data_envio__isnull=False, status='E')
class ProposicoesNaoIncorporadasView(ListView): class ProposicoesNaoIncorporadasView(ListView):
template_name = "protocoloadm/proposicoes_naoincorporadas.html" template_name = "protocoloadm/proposicoes_naoincorporadas.html"
model = Proposicao model = Proposicao
@ -545,26 +542,31 @@ class ProposicoesIncorporadasView(ListView):
data_recebimento__isnull=False, data_recebimento__isnull=False,
status='I') status='I')
class ProposicaoSimpleForm(forms.Form): class ProposicaoSimpleForm(forms.Form):
tipo = forms.CharField(label='Tipo', tipo = forms.CharField(label='Tipo',
widget = forms.TextInput( widget=forms.TextInput(
attrs={'readonly':'readonly'})) attrs={'readonly': 'readonly'}))
materia = forms.CharField(label='Matéria', materia = forms.CharField(label='Matéria',
widget = forms.TextInput( widget=forms.TextInput(
attrs={'readonly':'readonly'})) attrs={'readonly': 'readonly'}))
data_envio = forms.DateField(label='Data Envio', data_envio = forms.DateField(label='Data Envio',
widget=forms.DateInput(format = '%d/%m/%Y', attrs={'readonly':'readonly'})) widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'readonly': 'readonly'}))
data_recebimento = forms.DateField(label='Data Recebimento', data_recebimento = forms.DateField(label='Data Recebimento',
widget=forms.DateInput(format = '%d/%m/%Y', attrs={'readonly':'readonly'})) widget=forms.DateInput(
format='%d/%m/%Y',
attrs={'readonly': 'readonly'}))
descricao = forms.CharField(label='Descrição', descricao = forms.CharField(label='Descrição',
widget = forms.TextInput( widget=forms.TextInput(
attrs={'readonly':'readonly'})) attrs={'readonly': 'readonly'}))
numero_proposicao = forms.CharField(label='Número', numero_proposicao = forms.CharField(label='Número',
widget = forms.TextInput( widget=forms.TextInput(
attrs={'readonly':'readonly'})) attrs={'readonly': 'readonly'}))
# ano = forms.CharField(label='Ano', # ano = forms.CharField(label='Ano',
# widget = forms.TextInput( # widget = forms.TextInput(
# attrs={'readonly':'readonly'})) # attrs={'readonly':'readonly'}))
@ -572,24 +574,24 @@ class ProposicaoSimpleForm(forms.Form):
class ProposicaoView(DetailView): class ProposicaoView(DetailView):
template_name = "protocoloadm/proposicao_view.html" template_name = "protocoloadm/proposicao_view.html"
model = Proposicao model = Proposicao
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
proposicao = Proposicao.objects.get(id=kwargs['pk']) proposicao = Proposicao.objects.get(id=kwargs['pk'])
data = {# 'ano': proposicao.ano, # TODO: FIX data = { # 'ano': proposicao.ano, # TODO: FIX
'tipo': proposicao.tipo.descricao, #TODO: FIX 'tipo': proposicao.tipo.descricao, # TODO: FIX
'materia': proposicao.materia, 'materia': proposicao.materia,
'numero_proposicao': proposicao.numero_proposicao, 'numero_proposicao': proposicao.numero_proposicao,
'data_envio': proposicao.data_envio, 'data_envio': proposicao.data_envio,
'data_recebimento': proposicao.data_recebimento, 'data_recebimento': proposicao.data_recebimento,
'descricao': proposicao.descricao} 'descricao': proposicao.descricao}
form = ProposicaoSimpleForm(initial=data) form = ProposicaoSimpleForm(initial=data)
return self.render_to_response({'form': form}) return self.render_to_response({'form': form})
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ProposicaoView, self).get_context_data(**kwargs) context = super(ProposicaoView, self).get_context_data(**kwargs)
context['form'] = ProposicaoSimpleForm context['form'] = ProposicaoSimpleForm
return context return context
# class PesquisaDocForm(forms.Form): # class PesquisaDocForm(forms.Form):
@ -722,8 +724,10 @@ class DetailDocumentoAdministrativo(DetailView):
class ModelFormDocumentoAcessorioAdministrativo(ModelForm): class ModelFormDocumentoAcessorioAdministrativo(ModelForm):
data = forms.DateField(label=u'Data', input_formats=['%d/%m/%Y'], data = forms.DateField(label=u'Data',
required=False, widget=forms.DateInput(format='%d/%m/%Y')) input_formats=['%d/%m/%Y'],
required=False,
widget=forms.DateInput(format='%d/%m/%Y'))
class Meta: class Meta:
model = DocumentoAcessorioAdministrativo model = DocumentoAcessorioAdministrativo
@ -748,11 +752,11 @@ class ModelFormDocumentoAcessorioAdministrativo(ModelForm):
ButtonHolder( ButtonHolder(
Submit('submit', 'Salvar', Submit('submit', 'Salvar',
css_class='button primary') css_class='button primary')
) )
), ),
) )
super(ModelFormDocumentoAcessorioAdministrativo, self).__init__(*args, **kwargs) super(ModelFormDocumentoAcessorioAdministrativo,
self).__init__(*args, **kwargs)
class DocumentoAcessorioAdministrativoView(FormMixin, GenericView): class DocumentoAcessorioAdministrativoView(FormMixin, GenericView):
@ -792,10 +796,11 @@ class DocumentoAcessorioAdministrativoView(FormMixin, GenericView):
return self.form_valid(form) return self.form_valid(form)
else: else:
print(form['data']) print(form['data'])
import ipdb; ipdb.set_trace() import ipdb
ipdb.set_trace()
return self.form_invalid(form) return self.form_invalid(form)
# return HttpResponseRedirect(self.get_success_url()) # return HttpResponseRedirect(self.get_success_url())
def get_success_url(self): def get_success_url(self):
pk = self.kwargs['pk'] pk = self.kwargs['pk']
return reverse('doc_ace_adm',kwargs={'pk': pk}) return reverse('doc_ace_adm', kwargs={'pk': pk})

Loading…
Cancel
Save