Commit e90f3f9acdcad2c285809becd0c8354ee9d5adc9
1 parent
7b46b522
Exists in
master
Formatação do nome do orgão para ser inserido na base de dados
Showing
3 changed files
with
26 additions
and
4 deletions
Show diff stats
wscacicneo/templates/master.pt
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | <metal:content define-slot="css"/> |
| 8 | 8 | </metal:content> |
| 9 | 9 | |
| 10 | + | |
| 10 | 11 | |
| 11 | 12 | <!-- Conteúdo da Página --> |
| 12 | 13 | <metal:content fill-slot="conteudo"> |
| ... | ... | @@ -96,7 +97,12 @@ |
| 96 | 97 | |
| 97 | 98 | <!-- Page heading --> |
| 98 | 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> | |
| 102 | + </h2> | |
| 103 | + <h2 class="pull-left" id="dashlocation"> | |
| 104 | + Você está em: ${request.path} | |
| 105 | + </h2> | |
| 100 | 106 | |
| 101 | 107 | |
| 102 | 108 | <div class="clearfix"></div> |
| ... | ... | @@ -124,5 +130,14 @@ |
| 124 | 130 | <!-- Footer ends --> |
| 125 | 131 | |
| 126 | 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 | 143 | </metal:main> | ... | ... |
wscacicneo/utils/utils.py
| 1 | 1 | import requests |
| 2 | 2 | import json |
| 3 | +import unicodedata | |
| 3 | 4 | from wscacicneo.model.orgao import Orgao |
| 4 | 5 | from wscacicneo.model.orgao import OrgaoBase |
| 5 | 6 | |
| ... | ... | @@ -12,9 +13,15 @@ class Utils: |
| 12 | 13 | def to_url(*args): |
| 13 | 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 | 18 | def verifica_email_institucional(email): |
| 16 | 19 | if("gov.br" in email): |
| 17 | 20 | return True |
| 18 | 21 | else: |
| 19 | 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 | 28 | \ No newline at end of file | ... | ... |
wscacicneo/views.py
| ... | ... | @@ -89,7 +89,7 @@ def post_notify(request): |
| 89 | 89 | def orgao(request): |
| 90 | 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 | 93 | def listorgao(request): |
| 94 | 94 | orgao_obj = Orgao( |
| 95 | 95 | nome = 'sahuds', |
| ... | ... | @@ -282,7 +282,7 @@ def edit_favoritos(request): |
| 282 | 282 | # Reports |
| 283 | 283 | @view_config(route_name='create_orgao',permission="admin") |
| 284 | 284 | def create_base(request): |
| 285 | - nm_orgao = request.matchdict['nm_orgao'] | |
| 285 | + nm_orgao = Utils.format_name(request.matchdict['nm_orgao']) | |
| 286 | 286 | coletaManualBase = coleta_manual.ColetaManualBase(nm_orgao) |
| 287 | 287 | lbbase = coletaManualBase.lbbase |
| 288 | 288 | retorno = coletaManualBase.create_base() |
| ... | ... | @@ -306,7 +306,7 @@ def conf_report(request): |
| 306 | 306 | |
| 307 | 307 | @view_config(route_name='report_itens', renderer='templates/report.pt', permission="admin") |
| 308 | 308 | def report_itens(request): |
| 309 | - nm_orgao = request.matchdict['nm_orgao'] | |
| 309 | + nm_orgao = Utils.format_name(request.matchdict['nm_orgao']) | |
| 310 | 310 | attr = request.matchdict['attr'] |
| 311 | 311 | child = request.matchdict['child'] |
| 312 | 312 | data = Reports(nm_orgao).count_attribute(attr, child) | ... | ... |