Esempio n. 1
0
 def update_user(self):
     contract = UpdateUserContract()
     playload = request.json
     if not (contract.validate(playload)):
         return ResultModel('Envie todos parametros obrigatorios.', False,
                            contract.errors).to_dict(), 406
     repository = UserRepository()
     user = repository.update(playload.get('id'), playload.get('username'),
                              playload.get('password'),
                              playload.get('is_admin'))
     return user
Esempio n. 2
0
 def update_user(self):
     contract = UpdateUserContract()
     playload = request.json
     if not (contract.validate(playload)):
         return ResultModel('Envie todos parametros obrigatorios.', False,
                            contract.errors).to_dict(), 406
     if playload.get('is_admin') and not Admin().is_admin():
         return ResultModel(
             'Só um administrador pode editar outro administrador.', False,
             contract.errors).to_dict(), 406
     repository = UserRepository()
     user = repository.update(playload.get('id'), playload.get('username'),
                              playload.get('password'),
                              playload.get('is_admin'))
     status_result = SetStatusResponseHandler()
     return status_result.default(user)