diff --git a/check_qa.sh b/check_qa.sh new file mode 100755 index 0000000..607bb52 --- /dev/null +++ b/check_qa.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Check if there's some debug breakpoint in codebase +me=`basename "$0"` +stmts=`grep --exclude=$me -r -l "ipdb.set_trace()" * | wc -l` +if [ $stmts != '0' ] +then + echo "==================================================================" + echo "ERROR: ipdb.set_trace() call in codebase! Remove, please." + grep --exclude=$me -r -n "ipdb.set_trace()" * + echo "==================================================================" +fi + +# QA checks: run this before every commit +./manage.py check +flake8 --exclude='ipython_log.py*,migrations,templates' . +isort --recursive --check-only --skip='migrations' --skip='templates' --skip='ipython_log.py' . diff --git a/conftest.py b/conftest.py index b9ff21f..a59c999 100644 --- a/conftest.py +++ b/conftest.py @@ -2,7 +2,6 @@ import pytest from django_webtest import DjangoTestApp, WebTestMixin - DEFAULT_MARK = object() diff --git a/etc/migracao/migra.py b/etc/migracao/migra.py index 47216db..693fa25 100755 --- a/etc/migracao/migra.py +++ b/etc/migracao/migra.py @@ -19,19 +19,21 @@ pós-instalação) para a migração dos dados. Este script não foi feito para banco de dados em produção. """ +import csv +from datetime import datetime + from django.core.management import setup_environ from sigi import settings -setup_environ(settings) - -import csv -from datetime import datetime from sigi.apps.casas.models import * from sigi.apps.contatos.models import * from sigi.apps.convenios.models import * from sigi.apps.inventario.models import * from sigi.apps.parlamentares.models import * +setup_environ(settings) + + ERROR_MSG_0 = (' %s[%s]: erro desconhecido! Possível erro de integridade ' 'do banco de dados. Favor verificar e inserir manualmente caso ' 'necessário.') diff --git a/fix_qa.sh b/fix_qa.sh new file mode 100755 index 0000000..a3ac9d8 --- /dev/null +++ b/fix_qa.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# QA fix: Use ese script para corrigir automaticamente vários +# problemas de estilo e boas práticas no código. +# +# Sempre guarde suas mudanças de alguma forma antes de aplicar esse script, +# de modo que possa revisar cada alteração que ele fez. +# Uma forma simples de fazer isso é adicionando antes suas mudanças à +# "staging area" do git, com `git add .` e após usar o script `git diff`. + +isort --recursive --skip='migrations' --skip='templates' --skip='ipython_log.py' . diff --git a/scripts/casas_com_PM_e_SAPL.py b/scripts/casas_com_PM_e_SAPL.py index b382da3..8c915c0 100644 --- a/scripts/casas_com_PM_e_SAPL.py +++ b/scripts/casas_com_PM_e_SAPL.py @@ -1,7 +1,6 @@ from csv_writer import CsvWriter from sigi.apps.servicos.models import Servico - ARQUIVO_CSV = '/tmp/casas_que_usam_PM_e_SAPL.csv' diff --git a/scripts/casas_que_usam_LEGBR_ou_PM.py b/scripts/casas_que_usam_LEGBR_ou_PM.py index 2dc8aeb..8d1de62 100644 --- a/scripts/casas_que_usam_LEGBR_ou_PM.py +++ b/scripts/casas_que_usam_LEGBR_ou_PM.py @@ -1,9 +1,8 @@ -import cStringIO import codecs +import cStringIO import csv -from sigi.apps.servicos.models import TipoServico, Servico - +from sigi.apps.servicos.models import Servico, TipoServico # cria um CSV com contatos das casas legislativas que possuem portal modelo ativo # rodar em um shell: diff --git a/scripts/contatos_de_casas_que_usam_portalmodelo.py b/scripts/contatos_de_casas_que_usam_portalmodelo.py index 32dc761..4736e40 100644 --- a/scripts/contatos_de_casas_que_usam_portalmodelo.py +++ b/scripts/contatos_de_casas_que_usam_portalmodelo.py @@ -1,10 +1,10 @@ -import cStringIO import codecs +import cStringIO import csv from sigi.apps.casas.models import Funcionario from sigi.apps.contatos.models import Telefone -from sigi.apps.servicos.models import TipoServico, Servico +from sigi.apps.servicos.models import Servico, TipoServico # cria um CSV com contatos das casas legislativas que possuem portal modelo ativo # rodar em um shell: diff --git a/scripts/csv_writer.py b/scripts/csv_writer.py index acf485d..a825e5c 100644 --- a/scripts/csv_writer.py +++ b/scripts/csv_writer.py @@ -1,5 +1,5 @@ -import cStringIO import codecs +import cStringIO import csv diff --git a/scripts/importa_pesquisa.py b/scripts/importa_pesquisa.py index cac1c32..b0f7955 100644 --- a/scripts/importa_pesquisa.py +++ b/scripts/importa_pesquisa.py @@ -29,6 +29,7 @@ from datetime import datetime from sigi.apps.casas.models import CasaLegislativa from sigi.apps.servidores.models import Servidor + def importa(file_list): ''' Este script importa dados de um arquivo CSV e dá carga no model casas.CasaLegislativa @@ -128,4 +129,3 @@ def importa(file_list): casa.save() print 'O arquivo '+filename+'.out foi criado com os registros que nao puderam ser importados' - diff --git a/scripts/servicos_seit_ate_2013_2014.py b/scripts/servicos_seit_ate_2013_2014.py index 24b4f7f..c2d2e18 100644 --- a/scripts/servicos_seit_ate_2013_2014.py +++ b/scripts/servicos_seit_ate_2013_2014.py @@ -1,4 +1,5 @@ from datetime import date + from django.db.models import Q from sigi.apps.servicos.models import TipoServico diff --git a/scripts/setgerentes/dados_gerentes.py b/scripts/setgerentes/dados_gerentes.py index 2000914..6616f24 100644 --- a/scripts/setgerentes/dados_gerentes.py +++ b/scripts/setgerentes/dados_gerentes.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from sigi.apps.servidores.models import Servidor - gerentes = {k: Servidor.objects.get(nome_completo=n) for k, n in ( ('ADAL', u'Adalberto Alves de Oliveira'), ('janarycn', u'Janary Carvão Nunes'), diff --git a/scripts/user_from_session.py b/scripts/user_from_session.py index 853aeb7..7c9b789 100644 --- a/scripts/user_from_session.py +++ b/scripts/user_from_session.py @@ -1,5 +1,5 @@ -from django.contrib.sessions.models import Session from django.contrib.auth.models import User +from django.contrib.sessions.models import Session def user_from_session(session_key): diff --git a/scripts/verificacao_arquivos_faltando_media.py b/scripts/verificacao_arquivos_faltando_media.py index 90cc79f..6a686c6 100644 --- a/scripts/verificacao_arquivos_faltando_media.py +++ b/scripts/verificacao_arquivos_faltando_media.py @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- +from datetime import datetime # Dependência: # pip install terminaltables from os.path import isfile -from datetime import datetime from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse -from terminaltables import AsciiTable from sigi.apps.casas.models import CasaLegislativa from sigi.apps.convenios.models import Anexo as AnexoConvenios @@ -15,6 +14,7 @@ from sigi.apps.diagnosticos.models import Anexo as AnexoDiagnosticos from sigi.apps.ocorrencias.models import Anexo as AnexoOcorrencias from sigi.apps.parlamentares.models import Parlamentar from sigi.apps.servidores.models import Servidor +from terminaltables import AsciiTable def print_table(msg, relacao): diff --git a/setup.py b/setup.py index 2ca58d5..c23c2bb 100644 --- a/setup.py +++ b/setup.py @@ -4,5 +4,4 @@ # from distutils.core import setup - setup(name='sigi', version='2.x') diff --git a/sigi/apps/casas/admin.py b/sigi/apps/casas/admin.py index 8f6b0b0..5099368 100644 --- a/sigi/apps/casas/admin.py +++ b/sigi/apps/casas/admin.py @@ -1,16 +1,17 @@ # -*- coding: utf-8 -*- -from django.core.urlresolvers import reverse from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline +from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect from django.utils.translation import ugettext as _ from image_cropping import ImageCroppingMixin from sigi.apps.casas.forms import CasaLegislativaForm -from sigi.apps.casas.models import CasaLegislativa, Presidente, Funcionario, TipoCasaLegislativa -from sigi.apps.casas.views import report_complete, labels_report, export_csv, \ - labels_report_sem_presidente, report, \ - adicionar_casas_carrinho +from sigi.apps.casas.models import (CasaLegislativa, Funcionario, Presidente, + TipoCasaLegislativa) +from sigi.apps.casas.views import (adicionar_casas_carrinho, export_csv, + labels_report, labels_report_sem_presidente, + report, report_complete) from sigi.apps.contatos.models import Telefone from sigi.apps.convenios.models import Convenio from sigi.apps.diagnosticos.models import Diagnostico diff --git a/sigi/apps/casas/management/commands/importa_gerentes.py b/sigi/apps/casas/management/commands/importa_gerentes.py index f43744c..2016d98 100644 --- a/sigi/apps/casas/management/commands/importa_gerentes.py +++ b/sigi/apps/casas/management/commands/importa_gerentes.py @@ -24,10 +24,13 @@ import csv import os + from django.core.management.base import BaseCommand, CommandError + from sigi.apps.casas.models import CasaLegislativa -from sigi.apps.servidores.models import Servidor from sigi.apps.contatos.models import Municipio +from sigi.apps.servidores.models import Servidor + class Command(BaseCommand): args = u"data_file.csv" @@ -81,4 +84,4 @@ class Command(BaseCommand): casa.gerente_contas = gerente casa.save() - self.stdout.write(u"Importação concluída. %s erros em %s linhas" % (erros, reader.line_num,)) \ No newline at end of file + self.stdout.write(u"Importação concluída. %s erros em %s linhas" % (erros, reader.line_num,)) diff --git a/sigi/apps/casas/models.py b/sigi/apps/casas/models.py index deb5955..6ae4e4a 100644 --- a/sigi/apps/casas/models.py +++ b/sigi/apps/casas/models.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import random +from datetime import datetime from string import ascii_uppercase from unicodedata import normalize -from datetime import datetime from django.contrib.contenttypes import fields from django.db import models from image_cropping import ImageRatioField diff --git a/sigi/apps/casas/reports.py b/sigi/apps/casas/reports.py index 2c7a043..3e5e66f 100644 --- a/sigi/apps/casas/reports.py +++ b/sigi/apps/casas/reports.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- from django.templatetags.static import static from django.utils.translation import ugettext as _ -from geraldo import Report, DetailBand, Label, ObjectValue, ReportGroup, ReportBand, landscape, SubReport, BAND_WIDTH, SystemField +from geraldo import (BAND_WIDTH, DetailBand, Label, ObjectValue, Report, + ReportBand, ReportGroup, SubReport, SystemField, + landscape) from geraldo.graphics import Image from reportlab.lib.enums import TA_CENTER from reportlab.lib.pagesizes import A4 diff --git a/sigi/apps/casas/urls.py b/sigi/apps/casas/urls.py index 5381364..4ad3519 100644 --- a/sigi/apps/casas/urls.py +++ b/sigi/apps/casas/urls.py @@ -1,7 +1,6 @@ # coding: utf-8 from django.conf.urls import patterns, url - urlpatterns = patterns( 'sigi.apps.casas.views', diff --git a/sigi/apps/casas/views.py b/sigi/apps/casas/views.py index d8cea61..d218cc3 100644 --- a/sigi/apps/casas/views.py +++ b/sigi/apps/casas/views.py @@ -2,23 +2,29 @@ import csv from functools import reduce -from django.core.paginator import Paginator, InvalidPage, EmptyPage -from django.http import HttpResponse, HttpResponseRedirect, Http404 -from django.shortcuts import render, get_object_or_404 -from django.utils.translation import ugettext as _, ungettext +from django.contrib.auth.decorators import login_required +from django.core.paginator import EmptyPage, InvalidPage, Paginator +from django.db.models import Count, Q +from django.http import Http404, HttpResponse, HttpResponseRedirect +from django.http.response import JsonResponse +from django.shortcuts import get_object_or_404, render +from django.utils.translation import ugettext as _ +from django.utils.translation import ungettext from geraldo.generators import PDFGenerator +from sigi.apps.casas.forms import PortfolioForm from sigi.apps.casas.models import CasaLegislativa -from sigi.apps.casas.reports import CasasLegislativasLabels, CasasLegislativasLabelsSemPresidente, CasasLegislativasReport, CasasSemConvenioReport, InfoCasaLegislativa +from sigi.apps.casas.reports import (CasasLegislativasLabels, + CasasLegislativasLabelsSemPresidente, + CasasLegislativasReport, + CasasSemConvenioReport, + InfoCasaLegislativa) +from sigi.apps.contatos.models import (Mesorregiao, Microrregiao, + UnidadeFederativa) +from sigi.apps.ocorrencias.models import Ocorrencia from sigi.apps.parlamentares.reports import ParlamentaresLabels -from sigi.apps.contatos.models import UnidadeFederativa, Mesorregiao, Microrregiao -from sigi.apps.casas.forms import PortfolioForm -from django.contrib.auth.decorators import login_required from sigi.apps.servicos.models import TipoServico from sigi.apps.servidores.models import Servidor -from sigi.apps.ocorrencias.models import Ocorrencia -from django.db.models import Count, Q -from django.http.response import JsonResponse # @param qs: queryset @@ -678,4 +684,4 @@ def painel_relacionamento(request): if snippet == 'resumo': return render(request, 'casas/resumo_carteira_snippet.html', context) - return render(request, 'casas/painel.html', context) \ No newline at end of file + return render(request, 'casas/painel.html', context) diff --git a/sigi/apps/contatos/admin.py b/sigi/apps/contatos/admin.py index 768956f..7506f42 100644 --- a/sigi/apps/contatos/admin.py +++ b/sigi/apps/contatos/admin.py @@ -3,11 +3,12 @@ from django.contrib import admin from django.utils.translation import ugettext as _ from sigi.apps.contatos.filters import PopulationFilter -from sigi.apps.contatos.models import (UnidadeFederativa, Mesorregiao, Microrregiao, - Municipio, Telefone, Contato) +from sigi.apps.contatos.models import (Contato, Mesorregiao, Microrregiao, + Municipio, Telefone, UnidadeFederativa) from sigi.apps.utils import queryset_ascii from sigi.apps.utils.base_admin import BaseModelAdmin + class MesorregiaoInline(admin.TabularInline): model = Mesorregiao diff --git a/sigi/apps/contatos/management/commands/importa_mesomicro.py b/sigi/apps/contatos/management/commands/importa_mesomicro.py index d4bc2b9..ffea419 100644 --- a/sigi/apps/contatos/management/commands/importa_mesomicro.py +++ b/sigi/apps/contatos/management/commands/importa_mesomicro.py @@ -23,8 +23,12 @@ # import csv import os + from django.core.management.base import BaseCommand, CommandError -from sigi.apps.contatos.models import Municipio, UnidadeFederativa, Mesorregiao, Microrregiao + +from sigi.apps.contatos.models import (Mesorregiao, Microrregiao, Municipio, + UnidadeFederativa) + class Command(BaseCommand): args = u"data_file.csv" @@ -97,4 +101,4 @@ class Command(BaseCommand): municipio.microrregiao = micro municipio.save() - self.stdout.write(u"Importação concluída. %s erros em %s linhas" % (erros, reader.line_num,)) \ No newline at end of file + self.stdout.write(u"Importação concluída. %s erros em %s linhas" % (erros, reader.line_num,)) diff --git a/sigi/apps/convenios/admin.py b/sigi/apps/convenios/admin.py index 6eeac0b..77dd8ee 100644 --- a/sigi/apps/convenios/admin.py +++ b/sigi/apps/convenios/admin.py @@ -4,7 +4,8 @@ from django.http import HttpResponse, HttpResponseRedirect from django.utils.translation import ugettext as _ from geraldo.generators import PDFGenerator -from sigi.apps.convenios.models import Projeto, Convenio, EquipamentoPrevisto, Anexo, Tramitacao +from sigi.apps.convenios.models import (Anexo, Convenio, EquipamentoPrevisto, + Projeto, Tramitacao) from sigi.apps.convenios.reports import ConvenioReport from sigi.apps.convenios.views import adicionar_convenios_carrinho from sigi.apps.utils import queryset_ascii diff --git a/sigi/apps/convenios/models.py b/sigi/apps/convenios/models.py index 7bf0f92..ad490c9 100644 --- a/sigi/apps/convenios/models.py +++ b/sigi/apps/convenios/models.py @@ -1,5 +1,6 @@ # style="list-style-type: noneo -*- coding: utf-8 -*- from datetime import datetime + from django.db import models from django.utils.translation import ugettext as _ diff --git a/sigi/apps/convenios/reports.py b/sigi/apps/convenios/reports.py index 15f68a8..a4dce18 100644 --- a/sigi/apps/convenios/reports.py +++ b/sigi/apps/convenios/reports.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.utils.translation import ugettext as _ -from geraldo import ReportBand, ObjectValue, Label, ReportGroup, FIELD_ACTION_SUM +from geraldo import (FIELD_ACTION_SUM, Label, ObjectValue, ReportBand, + ReportGroup) from reportlab.lib.units import cm from sigi.apps.relatorios.reports import ReportDefault diff --git a/sigi/apps/convenios/urls.py b/sigi/apps/convenios/urls.py index d3b753a..a8917ef 100644 --- a/sigi/apps/convenios/urls.py +++ b/sigi/apps/convenios/urls.py @@ -1,7 +1,6 @@ # coding: utf-8 from django.conf.urls import patterns, url - urlpatterns = patterns( 'sigi.apps.convenios.views', diff --git a/sigi/apps/convenios/views.py b/sigi/apps/convenios/views.py index 733dc18..af50126 100644 --- a/sigi/apps/convenios/views.py +++ b/sigi/apps/convenios/views.py @@ -1,12 +1,13 @@ #-*- coding:utf-8 -*- import csv - import datetime + import ho.pisa as pisa from django.conf import settings -from django.core.paginator import Paginator, InvalidPage, EmptyPage +from django.contrib.auth.decorators import login_required +from django.core.paginator import EmptyPage, InvalidPage, Paginator from django.http import HttpResponse, HttpResponseRedirect -from django.shortcuts import render, get_list_or_404 +from django.shortcuts import get_list_or_404, render from django.template import Context, loader from django.utils.translation import ugettext as _ from geraldo.generators import PDFGenerator @@ -14,8 +15,10 @@ from geraldo.generators import PDFGenerator from sigi.apps.casas.models import CasaLegislativa from sigi.apps.contatos.models import UnidadeFederativa from sigi.apps.convenios.models import Convenio, Projeto -from sigi.apps.convenios.reports import ConvenioPorCMReport, ConvenioPorALReport, ConvenioReportSemAceiteAL, ConvenioReportSemAceiteCM -from django.contrib.auth.decorators import login_required +from sigi.apps.convenios.reports import (ConvenioPorALReport, + ConvenioPorCMReport, + ConvenioReportSemAceiteAL, + ConvenioReportSemAceiteCM) def query_ordena(qs, o, ot): diff --git a/sigi/apps/crud/base.py b/sigi/apps/crud/base.py index 1d5f22c..b1a9ad3 100644 --- a/sigi/apps/crud/base.py +++ b/sigi/apps/crud/base.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from braces.views import FormMessagesMixin from django.conf.urls import url from django.core.urlresolvers import reverse @@ -9,8 +10,10 @@ from django.utils.translation import ugettext_lazy as _ from django.views.generic import (CreateView, DeleteView, DetailView, ListView, UpdateView) +from sigi.apps.crispy_layout_mixin import (CrispyLayoutFormMixin, + get_field_display) + from .utils import make_pagination -from sigi.apps.crispy_layout_mixin import CrispyLayoutFormMixin, get_field_display LIST, CREATE, DETAIL, UPDATE, DELETE = \ u'list', u'create', u'detail', u'update', u'delete' diff --git a/sigi/apps/crud/urls.py b/sigi/apps/crud/urls.py index b17b6df..51fdfd6 100644 --- a/sigi/apps/crud/urls.py +++ b/sigi/apps/crud/urls.py @@ -1,4 +1,5 @@ from __future__ import absolute_import + from django.conf.urls import include, url urlpatterns = [ diff --git a/sigi/apps/crud/utils.py b/sigi/apps/crud/utils.py index 53bf2b2..bf7723e 100644 --- a/sigi/apps/crud/utils.py +++ b/sigi/apps/crud/utils.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from django.utils.translation import ugettext_lazy as _ UF = [ diff --git a/sigi/apps/diagnosticos/admin.py b/sigi/apps/diagnosticos/admin.py index 402e7da..4ffb1a3 100644 --- a/sigi/apps/diagnosticos/admin.py +++ b/sigi/apps/diagnosticos/admin.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- from datetime import datetime + from django.contrib import admin from django.db.utils import OperationalError, ProgrammingError from django.utils.translation import ugettext as _ from eav.admin import BaseEntityAdmin, BaseSchemaAdmin from sigi.apps.diagnosticos.forms import DiagnosticoForm -from sigi.apps.diagnosticos.models import Diagnostico, Pergunta, Escolha, Equipe, Anexo, Categoria +from sigi.apps.diagnosticos.models import (Anexo, Categoria, Diagnostico, + Equipe, Escolha, Pergunta) from sigi.apps.utils.base_admin import BaseModelAdmin diff --git a/sigi/apps/diagnosticos/decorators.py b/sigi/apps/diagnosticos/decorators.py index 253f403..417e67c 100644 --- a/sigi/apps/diagnosticos/decorators.py +++ b/sigi/apps/diagnosticos/decorators.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -from django.template import RequestContext from django.shortcuts import render_to_response +from django.template import RequestContext + from sigi.apps.diagnosticos.models import Diagnostico diff --git a/sigi/apps/diagnosticos/forms.py b/sigi/apps/diagnosticos/forms.py index e381ccc..d426bd9 100644 --- a/sigi/apps/diagnosticos/forms.py +++ b/sigi/apps/diagnosticos/forms.py @@ -3,9 +3,8 @@ from copy import deepcopy from django import forms from django.contrib.contenttypes.forms import generic_inlineformset_factory -from django.forms import (BooleanField, CharField, DateField, - FloatField, ModelChoiceField, Textarea, - ModelMultipleChoiceField) +from django.forms import (BooleanField, CharField, DateField, FloatField, + ModelChoiceField, ModelMultipleChoiceField, Textarea) from django.forms.forms import BoundField from django.utils.translation import ugettext as _ from eav.fields import RangeField @@ -14,7 +13,8 @@ from eav.forms import BaseDynamicEntityForm from sigi.apps.casas.models import CasaLegislativa, Funcionario from sigi.apps.contatos.models import Telefone from sigi.apps.diagnosticos.models import Diagnostico -from sigi.apps.diagnosticos.widgets import EavCheckboxSelectMultiple, EavRadioSelect +from sigi.apps.diagnosticos.widgets import (EavCheckboxSelectMultiple, + EavRadioSelect) class DiagnosticoForm(BaseDynamicEntityForm): diff --git a/sigi/apps/diagnosticos/models.py b/sigi/apps/diagnosticos/models.py index 45030e2..7f55468 100644 --- a/sigi/apps/diagnosticos/models.py +++ b/sigi/apps/diagnosticos/models.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- from datetime import datetime + from django.db import models from django.utils.translation import ugettext as _ -from eav.models import BaseChoice, BaseEntity, BaseSchema, BaseAttribute +from eav.models import BaseAttribute, BaseChoice, BaseEntity, BaseSchema from sigi.apps.utils import SearchField from sigi.apps.utils.email import enviar_email diff --git a/sigi/apps/diagnosticos/templatetags/smart_if.py b/sigi/apps/diagnosticos/templatetags/smart_if.py index 5a09cd3..4de3c60 100644 --- a/sigi/apps/diagnosticos/templatetags/smart_if.py +++ b/sigi/apps/diagnosticos/templatetags/smart_if.py @@ -9,7 +9,6 @@ greater than and less than operators. Some common case examples:: """ from django import template - register = template.Library() diff --git a/sigi/apps/diagnosticos/templatetags/test_smart_if.py b/sigi/apps/diagnosticos/templatetags/test_smart_if.py index 9101bf9..29b3411 100644 --- a/sigi/apps/diagnosticos/templatetags/test_smart_if.py +++ b/sigi/apps/diagnosticos/templatetags/test_smart_if.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import pytest -from smart_if import Or, And, Equals, Greater, GreaterOrEqual, In, IfParser +from smart_if import And, Equals, Greater, GreaterOrEqual, IfParser, In, Or class TestVar(object): diff --git a/sigi/apps/diagnosticos/urls.py b/sigi/apps/diagnosticos/urls.py index 3e170d3..1b4d551 100644 --- a/sigi/apps/diagnosticos/urls.py +++ b/sigi/apps/diagnosticos/urls.py @@ -2,7 +2,6 @@ from django.conf.urls import patterns, url from django.views.generic import TemplateView - LOGIN_REDIRECT_URL = '/diagnosticos/mobile/login' urlpatterns = patterns( diff --git a/sigi/apps/diagnosticos/views.py b/sigi/apps/diagnosticos/views.py index 2807abe..3768c57 100644 --- a/sigi/apps/diagnosticos/views.py +++ b/sigi/apps/diagnosticos/views.py @@ -3,7 +3,7 @@ import json as simplejson # XXX trocar isso por simplesmente import json e refa from itertools import cycle from django.http import HttpResponse -from django.shortcuts import render_to_response, get_object_or_404 +from django.shortcuts import get_object_or_404, render_to_response from django.template import RequestContext from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache @@ -11,9 +11,10 @@ from django.views.decorators.cache import never_cache from sigi.apps.casas.models import Funcionario from sigi.apps.contatos.models import Telefone from sigi.apps.diagnosticos.decorators import validate_diagnostico -from sigi.apps.diagnosticos.forms import (DiagnosticoMobileForm, - CasaLegislativaMobileForm, FuncionariosMobileForm) -from sigi.apps.diagnosticos.models import Diagnostico, Categoria, Pergunta +from sigi.apps.diagnosticos.forms import (CasaLegislativaMobileForm, + DiagnosticoMobileForm, + FuncionariosMobileForm) +from sigi.apps.diagnosticos.models import Categoria, Diagnostico, Pergunta from sigi.apps.diagnosticos.urls import LOGIN_REDIRECT_URL from sigi.apps.utils.decorators import login_required from sigi.shortcuts import render_to_pdf diff --git a/sigi/apps/diagnosticos/widgets.py b/sigi/apps/diagnosticos/widgets.py index 5dc7a44..f0c8d32 100644 --- a/sigi/apps/diagnosticos/widgets.py +++ b/sigi/apps/diagnosticos/widgets.py @@ -1,8 +1,12 @@ from itertools import chain -from django.forms.widgets import CheckboxInput, CheckboxSelectMultiple, RadioSelect, RadioFieldRenderer, RadioChoiceInput -from django.utils.html import conditional_escape + +from django.forms.widgets import (CheckboxInput, CheckboxSelectMultiple, + RadioChoiceInput, RadioFieldRenderer, + RadioSelect) from django.utils.encoding import force_unicode +from django.utils.html import conditional_escape from django.utils.safestring import mark_safe + from sigi.apps.diagnosticos.models import Escolha diff --git a/sigi/apps/eventos/admin.py b/sigi/apps/eventos/admin.py index fb1c415..6723ff1 100644 --- a/sigi/apps/eventos/admin.py +++ b/sigi/apps/eventos/admin.py @@ -18,10 +18,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -from django.contrib import admin from django import forms +from django.contrib import admin from django.utils.translation import ugettext as _ -from sigi.apps.eventos.models import TipoEvento, Funcao, Evento, Equipe, Convite + +from sigi.apps.eventos.models import (Convite, Equipe, Evento, Funcao, + TipoEvento) + class EventoAdminForm(forms.ModelForm): class Meta: @@ -67,5 +70,3 @@ class EventoAdmin(admin.ModelAdmin): search_fields = ('nome', 'tipo_evento__nome', 'casa_anfitria__search_text', 'municipio__search_text', 'solicitante') inlines = (EquipeInline, ConviteInline) - - diff --git a/sigi/apps/eventos/models.py b/sigi/apps/eventos/models.py index 0374d26..9a6eea4 100644 --- a/sigi/apps/eventos/models.py +++ b/sigi/apps/eventos/models.py @@ -18,15 +18,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +from django.core.exceptions import ValidationError from django.db import models from django.utils.functional import lazy from django.utils.translation import ugettext as _ + from sigi.apps.casas.models import CasaLegislativa from sigi.apps.contatos.models import Municipio +from sigi.apps.mdl.models import Course from sigi.apps.servidores.models import Servidor from sigi.apps.utils.moodle_ws_api import get_courses -from django.core.exceptions import ValidationError -from sigi.apps.mdl.models import Course + class TipoEvento(models.Model): nome = models.CharField(_(u"Nome"), max_length=100) @@ -138,4 +140,4 @@ class Convite(models.Model): class Meta: ordering = ('evento', 'casa', '-data_convite') unique_together = ('evento', 'casa') - verbose_name, verbose_name_plural = _(u"Casa convidada"), _(u"Casas convidadas") \ No newline at end of file + verbose_name, verbose_name_plural = _(u"Casa convidada"), _(u"Casas convidadas") diff --git a/sigi/apps/eventos/urls.py b/sigi/apps/eventos/urls.py index a648c7c..9967641 100644 --- a/sigi/apps/eventos/urls.py +++ b/sigi/apps/eventos/urls.py @@ -1,7 +1,6 @@ # coding: utf-8 from django.conf.urls import patterns, url - urlpatterns = patterns( 'sigi.apps.eventos.views', # Painel de ocorrencias diff --git a/sigi/apps/eventos/views.py b/sigi/apps/eventos/views.py index e6ab84b..9f414df 100644 --- a/sigi/apps/eventos/views.py +++ b/sigi/apps/eventos/views.py @@ -19,17 +19,21 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import calendar +import csv import datetime import locale + from django.contrib.auth.decorators import login_required +from django.http.response import HttpResponse, JsonResponse from django.shortcuts import render from django.utils import translation -from django.utils.translation import ungettext, ugettext as _ +from django.utils.translation import ugettext as _ +from django.utils.translation import ungettext + from sigi.apps.eventos.models import Evento from sigi.apps.servidores.models import Servidor from sigi.shortcuts import render_to_pdf -import csv -from django.http.response import JsonResponse, HttpResponse + @login_required def calendario(request): @@ -188,4 +192,4 @@ def alocacao_equipe(request): } for d in dados]} return JsonResponse(result) - return render(request, 'eventos/alocacao_equipe.html', data) \ No newline at end of file + return render(request, 'eventos/alocacao_equipe.html', data) diff --git a/sigi/apps/home/templatetags/menus.py b/sigi/apps/home/templatetags/menus.py index f8819fd..5bf6094 100644 --- a/sigi/apps/home/templatetags/menus.py +++ b/sigi/apps/home/templatetags/menus.py @@ -3,7 +3,6 @@ from os.path import dirname import yaml from django import template - register = template.Library() menus = yaml.load(open(dirname(__file__) + '/menu_conf.yaml', 'r')) diff --git a/sigi/apps/home/urls.py b/sigi/apps/home/urls.py index 2d6b091..94bc18f 100644 --- a/sigi/apps/home/urls.py +++ b/sigi/apps/home/urls.py @@ -2,7 +2,6 @@ from django.conf.urls import patterns, url from django.views.generic.base import TemplateView - urlpatterns = patterns( 'sigi.apps.home.views', url(r'^home/atendimento', TemplateView.as_view( diff --git a/sigi/apps/home/views.py b/sigi/apps/home/views.py index bef5f52..ca47794 100644 --- a/sigi/apps/home/views.py +++ b/sigi/apps/home/views.py @@ -22,24 +22,27 @@ # 02110-1301, USA. # -import datetime import calendar -from django.shortcuts import render, get_object_or_404 -from django.utils.translation import ugettext as _ +import csv +import datetime from itertools import cycle + +from django.contrib.auth.decorators import login_required +from django.core.urlresolvers import reverse +from django.db.models import Count, Q +from django.http.response import HttpResponse, JsonResponse +from django.shortcuts import get_object_or_404, render +from django.utils.translation import ugettext as _ +from django.views.decorators.cache import never_cache + from sigi.apps.casas.models import CasaLegislativa from sigi.apps.convenios.models import Convenio, Projeto from sigi.apps.diagnosticos.models import Diagnostico from sigi.apps.metas.models import Meta from sigi.apps.servicos.models import TipoServico from sigi.apps.servidores.models import Servidor -from django.views.decorators.cache import never_cache -from django.contrib.auth.decorators import login_required -from django.http.response import JsonResponse, HttpResponse -from django.core.urlresolvers import reverse -from django.db.models import Q, Count from sigi.shortcuts import render_to_pdf -import csv + @never_cache @login_required diff --git a/sigi/apps/inventario/admin.py b/sigi/apps/inventario/admin.py index 5a5b00a..e8faed0 100644 --- a/sigi/apps/inventario/admin.py +++ b/sigi/apps/inventario/admin.py @@ -3,9 +3,9 @@ from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline from sigi.apps.contatos.models import Contato, Telefone -from sigi.apps.inventario.models import (Fornecedor, Fabricante, Equipamento, - TipoEquipamento, ModeloEquipamento, - Bem) +from sigi.apps.inventario.models import (Bem, Equipamento, Fabricante, + Fornecedor, ModeloEquipamento, + TipoEquipamento) from sigi.apps.utils.base_admin import BaseModelAdmin diff --git a/sigi/apps/mdl/models.py b/sigi/apps/mdl/models.py index 0466b45..0e22936 100644 --- a/sigi/apps/mdl/models.py +++ b/sigi/apps/mdl/models.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals + from django.db import models diff --git a/sigi/apps/metas/models.py b/sigi/apps/metas/models.py index 3ca3c36..5b1a58d 100644 --- a/sigi/apps/metas/models.py +++ b/sigi/apps/metas/models.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from datetime import date + from django.db import models from django.utils.translation import ugettext as _ from sigi.apps.casas.models import CasaLegislativa -from sigi.apps.convenios.models import Projeto, Convenio +from sigi.apps.convenios.models import Convenio, Projeto from sigi.apps.diagnosticos.models import Diagnostico from sigi.apps.financeiro.models import Desembolso diff --git a/sigi/apps/metas/templatetags/mapa_tags.py b/sigi/apps/metas/templatetags/mapa_tags.py index 79039a6..0e885a1 100644 --- a/sigi/apps/metas/templatetags/mapa_tags.py +++ b/sigi/apps/metas/templatetags/mapa_tags.py @@ -5,7 +5,6 @@ from django.utils.safestring import mark_safe from sigi.apps.casas.models import CasaLegislativa from sigi.apps.metas.views import parliament_summary - register = template.Library() diff --git a/sigi/apps/metas/urls.py b/sigi/apps/metas/urls.py index 3d89a57..7c7dad4 100644 --- a/sigi/apps/metas/urls.py +++ b/sigi/apps/metas/urls.py @@ -1,7 +1,6 @@ # coding: utf-8 from django.conf.urls import patterns, url - urlpatterns = patterns( 'sigi.apps.metas.views', diff --git a/sigi/apps/metas/views.py b/sigi/apps/metas/views.py index a1f086d..de8971a 100644 --- a/sigi/apps/metas/views.py +++ b/sigi/apps/metas/views.py @@ -3,6 +3,7 @@ import csv import json as simplejson # XXX trocar isso por simplesmente import json e refatorar o codigo import os import time +from collections import OrderedDict from functools import reduce from django.contrib.auth.decorators import login_required @@ -12,7 +13,6 @@ from django.db.models.aggregates import Sum from django.http import HttpResponse from django.shortcuts import render, render_to_response from django.template import RequestContext -from collections import OrderedDict from django.utils.translation import ugettext as _ from django.views.decorators.cache import cache_page from easy_thumbnails.templatetags.thumbnail import thumbnail_url @@ -26,7 +26,6 @@ from sigi.apps.utils import to_ascii from sigi.settings import MEDIA_ROOT, STATIC_URL from sigi.shortcuts import render_to_pdf - JSON_FILE_NAME = os.path.join(MEDIA_ROOT, 'apps/metas/map_data.json') diff --git a/sigi/apps/ocorrencias/admin.py b/sigi/apps/ocorrencias/admin.py index 4cf1dd6..ccf8d88 100644 --- a/sigi/apps/ocorrencias/admin.py +++ b/sigi/apps/ocorrencias/admin.py @@ -4,7 +4,8 @@ from django.contrib.admin.views.main import ChangeList from django.utils.translation import ugettext as _ from filters import OcorrenciaListFilter -from sigi.apps.ocorrencias.models import Ocorrencia, Comentario, Anexo, Categoria, TipoContato +from sigi.apps.ocorrencias.models import (Anexo, Categoria, Comentario, + Ocorrencia, TipoContato) from sigi.apps.servidores.models import Servidor from sigi.apps.utils.base_admin import BaseModelAdmin diff --git a/sigi/apps/ocorrencias/forms.py b/sigi/apps/ocorrencias/forms.py index 45e01d9..746a2a7 100644 --- a/sigi/apps/ocorrencias/forms.py +++ b/sigi/apps/ocorrencias/forms.py @@ -21,15 +21,17 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # -from django.forms import ModelForm, ModelChoiceField, HiddenInput, TextInput -from sigi.apps.ocorrencias.models import Ocorrencia, Comentario, Anexo -from sigi.apps.servidores.models import Servico +from django.core.urlresolvers import reverse_lazy +from django.forms import HiddenInput, ModelChoiceField, ModelForm, TextInput +from django.forms.utils import flatatt from django.utils.encoding import force_text from django.utils.html import format_html -from django.forms.utils import flatatt -from django.core.urlresolvers import reverse_lazy from django.utils.safestring import mark_safe +from sigi.apps.ocorrencias.models import Anexo, Comentario, Ocorrencia +from sigi.apps.servidores.models import Servico + + class AjaxSelect(TextInput): url = "" def __init__(self, url, attrs=None): diff --git a/sigi/apps/ocorrencias/models.py b/sigi/apps/ocorrencias/models.py index 125bd1c..d9932bb 100644 --- a/sigi/apps/ocorrencias/models.py +++ b/sigi/apps/ocorrencias/models.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from django.db import models from django.conf import settings -from django.utils.translation import ugettext as _ from django.core.exceptions import ValidationError +from django.db import models from django.utils.safestring import mark_safe +from django.utils.translation import ugettext as _ class Categoria(models.Model): diff --git a/sigi/apps/ocorrencias/urls.py b/sigi/apps/ocorrencias/urls.py index f98cb08..c6c8257 100644 --- a/sigi/apps/ocorrencias/urls.py +++ b/sigi/apps/ocorrencias/urls.py @@ -1,7 +1,6 @@ # coding: utf-8 from django.conf.urls import patterns, url - urlpatterns = patterns( 'sigi.apps.ocorrencias.views', # Painel de ocorrencias diff --git a/sigi/apps/ocorrencias/views.py b/sigi/apps/ocorrencias/views.py index bc9f168..7b4bce2 100644 --- a/sigi/apps/ocorrencias/views.py +++ b/sigi/apps/ocorrencias/views.py @@ -1,19 +1,23 @@ # -*- coding: utf-8 -*- -from django.http import JsonResponse, Http404 -from django.db.models import Q, Count -from django.utils.translation import ungettext, ugettext as _ -from django.shortcuts import get_object_or_404, render, HttpResponse from django.contrib.auth.decorators import login_required -from django.views.decorators.http import require_POST -from django.template.loader import render_to_string +from django.db.models import Count, Q +from django.http import Http404, JsonResponse +from django.shortcuts import HttpResponse, get_object_or_404, render from django.template import RequestContext -from sigi.apps.utils import to_ascii +from django.template.loader import render_to_string +from django.utils.html import escape +from django.utils.translation import ugettext as _ +from django.utils.translation import ungettext +from django.views.decorators.http import require_POST + from sigi.apps.casas.models import CasaLegislativa from sigi.apps.contatos.models import UnidadeFederativa -from sigi.apps.servidores.models import Servidor, Servico -from sigi.apps.ocorrencias.models import Ocorrencia, Anexo -from sigi.apps.ocorrencias.forms import AnexoForm, ComentarioForm, OcorrenciaForm -from django.utils.html import escape +from sigi.apps.ocorrencias.forms import (AnexoForm, ComentarioForm, + OcorrenciaForm) +from sigi.apps.ocorrencias.models import Anexo, Ocorrencia +from sigi.apps.servidores.models import Servico, Servidor +from sigi.apps.utils import to_ascii + @login_required def painel_ocorrencias(request): @@ -212,4 +216,4 @@ def inclui_ocorrencia(request): {'ocorrencia_form': form}, context_instance=RequestContext(request)) - return JsonResponse(data) \ No newline at end of file + return JsonResponse(data) diff --git a/sigi/apps/parlamentares/admin.py b/sigi/apps/parlamentares/admin.py index e42e8c3..9f97448 100644 --- a/sigi/apps/parlamentares/admin.py +++ b/sigi/apps/parlamentares/admin.py @@ -1,14 +1,16 @@ # -*- coding: utf-8 -*- from django.contrib import admin -from django.contrib.contenttypes.admin import GenericTabularInline -from django.http import HttpResponseRedirect, HttpResponse +from django.contrib.contenttypes.admin import GenericTabularInline +from django.http import HttpResponse, HttpResponseRedirect from django.utils.html import escape, escapejs from django.utils.translation import ugettext as _ from sigi.apps.contatos.models import Telefone -from sigi.apps.parlamentares.models import ( - Partido, Parlamentar, Mandato, Legislatura, Coligacao, ComposicaoColigacao, - SessaoLegislativa, MesaDiretora, Cargo, MembroMesaDiretora) +from sigi.apps.parlamentares.models import (Cargo, Coligacao, + ComposicaoColigacao, Legislatura, + Mandato, MembroMesaDiretora, + MesaDiretora, Parlamentar, Partido, + SessaoLegislativa) from sigi.apps.parlamentares.views import adicionar_parlamentar_carrinho from sigi.apps.utils.base_admin import BaseModelAdmin from sigi.apps.utils.filters import AlphabeticFilter diff --git a/sigi/apps/parlamentares/reports.py b/sigi/apps/parlamentares/reports.py index adbe021..1d43eb4 100644 --- a/sigi/apps/parlamentares/reports.py +++ b/sigi/apps/parlamentares/reports.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- from django.templatetags.static import static from django.utils.translation import ugettext as _ -from geraldo import Report, DetailBand, Label, ObjectValue, ReportGroup, ReportBand, landscape, SubReport, BAND_WIDTH, SystemField +from geraldo import (BAND_WIDTH, DetailBand, Label, ObjectValue, Report, + ReportBand, ReportGroup, SubReport, SystemField, + landscape) from geraldo.graphics import Image from reportlab.lib.enums import TA_CENTER from reportlab.lib.pagesizes import A4 diff --git a/sigi/apps/parlamentares/test_parlamentares.py b/sigi/apps/parlamentares/test_parlamentares.py index 271820d..3c9cff4 100644 --- a/sigi/apps/parlamentares/test_parlamentares.py +++ b/sigi/apps/parlamentares/test_parlamentares.py @@ -4,7 +4,6 @@ from django_dynamic_fixture import G from sigi.apps.parlamentares.models import Parlamentar - pytestmark = pytest.mark.django_db diff --git a/sigi/apps/parlamentares/views.py b/sigi/apps/parlamentares/views.py index 33d66e4..063d01b 100644 --- a/sigi/apps/parlamentares/views.py +++ b/sigi/apps/parlamentares/views.py @@ -1,22 +1,20 @@ # coding: utf-8 -import datetime import csv +import datetime -from django.template import Context, loader -from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.conf import settings -from django.shortcuts import render, get_list_or_404 +from django.contrib.auth.decorators import login_required +from django.core.paginator import EmptyPage, InvalidPage, Paginator from django.http import HttpResponse, HttpResponseRedirect +from django.shortcuts import get_list_or_404, render +from django.template import Context, RequestContext, loader from django.views.decorators.csrf import csrf_protect -from django.template import RequestContext +from geraldo.generators import PDFGenerator from sigi.apps.casas.models import CasaLegislativa from sigi.apps.parlamentares.models import Parlamentar from sigi.apps.parlamentares.reports import ParlamentaresLabels -from geraldo.generators import PDFGenerator -from django.contrib.auth.decorators import login_required - def adicionar_parlamentar_carrinho(request, queryset=None, id=None): if request.method == 'POST': diff --git a/sigi/apps/relatorios/reports.py b/sigi/apps/relatorios/reports.py index 9bf82de..30bb1e0 100644 --- a/sigi/apps/relatorios/reports.py +++ b/sigi/apps/relatorios/reports.py @@ -3,7 +3,8 @@ import os from django.templatetags.static import static from django.utils.translation import ugettext as _ -from geraldo import Report, ReportBand, ObjectValue, DetailBand, Label, SystemField, BAND_WIDTH, FIELD_ACTION_COUNT, Line +from geraldo import (BAND_WIDTH, FIELD_ACTION_COUNT, DetailBand, Label, Line, + ObjectValue, Report, ReportBand, SystemField) from geraldo.graphics import Image from reportlab.lib.colors import navy from reportlab.lib.enums import TA_CENTER, TA_RIGHT diff --git a/sigi/apps/saberes/admin.py b/sigi/apps/saberes/admin.py index e9749de..9798544 100644 --- a/sigi/apps/saberes/admin.py +++ b/sigi/apps/saberes/admin.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from django.utils.translation import ugettext as _ from django.contrib import admin +from django.utils.translation import ugettext as _ + from sigi.apps.saberes.models import CategoriasInteresse diff --git a/sigi/apps/saberes/management/commands/get_moodle_stats.py b/sigi/apps/saberes/management/commands/get_moodle_stats.py index 29dcfb2..6984b8b 100644 --- a/sigi/apps/saberes/management/commands/get_moodle_stats.py +++ b/sigi/apps/saberes/management/commands/get_moodle_stats.py @@ -21,12 +21,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # -from django.utils.translation import ugettext as _ from django.core.management.base import BaseCommand -from django.db.models import Sum, Avg +from django.db.models import Avg, Sum +from django.utils.translation import ugettext as _ + +from sigi.apps.mdl.models import CourseStats, User from sigi.apps.metas.views import gera_map_data_file from sigi.apps.saberes.models import CategoriasInteresse, PainelItem -from sigi.apps.mdl.models import User, CourseStats class Command(BaseCommand): diff --git a/sigi/apps/saberes/models.py b/sigi/apps/saberes/models.py index a200aeb..30b11ef 100644 --- a/sigi/apps/saberes/models.py +++ b/sigi/apps/saberes/models.py @@ -1,10 +1,13 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.utils.translation import ugettext as _ + from django.db import models from django.db.models import Q -from sigi.apps.mdl.models import Course, CourseCategories, CourseCompletions, UserEnrolments +from django.utils.translation import ugettext as _ + +from sigi.apps.mdl.models import (Course, CourseCategories, CourseCompletions, + UserEnrolments) class CategoriasInteresse(models.Model): diff --git a/sigi/apps/saberes/urls.py b/sigi/apps/saberes/urls.py index 05254fc..7a6d1bc 100644 --- a/sigi/apps/saberes/urls.py +++ b/sigi/apps/saberes/urls.py @@ -1,8 +1,8 @@ # coding: utf-8 from django.conf.urls import patterns, url -from .views import cursos_sem_tutoria, cursos_com_tutoria, dashboard, pentaho_proxy - +from .views import (cursos_com_tutoria, cursos_sem_tutoria, dashboard, + pentaho_proxy) urlpatterns = patterns( 'sigi.apps.saberes.views', diff --git a/sigi/apps/saberes/views.py b/sigi/apps/saberes/views.py index 28951f7..b7798b6 100644 --- a/sigi/apps/saberes/views.py +++ b/sigi/apps/saberes/views.py @@ -5,8 +5,8 @@ from django.shortcuts import render from django.views.decorators.csrf import csrf_exempt from requests.auth import HTTPBasicAuth -from sigi.settings import PENTAHO_SERVER, PENTAHO_DASHBOARDS, PENTAHO_USERNAME_PASSWORD - +from sigi.settings import (PENTAHO_DASHBOARDS, PENTAHO_SERVER, + PENTAHO_USERNAME_PASSWORD) PENTAHO_CDF_URL = 'http://%s/pentaho/plugin/pentaho-cdf-dd/api/renderer/' % PENTAHO_SERVER diff --git a/sigi/apps/servicos/admin.py b/sigi/apps/servicos/admin.py index 7e7da33..5badf83 100644 --- a/sigi/apps/servicos/admin.py +++ b/sigi/apps/servicos/admin.py @@ -8,7 +8,8 @@ from django.utils.translation import ugettext as _ from sigi.apps.casas.admin import FuncionariosInline from sigi.apps.casas.models import CasaLegislativa -from sigi.apps.servicos.models import Servico, LogServico, CasaAtendida, TipoServico +from sigi.apps.servicos.models import (CasaAtendida, LogServico, Servico, + TipoServico) from sigi.apps.utils.base_admin import BaseModelAdmin diff --git a/sigi/apps/servicos/models.py b/sigi/apps/servicos/models.py index 107bf1b..8eeee00 100644 --- a/sigi/apps/servicos/models.py +++ b/sigi/apps/servicos/models.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- from datetime import date + from django.db import models -from sigi.apps.casas.models import CasaLegislativa, Funcionario from django.utils.translation import ugettext as _ +from sigi.apps.casas.models import CasaLegislativa, Funcionario + class TipoServico(models.Model): MODO_CHOICES = ( @@ -219,4 +221,3 @@ class RegistroServico(models.Model): class Meta: verbose_name_plural = _(u'Registro de serviços') - diff --git a/sigi/apps/servicos/urls.py b/sigi/apps/servicos/urls.py index 8c91807..22f9e9f 100644 --- a/sigi/apps/servicos/urls.py +++ b/sigi/apps/servicos/urls.py @@ -4,7 +4,6 @@ from django.views.generic.base import TemplateView from .views import MapaView - urlpatterns = patterns( 'sigi.apps.servicos.views', diff --git a/sigi/apps/servicos/views.py b/sigi/apps/servicos/views.py index ab7a47c..7196a76 100644 --- a/sigi/apps/servicos/views.py +++ b/sigi/apps/servicos/views.py @@ -5,14 +5,15 @@ from django import forms from django.db.models import Q from django.forms.forms import BoundField from django.http import HttpResponse -from django.shortcuts import render_to_response, get_object_or_404 +from django.shortcuts import get_object_or_404, render_to_response from django.template.context import RequestContext from django.utils.translation import ugettext as _ from django.views.generic.base import TemplateView from sigi.apps.casas.models import CasaLegislativa from sigi.apps.contatos.models import UnidadeFederativa -from sigi.apps.servicos.models import TipoServico, CasaAtendida, CasaManifesta, ServicoManifesto +from sigi.apps.servicos.models import (CasaAtendida, CasaManifesta, + ServicoManifesto, TipoServico) class MapaView(TemplateView): diff --git a/sigi/apps/servidores/admin.py b/sigi/apps/servidores/admin.py index 033b14b..033ea24 100644 --- a/sigi/apps/servidores/admin.py +++ b/sigi/apps/servidores/admin.py @@ -4,8 +4,9 @@ from django.contrib.contenttypes import admin as generic from django.utils.translation import ugettext as _ from sigi.apps.contatos.models import Endereco, Telefone -from sigi.apps.servidores.forms import FeriasForm, LicencaForm, FuncaoForm -from sigi.apps.servidores.models import Servidor, Funcao, Licenca, Ferias, Servico, Subsecretaria +from sigi.apps.servidores.forms import FeriasForm, FuncaoForm, LicencaForm +from sigi.apps.servidores.models import (Ferias, Funcao, Licenca, Servico, + Servidor, Subsecretaria) from sigi.apps.utils.admin_widgets import AdminImageWidget from sigi.apps.utils.base_admin import BaseModelAdmin from sigi.apps.utils.filters import AlphabeticFilter diff --git a/sigi/apps/servidores/forms.py b/sigi/apps/servidores/forms.py index 3f01a95..307ff0f 100644 --- a/sigi/apps/servidores/forms.py +++ b/sigi/apps/servidores/forms.py @@ -4,7 +4,7 @@ from collections import namedtuple from django import forms from django.utils.translation import ugettext as _ -from sigi.apps.servidores.models import Ferias, Licenca, Funcao, Servidor +from sigi.apps.servidores.models import Ferias, Funcao, Licenca, Servidor def valida_data_inicial_menor_que_final(data, chave_ini, chave_fim): diff --git a/sigi/apps/servidores/management/commands/migra.py b/sigi/apps/servidores/management/commands/migra.py index c6187ca..c6603f0 100644 --- a/sigi/apps/servidores/management/commands/migra.py +++ b/sigi/apps/servidores/management/commands/migra.py @@ -1,14 +1,14 @@ # coding= utf-8 import csv import re - from datetime import datetime + from django.contrib.auth.models import User from django.core.management.base import BaseCommand from django.utils.translation import ugettext as _ from sigi.apps.contatos.models import Municipio -from sigi.apps.servidores.models import Servidor, Servico, Subsecretaria +from sigi.apps.servidores.models import Servico, Servidor, Subsecretaria # Funcao.objects.all().delete() diff --git a/sigi/apps/servidores/management/commands/sync_ldap.py b/sigi/apps/servidores/management/commands/sync_ldap.py index 6c2c9c3..f15d4ea 100644 --- a/sigi/apps/servidores/management/commands/sync_ldap.py +++ b/sigi/apps/servidores/management/commands/sync_ldap.py @@ -1,113 +1,113 @@ -# coding: utf-8 -import ldap -from django.contrib.auth.models import User, Group -from django.core.management.base import BaseCommand - -from sigi.apps.servidores.models import Servidor -from sigi.settings import * - - -class Command(BaseCommand): - help = u'Sincroniza Usuários e Servidores com o LDAP' - - def handle(self, *args, **options): - self.sync_groups() - self.sync_users() - - def get_ldap_groups(self): - filter = "(&(objectclass=Group))" - values = ['cn', ] - l = ldap.initialize(AUTH_LDAP_SERVER_URI) - l.protocol_version = ldap.VERSION3 - l.simple_bind_s(AUTH_LDAP_BIND_DN.encode('utf-8'), AUTH_LDAP_BIND_PASSWORD) - result_id = l.search(AUTH_LDAP_GROUP, ldap.SCOPE_SUBTREE, filter, values) - result_type, result_data = l.result(result_id, 1) - l.unbind() - return result_data - - def get_ldap_users(self): - filter = "(&(objectclass=user))" - values = ['sAMAccountName', 'userPrincipalName', 'givenName', 'sn', 'cn'] - l = ldap.initialize(AUTH_LDAP_SERVER_URI) - l.protocol_version = ldap.VERSION3 - l.simple_bind_s(AUTH_LDAP_BIND_DN.encode('utf-8'), AUTH_LDAP_BIND_PASSWORD) - result_id = l.search(AUTH_LDAP_USER.encode('utf-8'), ldap.SCOPE_SUBTREE, filter, values) - result_type, result_data = l.result(result_id, 1) - l.unbind() - return result_data - - def sync_groups(self): - ldap_groups = self.get_ldap_groups() - for ldap_group in ldap_groups: - try: - group_name = ldap_group[1]['cn'][0] - except: - pass - else: - try: - group = Group.objects.get(name=group_name) - except Group.DoesNotExist: - group = Group(name=group_name) - group.save() - print "Group '%s' created." % group_name - print "Groups are synchronized." - - def sync_users(self): - ldap_users = self.get_ldap_users() - - def get_ldap_property(ldap_user, property_name, default_value=None): - value = ldap_user[1].get(property_name, None) - return value[0].decode('utf8') if value else default_value - - for ldap_user in ldap_users: - username = get_ldap_property(ldap_user, 'sAMAccountName') - if username: - email = get_ldap_property(ldap_user, 'userPrincipalName', '') - first_name = get_ldap_property(ldap_user, 'givenName', username) - last_name = get_ldap_property(ldap_user, 'sn', '')[:30] - try: - user = User.objects.get(username=username) - except User.DoesNotExist: - try: - user = User.objects.get(email=email) - old_username = user.username - user.username = username - print "User with email '%s' had his/her username updated from [%s] to [%s]." % ( - email, old_username, username) - except User.DoesNotExist: - user = User.objects.create_user( - username=username, - first_name=first_name, - last_name=last_name, - email=email, - ) - print "User '%s' created." % username - - if not user.first_name == first_name: - user.first_name = first_name - print "User '%s' first name updated." % username - if not user.last_name == last_name: - user.last_name = last_name - print "User '%s' last name updated." % username - if not user.email == email: - user.email = email - print "User '%s' email updated." % username - - nome_completo = get_ldap_property(ldap_user, 'cn', '') - try: - servidor = user.servidor - except Servidor.DoesNotExist: - try: - servidor = Servidor.objects.get(nome_completo=nome_completo) - except Servidor.DoesNotExist: - servidor = user.servidor_set.create(nome_completo=nome_completo) - print "Servidor '%s' created." % nome_completo - else: - if not servidor.nome_completo == nome_completo: - servidor.nome_completo = nome_completo - print "Full name of Servidor '%s' updated." % nome_completo - - servidor.user = user - servidor.save() - user.save() - print "Users are synchronized." +# coding: utf-8 +import ldap +from django.contrib.auth.models import Group, User +from django.core.management.base import BaseCommand + +from sigi.apps.servidores.models import Servidor +from sigi.settings import * + + +class Command(BaseCommand): + help = u'Sincroniza Usuários e Servidores com o LDAP' + + def handle(self, *args, **options): + self.sync_groups() + self.sync_users() + + def get_ldap_groups(self): + filter = "(&(objectclass=Group))" + values = ['cn', ] + l = ldap.initialize(AUTH_LDAP_SERVER_URI) + l.protocol_version = ldap.VERSION3 + l.simple_bind_s(AUTH_LDAP_BIND_DN.encode('utf-8'), AUTH_LDAP_BIND_PASSWORD) + result_id = l.search(AUTH_LDAP_GROUP, ldap.SCOPE_SUBTREE, filter, values) + result_type, result_data = l.result(result_id, 1) + l.unbind() + return result_data + + def get_ldap_users(self): + filter = "(&(objectclass=user))" + values = ['sAMAccountName', 'userPrincipalName', 'givenName', 'sn', 'cn'] + l = ldap.initialize(AUTH_LDAP_SERVER_URI) + l.protocol_version = ldap.VERSION3 + l.simple_bind_s(AUTH_LDAP_BIND_DN.encode('utf-8'), AUTH_LDAP_BIND_PASSWORD) + result_id = l.search(AUTH_LDAP_USER.encode('utf-8'), ldap.SCOPE_SUBTREE, filter, values) + result_type, result_data = l.result(result_id, 1) + l.unbind() + return result_data + + def sync_groups(self): + ldap_groups = self.get_ldap_groups() + for ldap_group in ldap_groups: + try: + group_name = ldap_group[1]['cn'][0] + except: + pass + else: + try: + group = Group.objects.get(name=group_name) + except Group.DoesNotExist: + group = Group(name=group_name) + group.save() + print "Group '%s' created." % group_name + print "Groups are synchronized." + + def sync_users(self): + ldap_users = self.get_ldap_users() + + def get_ldap_property(ldap_user, property_name, default_value=None): + value = ldap_user[1].get(property_name, None) + return value[0].decode('utf8') if value else default_value + + for ldap_user in ldap_users: + username = get_ldap_property(ldap_user, 'sAMAccountName') + if username: + email = get_ldap_property(ldap_user, 'userPrincipalName', '') + first_name = get_ldap_property(ldap_user, 'givenName', username) + last_name = get_ldap_property(ldap_user, 'sn', '')[:30] + try: + user = User.objects.get(username=username) + except User.DoesNotExist: + try: + user = User.objects.get(email=email) + old_username = user.username + user.username = username + print "User with email '%s' had his/her username updated from [%s] to [%s]." % ( + email, old_username, username) + except User.DoesNotExist: + user = User.objects.create_user( + username=username, + first_name=first_name, + last_name=last_name, + email=email, + ) + print "User '%s' created." % username + + if not user.first_name == first_name: + user.first_name = first_name + print "User '%s' first name updated." % username + if not user.last_name == last_name: + user.last_name = last_name + print "User '%s' last name updated." % username + if not user.email == email: + user.email = email + print "User '%s' email updated." % username + + nome_completo = get_ldap_property(ldap_user, 'cn', '') + try: + servidor = user.servidor + except Servidor.DoesNotExist: + try: + servidor = Servidor.objects.get(nome_completo=nome_completo) + except Servidor.DoesNotExist: + servidor = user.servidor_set.create(nome_completo=nome_completo) + print "Servidor '%s' created." % nome_completo + else: + if not servidor.nome_completo == nome_completo: + servidor.nome_completo = nome_completo + print "Full name of Servidor '%s' updated." % nome_completo + + servidor.user = user + servidor.save() + user.save() + print "Users are synchronized." diff --git a/sigi/apps/servidores/management/commands/test_sync_ldap.py b/sigi/apps/servidores/management/commands/test_sync_ldap.py index d01d64d..4cac024 100644 --- a/sigi/apps/servidores/management/commands/test_sync_ldap.py +++ b/sigi/apps/servidores/management/commands/test_sync_ldap.py @@ -5,7 +5,6 @@ from django_dynamic_fixture import G from sigi.apps.servidores.management.commands.sync_ldap import Command - pytestmark = pytest.mark.django_db diff --git a/sigi/apps/servidores/test_servidores_forms.py b/sigi/apps/servidores/test_servidores_forms.py index cbbd838..975f03f 100644 --- a/sigi/apps/servidores/test_servidores_forms.py +++ b/sigi/apps/servidores/test_servidores_forms.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- -from django import forms -import pytest from datetime import date -from sigi.apps.servidores.forms import valida_data_inicial_menor_que_final, Periodo, periodos_se_sobrepoe +import pytest +from django import forms + +from sigi.apps.servidores.forms import (Periodo, periodos_se_sobrepoe, + valida_data_inicial_menor_que_final) @pytest.mark.parametrize('data', [ diff --git a/sigi/apps/servidores/urls.py b/sigi/apps/servidores/urls.py index 0a3c33c..60c122d 100644 --- a/sigi/apps/servidores/urls.py +++ b/sigi/apps/servidores/urls.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from django.conf.urls import patterns, url - urlpatterns = patterns( 'sigi.apps.servidores.views', diff --git a/sigi/apps/servidores/views.py b/sigi/apps/servidores/views.py index f229af4..4870804 100644 --- a/sigi/apps/servidores/views.py +++ b/sigi/apps/servidores/views.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- import new + +from django.db.models import Avg, Count, Max, Min +from django.shortcuts import get_object_or_404, redirect, render_to_response from django.template import RequestContext -from django.shortcuts import render_to_response, get_object_or_404, redirect -from django.db.models import Avg, Max, Min, Count -from sigi.apps.servidores.models import Servidor, Funcao + +from sigi.apps.servidores.models import Funcao, Servidor from sigi.shortcuts import render_to_pdf diff --git a/sigi/apps/solicitacoes/apps.py b/sigi/apps/solicitacoes/apps.py index 9567689..c3df515 100644 --- a/sigi/apps/solicitacoes/apps.py +++ b/sigi/apps/solicitacoes/apps.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from django import apps from django.utils.translation import ugettext_lazy as _ diff --git a/sigi/apps/solicitacoes/forms.py b/sigi/apps/solicitacoes/forms.py index 781db4e..8c702f5 100644 --- a/sigi/apps/solicitacoes/forms.py +++ b/sigi/apps/solicitacoes/forms.py @@ -1,11 +1,15 @@ from __future__ import absolute_import -from django.db import transaction + +import json + +import requests from django import forms +from django.db import transaction from django.forms import ModelForm + from sigi.settings.prod import OSTICKET_API_KEY, OSTICKET_URL + from .models import Solicitacao -import json -import requests def open_osticket(solicitacao): diff --git a/sigi/apps/solicitacoes/models.py b/sigi/apps/solicitacoes/models.py index 534e618..379317b 100644 --- a/sigi/apps/solicitacoes/models.py +++ b/sigi/apps/solicitacoes/models.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from django.db import models from django.utils.translation import ugettext_lazy as _ -from sigi.apps.usuarios.models import Usuario from sigi.apps.servicos.models import TipoServico +from sigi.apps.usuarios.models import Usuario class Solicitacao(models.Model): diff --git a/sigi/apps/solicitacoes/urls.py b/sigi/apps/solicitacoes/urls.py index 910d397..289bbef 100644 --- a/sigi/apps/solicitacoes/urls.py +++ b/sigi/apps/solicitacoes/urls.py @@ -1,4 +1,5 @@ from __future__ import absolute_import + from django.conf.urls import include, url from sigi.apps.solicitacoes.views import SolicitacaoCrud diff --git a/sigi/apps/solicitacoes/views.py b/sigi/apps/solicitacoes/views.py index 95e65dc..dffe63b 100644 --- a/sigi/apps/solicitacoes/views.py +++ b/sigi/apps/solicitacoes/views.py @@ -1,11 +1,13 @@ from __future__ import absolute_import + import random from django.contrib.auth.mixins import LoginRequiredMixin from django.core.urlresolvers import reverse import sigi.apps.crud.base -from sigi.apps.crud.base import Crud, CrudCreateView, CrudListView, CrudCreateView, CrudUpdateView, CrudBaseMixin +from sigi.apps.crud.base import (Crud, CrudBaseMixin, CrudCreateView, + CrudListView, CrudUpdateView) from sigi.apps.usuarios.models import Usuario from .forms import SolicitacaoForm diff --git a/sigi/apps/usuarios/apps.py b/sigi/apps/usuarios/apps.py index d1851f6..212178d 100644 --- a/sigi/apps/usuarios/apps.py +++ b/sigi/apps/usuarios/apps.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from django import apps from django.utils.translation import ugettext_lazy as _ diff --git a/sigi/apps/usuarios/forms.py b/sigi/apps/usuarios/forms.py index 0cde164..0261cb5 100644 --- a/sigi/apps/usuarios/forms.py +++ b/sigi/apps/usuarios/forms.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from datetime import datetime from captcha.fields import CaptchaField @@ -14,12 +15,12 @@ from django.core.exceptions import ValidationError from django.db import transaction from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ -from sigi.apps.casas.models import CasaLegislativa from easy_select2 import Select2 import sigi.apps.crispy_layout_mixin -from sigi.apps.crud.utils import YES_NO_CHOICES +from sigi.apps.casas.models import CasaLegislativa from sigi.apps.crispy_layout_mixin import form_actions +from sigi.apps.crud.utils import YES_NO_CHOICES from .models import Telefone, Usuario diff --git a/sigi/apps/usuarios/models.py b/sigi/apps/usuarios/models.py index b7efa7c..639a5de 100644 --- a/sigi/apps/usuarios/models.py +++ b/sigi/apps/usuarios/models.py @@ -1,12 +1,15 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + import base64 + from django.contrib.auth.models import User from django.db import models from django.utils import timezone from django.utils.translation import ugettext_lazy as _ -from sigi.apps.utils import SearchField + from sigi.apps.crud.utils import UF, YES_NO_CHOICES +from sigi.apps.utils import SearchField class Subsecretaria(models.Model): diff --git a/sigi/apps/usuarios/urls.py b/sigi/apps/usuarios/urls.py index ecdca95..5e4497a 100644 --- a/sigi/apps/usuarios/urls.py +++ b/sigi/apps/usuarios/urls.py @@ -1,16 +1,18 @@ from __future__ import absolute_import + from django.conf.urls import include, url from django.contrib.auth.views import (login, logout, password_reset, - password_reset_done, + password_reset_complete, password_reset_confirm, - password_reset_complete) -from sigi.apps.usuarios.forms import (LoginForm, RecuperarSenhaEmailForm, - RecuperacaoMudarSenhaForm) -from sigi.apps.usuarios.views import (HabilitarDetailView, HabilitarEditView, - MudarSenhaView, UsuarioCrud, - ConfirmarEmailView) + password_reset_done) from django.views.generic.base import TemplateView +from sigi.apps.usuarios.forms import (LoginForm, RecuperacaoMudarSenhaForm, + RecuperarSenhaEmailForm) +from sigi.apps.usuarios.views import (ConfirmarEmailView, HabilitarDetailView, + HabilitarEditView, MudarSenhaView, + UsuarioCrud) + from .apps import AppConfig app_name = AppConfig.name diff --git a/sigi/apps/usuarios/utils.py b/sigi/apps/usuarios/utils.py index 53bf2b2..bf7723e 100644 --- a/sigi/apps/usuarios/utils.py +++ b/sigi/apps/usuarios/utils.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from django.utils.translation import ugettext_lazy as _ UF = [ diff --git a/sigi/apps/usuarios/views.py b/sigi/apps/usuarios/views.py index ee3c869..49bfde9 100644 --- a/sigi/apps/usuarios/views.py +++ b/sigi/apps/usuarios/views.py @@ -1,25 +1,27 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import + from braces.views import FormValidMessageMixin from django.conf import settings +from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import LoginRequiredMixin +from django.contrib.auth.tokens import default_token_generator +from django.core.mail import send_mail from django.core.urlresolvers import reverse +from django.shortcuts import redirect from django.utils import timezone -from django.views.generic import DetailView, FormView, TemplateView -from django.core.mail import send_mail -from sigi.apps.crud.utils import str2bool -from django.contrib.auth.tokens import default_token_generator -from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.utils.encoding import force_bytes +from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode +from django.views.generic import DetailView, FormView, TemplateView + from sigi.apps.crud.base import (Crud, CrudBaseMixin, CrudCreateView, - CrudListView, CrudUpdateView, CrudDetailView) + CrudDetailView, CrudListView, CrudUpdateView) +from sigi.apps.crud.utils import str2bool from .forms import (HabilitarEditForm, MudarSenhaForm, UsuarioEditForm, UsuarioForm) -from .models import Usuario, ConfirmaEmail, User -from django.contrib.auth.decorators import login_required -from django.shortcuts import redirect +from .models import ConfirmaEmail, User, Usuario class UsuarioCrud(Crud): diff --git a/sigi/apps/utils/decorators.py b/sigi/apps/utils/decorators.py index 85d6786..52715ec 100644 --- a/sigi/apps/utils/decorators.py +++ b/sigi/apps/utils/decorators.py @@ -11,14 +11,16 @@ obsoleto. """ import urlparse + +from django.conf import settings +from django.contrib.auth import REDIRECT_FIELD_NAME +from django.utils.decorators import available_attrs + try: from functools import wraps except ImportError: from django.utils.functional import wraps # Python 2.4 fallback. -from django.conf import settings -from django.contrib.auth import REDIRECT_FIELD_NAME -from django.utils.decorators import available_attrs def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): diff --git a/sigi/apps/utils/filters.py b/sigi/apps/utils/filters.py index 0551776..6c905dc 100644 --- a/sigi/apps/utils/filters.py +++ b/sigi/apps/utils/filters.py @@ -1,5 +1,6 @@ # coding: utf-8 import string + from django.contrib import admin diff --git a/sigi/apps/utils/moodle_ws_api.py b/sigi/apps/utils/moodle_ws_api.py index 1be0cc0..f1ac319 100644 --- a/sigi/apps/utils/moodle_ws_api.py +++ b/sigi/apps/utils/moodle_ws_api.py @@ -20,8 +20,10 @@ import json import urllib2 + from django.conf import settings + def get_courses(ids=[], sort_order='', *args, **kwargs): ''' Implements core_courses_get_courses function @param ids: list of course ids to retrieve, blank for all courses @@ -84,4 +86,4 @@ def get_courses(ids=[], sort_order='', *args, **kwargs): else: courses.sort(key=lambda x: x[sort_order]) - return courses \ No newline at end of file + return courses diff --git a/sigi/settings/base.py b/sigi/settings/base.py index 91c41d9..0f212d1 100644 --- a/sigi/settings/base.py +++ b/sigi/settings/base.py @@ -14,6 +14,7 @@ import os from os.path import dirname import django.conf.global_settings as DEFAULT_SETTINGS +from easy_thumbnails.conf import Settings as thumbnail_settings BASE_DIR = dirname(dirname(dirname(__file__))) @@ -152,7 +153,6 @@ LOGIN_URL = '/login/?next=' # Using pytest directly (without a test runner) TEST_RUNNER = None -from easy_thumbnails.conf import Settings as thumbnail_settings THUMBNAIL_PROCESSORS = ( 'image_cropping.thumbnail_processors.crop_corners', ) + thumbnail_settings.THUMBNAIL_PROCESSORS diff --git a/sigi/settings/test.py b/sigi/settings/test.py index d037147..094b710 100644 --- a/sigi/settings/test.py +++ b/sigi/settings/test.py @@ -1,6 +1,5 @@ from base import * - # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '0$ip1fb5xtq%a=)-k_4r^(#jn0t^@+*^kihkxkozg-mip7+w3+' diff --git a/sigi/test_cart.py b/sigi/test_cart.py index d9d7d53..dad8531 100644 --- a/sigi/test_cart.py +++ b/sigi/test_cart.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- import pytest -from sigi.apps.casas.test_casas import some_parliaments, parliaments_from_names -from sigi.apps.parlamentares.test_parlamentares import some_parliamentarians, parliamentarians_from_names +from sigi.apps.casas.test_casas import parliaments_from_names, some_parliaments +from sigi.apps.parlamentares.test_parlamentares import (parliamentarians_from_names, + some_parliamentarians) from sigi.testutils import pdf_text diff --git a/sigi/test_testutils.py b/sigi/test_testutils.py index 7b75ec4..d66c3de 100644 --- a/sigi/test_testutils.py +++ b/sigi/test_testutils.py @@ -2,7 +2,6 @@ from collections import namedtuple from sigi.testutils import SigiDataFixture - FieldStub = namedtuple('FieldStub', ['max_length']) diff --git a/sigi/testutils.py b/sigi/testutils.py index bae2f14..336ced1 100644 --- a/sigi/testutils.py +++ b/sigi/testutils.py @@ -3,7 +3,8 @@ from cStringIO import StringIO from itertools import product import pyPdf -from django_dynamic_fixture.fixture_algorithms.sequential_fixture import SequentialDataFixture +from django_dynamic_fixture.fixture_algorithms.sequential_fixture import \ + SequentialDataFixture def pdf_text(res): diff --git a/sigi/urls.py b/sigi/urls.py index b743cf0..cb29f9d 100644 --- a/sigi/urls.py +++ b/sigi/urls.py @@ -1,7 +1,7 @@ #-*- coding:utf-8 -*- from django.conf import settings -from django.conf.urls import patterns, include, url +from django.conf.urls import include, patterns, url from django.conf.urls.static import static from django.contrib import admin from django.views.generic.base import TemplateView diff --git a/sigi/wsgi.py b/sigi/wsgi.py index 2bfdfd1..0a17509 100644 --- a/sigi/wsgi.py +++ b/sigi/wsgi.py @@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/ """ import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sigi.settings") from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sigi.settings") + application = get_wsgi_application()