Commit 17faee8d54bd5f1e2f3f9df2041125f36c816747
1 parent
0dda9506
Exists in
master
favoritos concluido
Showing
4 changed files
with
70 additions
and
8 deletions
Show diff stats
wscacicneo/model/user.py
wscacicneo/templates/favoritos.pt
... | ... | @@ -71,15 +71,49 @@ |
71 | 71 | 'permissao' : '$permissao', |
72 | 72 | 'senha' : '${senha}' |
73 | 73 | } |
74 | - json = JSON.stringify({'documento': data}) | |
74 | + json = JSON.stringify(data) | |
75 | 75 | $.ajax({ |
76 | 76 | type: "PUT", |
77 | 77 | url: "${request.route_url('root')}edit_favoritos", |
78 | - data: json, | |
78 | + data: {'documento': json}, | |
79 | 79 | success: function(){ location.reload(); }, |
80 | 80 | error: function(){ alert('Não foi desta vez Tente novamente mais tarde') }, |
81 | 81 | }); |
82 | 82 | }); |
83 | + $('#favoritos li').on('click', function(){ | |
84 | + index = $(this).index() | |
85 | + a = $(this).find('a') | |
86 | + value = $(a).html() | |
87 | + favoritos = ${favoritos} | |
88 | + favoritos.splice(index, 1) | |
89 | + itens = ${itens} | |
90 | + matricola = $('#url').val() | |
91 | + itens.push(value) | |
92 | + var data = { | |
93 | + 'matricola': matricola, | |
94 | + 'index': index, | |
95 | + 'favoritos': favoritos, | |
96 | + 'itens': itens, | |
97 | + 'nome' : '${nome}', | |
98 | + 'matricula' : '${matricula}', | |
99 | + 'email' : '${email}', | |
100 | + 'orgao' : '${orgao}', | |
101 | + 'telefone' : '${telefone}', | |
102 | + 'cargo' : '${cargo}', | |
103 | + 'setor' : '${setor}', | |
104 | + 'permissao' : '$permissao', | |
105 | + 'senha' : '${senha}' | |
106 | + } | |
107 | + json = JSON.stringify(data) | |
108 | + $.ajax({ | |
109 | + type: "PUT", | |
110 | + url: "${request.route_url('root')}edit_favoritos", | |
111 | + data: {'documento': json}, | |
112 | + success: function(){ location.reload(); }, | |
113 | + error: function(){ alert('Não foi desta vez Tente novamente mais tarde') }, | |
114 | + }); | |
115 | + }); | |
116 | + | |
83 | 117 | </script> |
84 | 118 | </metal:content> |
85 | 119 | </metal:main> | ... | ... |
wscacicneo/templates/user.pt
wscacicneo/views.py
... | ... | @@ -465,7 +465,36 @@ def edit_favoritos(request): |
465 | 465 | """ |
466 | 466 | Editar do Favoritos |
467 | 467 | """ |
468 | - request = request.params | |
469 | - json = json.dumps(request) | |
470 | - print(json) | |
471 | - return { } | |
468 | + documento = json.loads(request.params['documento']) | |
469 | + matricula = documento['matricola'] | |
470 | + user_obj = User( | |
471 | + nome = documento['nome'], | |
472 | + matricula = documento['matricula'], | |
473 | + email = documento['email'], | |
474 | + orgao = documento['orgao'], | |
475 | + telefone = documento['telefone'], | |
476 | + cargo = documento['cargo'], | |
477 | + setor = documento['setor'], | |
478 | + permissao = documento['permissao'], | |
479 | + senha = documento['senha'] | |
480 | + ) | |
481 | + user = { | |
482 | + 'nome' : documento['nome'], | |
483 | + 'matricula' : documento['matricula'], | |
484 | + 'email' : documento['email'], | |
485 | + 'orgao' : documento['orgao'], | |
486 | + 'telefone' : documento['telefone'], | |
487 | + 'cargo' : documento['cargo'], | |
488 | + 'setor' : documento['setor'], | |
489 | + 'permissao' : documento['permissao'], | |
490 | + 'senha' : documento['senha'], | |
491 | + 'itens': documento['itens'], | |
492 | + 'favoritos': documento['favoritos'] | |
493 | + } | |
494 | + search = user_obj.search_user(matricula) | |
495 | + id = search.results[0]._metadata.id_doc | |
496 | + doc = json.dumps(user) | |
497 | + edit = user_obj.edit_user(id, doc) | |
498 | + | |
499 | + return Response(edit) | |
500 | + | ... | ... |