From 13086b70659f328c64eec8b699a8532092d287bc Mon Sep 17 00:00:00 2001 From: adleywd Date: Tue, 2 Sep 2014 10:40:51 -0300 Subject: [PATCH] criação do editar orgão --- wscacicneo/__init__.py | 5 +++-- wscacicneo/model/user.py | 4 ++-- wscacicneo/templates/editaruser.pt | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ wscacicneo/templates/menu.pt | 8 +++++++- wscacicneo/templates/user.pt | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- wscacicneo/templates/userbk.pt | 19 +++++++++++++++++++ wscacicneo/test/results.txt | 2 +- wscacicneo/views.py | 29 +++++++++++++++++++++++++++-- 8 files changed, 267 insertions(+), 27 deletions(-) create mode 100644 wscacicneo/templates/editaruser.pt create mode 100644 wscacicneo/templates/userbk.pt diff --git a/wscacicneo/__init__.py b/wscacicneo/__init__.py index 82c08c2..caeee6a 100644 --- a/wscacicneo/__init__.py +++ b/wscacicneo/__init__.py @@ -42,14 +42,15 @@ def main(global_config, **settings): config.add_route('orgao', 'orgao/cadastro') config.add_route('post_orgao', 'post_orgao') config.add_route('put_orgao', 'put_orgao') - config.add_route('editorgao', 'editar/{sigla}') + config.add_route('editorgao', 'editar/orgao/{sigla}') config.add_route('listorgao', 'orgao/list') config.add_route('delete_orgao', 'delete/{sigla}') # #Usuários - config.add_route('users', 'users') + config.add_route('user', 'user/cadastro') config.add_route('post_user', 'post_user') + config.add_route('edituser', 'editar/user/{matricula}') # config.add_route('list', 'list') diff --git a/wscacicneo/model/user.py b/wscacicneo/model/user.py index 9b4e79f..fb08aff 100644 --- a/wscacicneo/model/user.py +++ b/wscacicneo/model/user.py @@ -208,13 +208,13 @@ class User(user_base.metaclass): return result - def search_user(self, matricula_user): + def search_user(self, matricula): """ Busca registro completo do usuário pela matricula :return: obj collection com os dados da base """ search = Search( - literal="document->>'matricula' = '"+matricula_user+"'" + literal="document->>'matricula' = '"+matricula+"'" ) results = self.documentrest.get_collection(search_obj=search) diff --git a/wscacicneo/templates/editaruser.pt b/wscacicneo/templates/editaruser.pt new file mode 100644 index 0000000..837906a --- /dev/null +++ b/wscacicneo/templates/editaruser.pt @@ -0,0 +1,104 @@ + + +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+
+
+ + + +
diff --git a/wscacicneo/templates/menu.pt b/wscacicneo/templates/menu.pt index c90809c..6982b74 100644 --- a/wscacicneo/templates/menu.pt +++ b/wscacicneo/templates/menu.pt @@ -7,7 +7,13 @@
  • Orgão +
  • + Usuário +
  • diff --git a/wscacicneo/templates/user.pt b/wscacicneo/templates/user.pt index 7e988c3..4dd87cc 100644 --- a/wscacicneo/templates/user.pt +++ b/wscacicneo/templates/user.pt @@ -1,19 +1,104 @@ - - - Login - - - -
    - - + + +
    +
    + +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + + + +
    diff --git a/wscacicneo/templates/userbk.pt b/wscacicneo/templates/userbk.pt new file mode 100644 index 0000000..7e988c3 --- /dev/null +++ b/wscacicneo/templates/userbk.pt @@ -0,0 +1,19 @@ + + + Login + + + +
    + + diff --git a/wscacicneo/test/results.txt b/wscacicneo/test/results.txt index 25bf17f..8fdd954 100644 --- a/wscacicneo/test/results.txt +++ b/wscacicneo/test/results.txt @@ -1 +1 @@ -18 \ No newline at end of file +22 \ No newline at end of file diff --git a/wscacicneo/views.py b/wscacicneo/views.py index eec5dbc..751a5d4 100644 --- a/wscacicneo/views.py +++ b/wscacicneo/views.py @@ -72,8 +72,8 @@ def admin(request): def diagnostic(request): return {'project': 'WSCacicNeo'} -@view_config(route_name='users', renderer='templates/users.pt') -def users(request): +@view_config(route_name='user', renderer='templates/user.pt') +def user(request): return {'project': 'WSCacicNeo'} @view_config(route_name='cadastro', renderer='templates/cadastro.pt') @@ -302,3 +302,28 @@ def post_user(request): print(id_doc) return Response(str(id_doc)) + +@view_config(route_name='edituser', renderer='templates/editaruser.pt') +def edituser(request): + matricula = request.matchdict['matricula'] + user_obj = User( + nome = 'base', + matricula = matricula, + email = 'base@gov.br', + orgao = 'orgao', + telefone = 'telefone', + cargo = 'cargo', + setor = 'setor', + permissao = 'Gestor' + ) + search = user_obj.search_user(matricula) + return { + 'nome' : search.results[0].nome, + 'matricula' : search.results[0].matricula, + 'email' : search.results[0].email, + 'orgao' : search.results[0].orgao, + 'telefone' : search.results[0].telefone, + 'cargo' : search.results[0].cargo, + 'setor' : search.results[0].setor, + 'permissao' : search.results[0].permissao + } \ No newline at end of file -- libgit2 0.21.2