Browse Source

Add cache to header and fix QA

pull/153/head
Edward Ribeiro 9 years ago
parent
commit
1f1e7a1d9e
  1. 10
      base/views.py
  2. 4
      materia/views.py
  3. 9
      protocoloadm/views.py
  4. 9
      sapl/context_processors.py

10
base/views.py

@ -1,4 +1,5 @@
import os
from functools import lru_cache
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, ButtonHolder, Fieldset, Layout, Submit
@ -15,6 +16,11 @@ import sapl
from .models import CasaLegislativa
@lru_cache(maxsize=1)
def get_casalegislativa():
return CasaLegislativa.objects.first()
class HelpView(TemplateView):
# XXX treat non existing template as a 404!!!!
@ -199,6 +205,10 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView):
casa_save.save()
else:
form.save()
# Invalida cache de consulta
get_casalegislativa.cache_clear()
return self.form_valid(form)
else:
return self.render_to_response({'form': form})

4
materia/views.py

@ -1488,8 +1488,8 @@ class TramitacaoView(FormMixin, GenericView):
'error': 'A origem da nova tramitação \
deve ser igual ao destino da última adicionada!'})
corpo_email = ('A tramitação da matéria\
%s foi alterada.' % materia)
corpo_email = ('A tramitação da matéria %s foi alterada.' % materia
)
destinatarios = AcompanharMateria.objects.values_list(
'email', flat=True).filter(
materia_cadastrada=materia)

9
protocoloadm/views.py

@ -2,7 +2,8 @@ from datetime import date, datetime
from re import sub
from crispy_forms.helper import FormHelper
from crispy_forms.layout import ButtonHolder, HTML, Field, Fieldset, Layout, Submit
from crispy_forms.layout import (HTML, ButtonHolder, Field, Fieldset, Layout,
Submit)
from django import forms
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
@ -330,8 +331,10 @@ class AnularProcoloAdmForm(forms.Form):
row2,
HTML(" "),
ButtonHolder(Submit('submit', 'Anular',
css_class='button primary'))
)
css_class='button primary'
)
)
)
)
super(AnularProcoloAdmForm, self).__init__(
*args, **kwargs)

9
sapl/context_processors.py

@ -1,10 +1,5 @@
from base.models import CasaLegislativa
# TODO: this need to be cached and retrieved once!!!
def query_database():
return CasaLegislativa.objects.first()
from base.views import get_casalegislativa
def parliament_info(request):
@ -21,7 +16,7 @@ def parliament_info(request):
'url_email': '#',
}
casa_legislativa = query_database()
casa_legislativa = get_casalegislativa()
if casa_legislativa:
context['parliament_type'] = casa_legislativa.nome

Loading…
Cancel
Save