예제 #1
0
파일: employees.py 프로젝트: yehiaa/clinic
    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)
예제 #2
0
파일: users.py 프로젝트: yehiaa/clinic
    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)