Commit 9d2873251fbb5ac5f73cced8ddd8c45f3c69a503
1 parent
a1bdf0d5
Exists in
master
crud de orgao concluido
Showing
6 changed files
with
36 additions
and
31 deletions
Show diff stats
wscacicneo/__init__.py
... | ... | @@ -42,9 +42,9 @@ def main(global_config, **settings): |
42 | 42 | config.add_route('orgao', 'orgao/cadastro') |
43 | 43 | config.add_route('post_orgao', 'post_orgao') |
44 | 44 | config.add_route('put_orgao', 'put_orgao') |
45 | - config.add_route('editorgao', 'editar/{orgao}') | |
45 | + config.add_route('editorgao', 'editar/{sigla}') | |
46 | 46 | config.add_route('listorgao', 'orgao/list') |
47 | - config.add_route('delete_orgao', 'delete_orgao') | |
47 | + config.add_route('delete_orgao', 'delete/{sigla}') | |
48 | 48 | # |
49 | 49 | |
50 | 50 | #Usuários | ... | ... |
wscacicneo/model/orgao.py
... | ... | @@ -196,13 +196,13 @@ class Orgao(orgao_base.metaclass): |
196 | 196 | |
197 | 197 | return result |
198 | 198 | |
199 | - def search_orgao(self, nm_orgao): | |
199 | + def search_orgao(self, sigla): | |
200 | 200 | """ |
201 | 201 | Busca registro completo do órgao pelo nome |
202 | 202 | :return: obj collection com os dados da base |
203 | 203 | """ |
204 | 204 | search = Search( |
205 | - literal="document->>'nome' = '"+nm_orgao+"'" | |
205 | + literal="document->>'sigla' = '"+sigla+"'" | |
206 | 206 | ) |
207 | 207 | results = self.documentrest.get_collection(search_obj=search) |
208 | 208 | ... | ... |
wscacicneo/templates/editarorgao.pt
... | ... | @@ -55,7 +55,7 @@ |
55 | 55 | <div class="form-group"> |
56 | 56 | <div class="col-lg-offset-2 col-lg-6"> |
57 | 57 | <button type="button" id="enviar" class="btn btn-sm" style="margin-left: 315px;" >Enviar</button> |
58 | - <input style="display:none;" id="url" value="${request.matchdict['orgao']}"> | |
58 | + <input style="display:none;" id="url" value="${request.matchdict['sigla']}"> | |
59 | 59 | <button type="button" id="limpar" class="btn btn-sm">Limpar</button> |
60 | 60 | </div> |
61 | 61 | </div> | ... | ... |
wscacicneo/templates/list_orgao.pt
... | ... | @@ -20,11 +20,12 @@ |
20 | 20 | <table cellpadding="0" cellspacing="0" border="0" id="data-table" width="100%"> |
21 | 21 | <thead> |
22 | 22 | <tr> |
23 | - <th>Rendering engine</th> | |
24 | - <th>Browser</th> | |
25 | - <th>Platform(s)</th> | |
26 | - <th>Engine version</th> | |
27 | - <th>CSS grade</th> | |
23 | + <th>Nome</th> | |
24 | + <th>Sigla</th> | |
25 | + <th>Coleta</th> | |
26 | + <th>Endereço</th> | |
27 | + <th>E-mail</th> | |
28 | + <th>Opções</th> | |
28 | 29 | </tr> |
29 | 30 | </thead> |
30 | 31 | <tbody> |
... | ... | @@ -34,6 +35,11 @@ |
34 | 35 | <td>${doc.coleta}</td> |
35 | 36 | <td>${doc.endereco}</td> |
36 | 37 | <td>${doc.email}</td> |
38 | + <td> | |
39 | + <a class="btn btn-xs btn-success"><i class="fa fa-check"></i></a> | |
40 | + <a href="${request.route_url('root')}editar/${doc.sigla}" class="btn btn-xs btn-warning"><i class="fa fa-pencil"></i></a> | |
41 | + <a href="${request.route_url('root')}delete/${doc.sigla}" class="btn btn-xs btn-danger"><i class="fa fa-times"></i></a> | |
42 | + </td> | |
37 | 43 | </tr> |
38 | 44 | </tbody> |
39 | 45 | </table> |
... | ... | @@ -52,8 +58,7 @@ |
52 | 58 | </metal:content> |
53 | 59 | <metal:content fill-slot="javascript"> |
54 | 60 | <script type="text/javascript"> |
55 | - $(document).ready(function(){ | |
56 | - }); | |
61 | + }); | |
57 | 62 | </script> |
58 | 63 | </metal:content> |
59 | 64 | </metal:main> | ... | ... |
wscacicneo/test/test_orgao_attributes.py
... | ... | @@ -50,8 +50,8 @@ class TestOrgaoBase(unittest.TestCase): |
50 | 50 | email='admin@planemaneto.gov.br', |
51 | 51 | telefone='(61) 2025-4117' |
52 | 52 | ) |
53 | - nm_orgao='Ministério do Planejameiaaaaaaaaanto' | |
54 | - search = orgao_obj.search_orgao(nm_orgao) | |
53 | + sigla='MPOG' | |
54 | + search = orgao_obj.search_orgao(sigla) | |
55 | 55 | id = search.results[0]._metadata.id_doc |
56 | 56 | delete = orgao_obj.delete_orgao(id) |
57 | 57 | |
... | ... | @@ -85,8 +85,8 @@ class TestOrgaoBase(unittest.TestCase): |
85 | 85 | 'email':'admin@planemaneto.gov.br', |
86 | 86 | 'telefone':'(61) 2025-4117' |
87 | 87 | }) |
88 | - nm_orgao='Ministério do Planejameiaaaaaaaaanto' | |
89 | - search = orgao_obj.search_orgao(nm_orgao) | |
88 | + sigla ='MPOG' | |
89 | + search = orgao_obj.search_orgao(sigla) | |
90 | 90 | id = search.results[0]._metadata.id_doc |
91 | 91 | doc = json.dumps(orgao) |
92 | 92 | edit = orgao_obj.edit_orgao(id, doc) | ... | ... |
wscacicneo/views.py
... | ... | @@ -158,17 +158,17 @@ def configapi(request): |
158 | 158 | |
159 | 159 | @view_config(route_name='editorgao', renderer='templates/editarorgao.pt') |
160 | 160 | def editorgao(request): |
161 | - nm_orgao = request.matchdict['orgao'] | |
161 | + sigla = request.matchdict['sigla'] | |
162 | 162 | orgao_obj = Orgao( |
163 | - nome = nm_orgao, | |
163 | + nome = 'asdsad', | |
164 | 164 | cargo = 'cargo', |
165 | 165 | coleta = '4h', |
166 | - sigla = 'MPOG', | |
166 | + sigla = sigla, | |
167 | 167 | endereco = 'Esplanada bloco C', |
168 | 168 | email = 'admin@planemaneto.gov.br', |
169 | 169 | telefone = '(61) 2025-4117' |
170 | 170 | ) |
171 | - search = orgao_obj.search_orgao(nm_orgao) | |
171 | + search = orgao_obj.search_orgao(sigla) | |
172 | 172 | return { |
173 | 173 | 'nome' : search.results[0].nome, |
174 | 174 | 'cargo' : search.results[0].cargo, |
... | ... | @@ -249,7 +249,7 @@ def put_orgao(request): |
249 | 249 | email = doc['email'], |
250 | 250 | telefone = doc['telefone'] |
251 | 251 | ) |
252 | - search = orgao_obj.search_orgao(nm_orgao) | |
252 | + search = orgao_obj.search_orgao(sigla) | |
253 | 253 | id = search.results[0]._metadata.id_doc |
254 | 254 | edit = Orgao.edit_orgao(id, doc) |
255 | 255 | |
... | ... | @@ -261,21 +261,21 @@ def delete_orgao(request): |
261 | 261 | Deleta doc apartir do id |
262 | 262 | """ |
263 | 263 | doc = request.params |
264 | - nm_orgao = doc['nome'] | |
264 | + sigla = request.matchdict['sigla'] | |
265 | 265 | orgao_obj = Orgao( |
266 | - nome = doc['nome'], | |
267 | - cargo = doc['gestor'], | |
268 | - coleta = doc['coleta'], | |
269 | - sigla = doc['sigla'], | |
270 | - endereco = doc['end'], | |
271 | - email = doc['email'], | |
272 | - telefone = doc['telefone'] | |
266 | + nome = 'asdasd', | |
267 | + cargo = 'asdasdasd', | |
268 | + coleta = 'asdasdasd', | |
269 | + sigla = 'asdasdas', | |
270 | + endereco = 'asdsad', | |
271 | + email = 'asdsad', | |
272 | + telefone = 'sadasd' | |
273 | 273 | ) |
274 | - search = orgao_obj.search_orgao(nm_orgao) | |
274 | + search = orgao_obj.search_orgao(sigla) | |
275 | 275 | id = search.results[0]._metadata.id_doc |
276 | 276 | delete = orgao_obj.delete_orgao(id) |
277 | 277 | |
278 | - return Response(str(delete)) | |
278 | + return Response(delete) | |
279 | 279 | |
280 | 280 | #URL Users |
281 | 281 | ... | ... |