Commit cd02128cf76332bc275d33aef87fad64bf1ee1da

Authored by Macieski
1 parent 82f75dde
Exists in master

configurações das coletas

wscacicneo/__init__.py
@@ -54,6 +54,13 @@ def main(global_config, **settings): @@ -54,6 +54,13 @@ def main(global_config, **settings):
54 cfg.add_route('post_notify', 'post_notify') 54 cfg.add_route('post_notify', 'post_notify')
55 cfg.add_route('list_notify', 'notificacoes/lista') 55 cfg.add_route('list_notify', 'notificacoes/lista')
56 # 56 #
  57 + # base orgaos
  58 + cfg.add_route('create_orgao', 'create/orgao/{nm_orgao}')
  59 + #
  60 + # relatorios
  61 + cfg.add_route('conf_report', 'relatorios/configuracao')
  62 + cfg.add_route('report_hd', 'relatorio/{orgao}/{item}')
  63 + #
57 cfg.add_route('list', 'list') 64 cfg.add_route('list', 'list')
58 cfg.add_route('gestao', 'gestao') 65 cfg.add_route('gestao', 'gestao')
59 cfg.add_route('memoria', 'memoria') 66 cfg.add_route('memoria', 'memoria')
wscacicneo/model/coleta_manual.py
@@ -20,10 +20,11 @@ class ColetaManualBase(): @@ -20,10 +20,11 @@ class ColetaManualBase():
20 """ 20 """
21 Classe para a base de usuários 21 Classe para a base de usuários
22 """ 22 """
23 - def __init__(self, rest_url=None): 23 + def __init__(self, nm_base, rest_url=None):
24 """ 24 """
25 Método construtor 25 Método construtor
26 """ 26 """
  27 + self.nm_base = nm_base
27 if rest_url is None: 28 if rest_url is None:
28 self.rest_url = config.REST_URL 29 self.rest_url = config.REST_URL
29 else: 30 else:
@@ -292,7 +293,7 @@ class ColetaManualBase(): @@ -292,7 +293,7 @@ class ColetaManualBase():
292 ) 293 )
293 294
294 base_metadata = BaseMetadata( 295 base_metadata = BaseMetadata(
295 - name='coleta_manual', 296 + name = self.nm_base,
296 ) 297 )
297 298
298 content_list = Content() 299 content_list = Content()
@@ -336,4 +337,4 @@ class ColetaManualBase(): @@ -336,4 +337,4 @@ class ColetaManualBase():
336 if response.status_code == 200: 337 if response.status_code == 200:
337 return True 338 return True
338 else: 339 else:
339 - raise IOError('Error excluding base from LB')  
340 \ No newline at end of file 340 \ No newline at end of file
  341 + raise IOError('Error excluding base from LB')
wscacicneo/templates/conf_report.pt 0 → 100644
@@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
  1 +<metal:main use-macro="load: master.pt">
  2 + <metal:content fill-slot="conteudo">
  3 + <div class="padd">
  4 + <br />
  5 + <!-- Form starts. -->
  6 + <form class="form-horizontal" role="form">
  7 + <div class="form-group">
  8 + <label class="col-lg-2 control-label">Órgão</label>
  9 + <div class="col-lg-2">
  10 + <select id="orgao" class="form-control">
  11 + <option></option>
  12 + <option tal:repeat="doc orgao_doc">${doc.sigla}</option>
  13 + </select>
  14 + </div>
  15 + </div>
  16 + <div class="form-group">
  17 + <label class="col-lg-2 control-label">Item</label>
  18 + <div class="col-lg-2">
  19 + <select id="coleta" class="form-control">
  20 + <option></option>
  21 + <option>processador</option>
  22 + <option>hd</option>
  23 + <option>bios</option>
  24 + <option>memoria</option>
  25 + <option>Sistemas Operacionais</option>
  26 + </select>
  27 + </div>
  28 + </div>
  29 + <div class="form-group">
  30 + <div class="col-lg-offset-2 col-lg-6">
  31 + <button type="button" id="enviar" class="btn btn-sm" style="margin-left: 315px;" >Enviar</button>
  32 + </div>
  33 + </div>
  34 + </form>
  35 + </div>
  36 + </metal:content>
  37 + <metal:content fill-slot="javascript">
  38 + <script type="text/javascript">
  39 + $('#enviar').click(function(){
  40 + window.location = "${request.route_url('root')}home"
  41 + });
  42 + </script>
  43 + </metal:content>
  44 +</metal:main>
