Commit e90f3f9acdcad2c285809becd0c8354ee9d5adc9

Authored by Adley
1 parent 7b46b522
Exists in master

Formatação do nome do orgão para ser inserido na base de dados

wscacicneo/templates/master.pt
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 <metal:content define-slot="css"/> 7 <metal:content define-slot="css"/>
8 </metal:content> 8 </metal:content>
9 9
  10 +
10 11
11 <!-- Conteúdo da Página --> 12 <!-- Conteúdo da Página -->
12 <metal:content fill-slot="conteudo"> 13 <metal:content fill-slot="conteudo">
@@ -96,7 +97,12 @@ @@ -96,7 +97,12 @@
96 97
97 <!-- Page heading --> 98 <!-- Page heading -->
98 <div class="page-head"> 99 <div class="page-head">
99 - <h2 class="pull-left"><i class="fa fa-home"></i> Você está em: ${request.path}</h2> 100 + <h2 class="pull-left">
  101 + <i class="fa fa-home"></i>&nbsp;
  102 + </h2>
  103 + <h2 class="pull-left" id="dashlocation">
  104 + Você está em: ${request.path}
  105 + </h2>
100 106
101 107
102 <div class="clearfix"></div> 108 <div class="clearfix"></div>
@@ -124,5 +130,14 @@ @@ -124,5 +130,14 @@
124 <!-- Footer ends --> 130 <!-- Footer ends -->
125 131
126 </metal:content> 132 </metal:content>
  133 + <metal:content fill-slot="javascript">
  134 + <script type="text/javascript">
  135 + $( document ).ready(function() {
  136 + var string = $('#dashlocation').text().replace("/wscacicneo/", "");
  137 + $('#dashlocation').text(string);
  138 + });
  139 + </script>
  140 + <metal:content define-slot="javascript"/>
  141 + </metal:content>
127 142
128 </metal:main> 143 </metal:main>
wscacicneo/utils/utils.py
1 import requests 1 import requests
2 import json 2 import json
  3 +import unicodedata
3 from wscacicneo.model.orgao import Orgao 4 from wscacicneo.model.orgao import Orgao
4 from wscacicneo.model.orgao import OrgaoBase 5 from wscacicneo.model.orgao import OrgaoBase
5 6
@@ -12,9 +13,15 @@ class Utils: @@ -12,9 +13,15 @@ class Utils:
12 def to_url(*args): 13 def to_url(*args):
13 return '/'.join(list(args)) 14 return '/'.join(list(args))
14 15
  16 + # Retorna verdadeiro para um email passado no qual contenha um e-mail institucional
  17 + # no caso, quando o e-mail tiver gov.br
15 def verifica_email_institucional(email): 18 def verifica_email_institucional(email):
16 if("gov.br" in email): 19 if("gov.br" in email):
17 return True 20 return True
18 else: 21 else:
19 return False 22 return False
20 23
  24 + # Retorna uma string sem caracteres especiais(sem espaço e acentos).
  25 + def format_name(data):
  26 + return ''.join(x for x in unicodedata.normalize('NFKD', data) if \
  27 + unicodedata.category(x)[0] == 'L').lower()
21 \ No newline at end of file 28 \ No newline at end of file
wscacicneo/views.py
@@ -89,7 +89,7 @@ def post_notify(request): @@ -89,7 +89,7 @@ def post_notify(request):
89 def orgao(request): 89 def orgao(request):
90 return {'project': 'WSCacicNeo'} 90 return {'project': 'WSCacicNeo'}
91 91
92 -@view_config(route_name='listorgao', renderer='templates/list_orgao.pt', permission="user") 92 +@view_config(route_name='listorgao', renderer='templates/list_orgao.pt', permission="admin")
93 def listorgao(request): 93 def listorgao(request):
94 orgao_obj = Orgao( 94 orgao_obj = Orgao(
95 nome = 'sahuds', 95 nome = 'sahuds',
@@ -282,7 +282,7 @@ def edit_favoritos(request): @@ -282,7 +282,7 @@ def edit_favoritos(request):
282 # Reports 282 # Reports
283 @view_config(route_name='create_orgao',permission="admin") 283 @view_config(route_name='create_orgao',permission="admin")
284 def create_base(request): 284 def create_base(request):
285 - nm_orgao = request.matchdict['nm_orgao'] 285 + nm_orgao = Utils.format_name(request.matchdict['nm_orgao'])
286 coletaManualBase = coleta_manual.ColetaManualBase(nm_orgao) 286 coletaManualBase = coleta_manual.ColetaManualBase(nm_orgao)
287 lbbase = coletaManualBase.lbbase 287 lbbase = coletaManualBase.lbbase
288 retorno = coletaManualBase.create_base() 288 retorno = coletaManualBase.create_base()
@@ -306,7 +306,7 @@ def conf_report(request): @@ -306,7 +306,7 @@ def conf_report(request):
306 306
307 @view_config(route_name='report_itens', renderer='templates/report.pt', permission="admin") 307 @view_config(route_name='report_itens', renderer='templates/report.pt', permission="admin")
308 def report_itens(request): 308 def report_itens(request):
309 - nm_orgao = request.matchdict['nm_orgao'] 309 + nm_orgao = Utils.format_name(request.matchdict['nm_orgao'])
310 attr = request.matchdict['attr'] 310 attr = request.matchdict['attr']
311 child = request.matchdict['child'] 311 child = request.matchdict['child']
312 data = Reports(nm_orgao).count_attribute(attr, child) 312 data = Reports(nm_orgao).count_attribute(attr, child)