Exemplo n.º 1
0
    def put(self, id):
        entity = employeeRepo.get(id)
        if entity is None:
            return notFoundResponse()

        form = EditUserForm(obj=entity)

        if form.validate():
            form.populate_obj(entity)

            employeeRepo.save(entity)
            return successResponse()

        return unableToProcessResponse(form.errors)
Exemplo n.º 2
0
    def put(self, id):
        entity = userRepo.get(id)
        if entity is None:
            return notFoundResponse()

        if not isSuperUser():
            return notAuthorizedResponse()

        form = EditUserForm(obj=entity)

        if form.validate():

            entity.name = form.name.data
            entity.userName = form.userName.data
            entity.active = form.active.data
            entity.allowLogin = form.allowLogin.data

            if form.password.data:
                entity.setPassword(form.password.data)

            userRepo.save(entity)
            return successResponse()

        return unableToProcessResponse(form.errors)