wscacicneo/templates/list_orgao.pt
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 <td>${doc.endereco}</td> 36 <td>${doc.endereco}</td>
37 <td>${doc.email}</td> 37 <td>${doc.email}</td>
38 <td> 38 <td>
39 - <a class="btn btn-xs btn-success"><i class="fa fa-check"></i></a> 39 + <a href="${request.route_url('root')}create/orgao/${doc.nome}" class="btn btn-xs btn-success" id="create"><i class="fa fa-check"></i></a>
40 <a href="${request.route_url('root')}orgao/editar/${doc.sigla}" class="btn btn-xs btn-warning"><i class="fa fa-pencil"></i></a> 40 <a href="${request.route_url('root')}orgao/editar/${doc.sigla}" class="btn btn-xs btn-warning"><i class="fa fa-pencil"></i></a>
41 <a href="${request.route_url('root')}orgao/delete/${doc.sigla}" class="btn btn-xs btn-danger"><i class="fa fa-times"></i></a> 41 <a href="${request.route_url('root')}orgao/delete/${doc.sigla}" class="btn btn-xs btn-danger"><i class="fa fa-times"></i></a>
42 </td> 42 </td>
wscacicneo/templates/report.pt 0 → 100644
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
  1 +<metal:main use-macro="load: master.pt">
  2 + <metal:content fill-slot="conteudo">
  3 + </metal:content>
  4 + <metal:content fill-slot="javascript">
  5 + <script type="text/javascript">
  6 + </script>
  7 + </metal:content>
  8 +</metal:main>
wscacicneo/test/test_coleta_manual_base.py
@@ -28,4 +28,4 @@ class TestColetaManualBase(unittest.TestCase): @@ -28,4 +28,4 @@ class TestColetaManualBase(unittest.TestCase):
28 self.assertIsInstance(retorno, Base) 28 self.assertIsInstance(retorno, Base)
29 29
30 def tearDown(self): 30 def tearDown(self):
31 - pass  
32 \ No newline at end of file 31 \ No newline at end of file
  32 + pass
wscacicneo/utils/utils.py
1 import requests 1 import requests
2 import json 2 import json
  3 +from wscacicneo.model.orgao import Orgao
  4 +from wscacicneo.model.orgao import OrgaoBase
  5 +
3 6
4 class Utils: 7 class Utils:
5 8
wscacicneo/views.py
@@ -16,6 +16,7 @@ from wscacicneo.model.user import User @@ -16,6 +16,7 @@ from wscacicneo.model.user import User
16 from wscacicneo.model.user import UserBase 16 from wscacicneo.model.user import UserBase
17 from wscacicneo.model.notify import Notify 17 from wscacicneo.model.notify import Notify
18 from wscacicneo.model.notify import NotifyBase 18 from wscacicneo.model.notify import NotifyBase
  19 +from wscacicneo.model import coleta_manual
19 20
20 from liblightbase.lbbase.struct import Base 21 from liblightbase.lbbase.struct import Base
21 from liblightbase.lbutils import conv 22 from liblightbase.lbutils import conv
@@ -209,7 +210,33 @@ def confighome(request): @@ -209,7 +210,33 @@ def confighome(request):
209 def db(request): 210 def db(request):
210 return {'project': 'WSCacicNeo'} 211 return {'project': 'WSCacicNeo'}
211 212
212 -#URL Órgaos 213 +@view_config(route_name='create_orgao')
  214 +def create_base(request):
  215 + nm_orgao = request.matchdict['nm_orgao']
  216 + coletaManualBase = coleta_manual.ColetaManualBase(nm_orgao)
  217 + lbbase = coletaManualBase.lbbase
  218 + retorno = coletaManualBase.create_base()
  219 +
  220 + return HTTPFound(request.route_url('root') + 'orgao/lista')
  221 +
  222 +@view_config(route_name='conf_report', renderer='templates/conf_report.pt')
  223 +def conf_report(request):
  224 + orgao_obj = Orgao(
  225 + nome = 'sahuds',
  226 + cargo = 'cargo',
  227 + coleta = '4h',
  228 + sigla = 'MPOG',
  229 + endereco = 'Esplanada bloco C',
  230 + email = 'admin@planemaneto.gov.br',
  231 + telefone = '(61) 2025-4117',
  232 + url = 'http://api.brlight.net/api'
  233 + )
  234 + search = orgao_obj.search_list_orgaos()
  235 + return {'orgao_doc': search.results}
  236 +
  237 +@view_config(route_name='report_hd', renderer='templates/report.pt')
  238 +def report_hd(request):
  239 + return { }
213 240
214 @view_config(route_name='post_orgao') 241 @view_config(route_name='post_orgao')
215 def post_orgao(request): 242 def post_orgao(request):