def form_content(self): user = self.context.user props = get_properties(user.uri) return {'name': user.name, 'login': user.login, 'password': '', 'validated': props.validated, 'suspended': props.suspended}
def modify(self): data, errors = self.extract() if errors: self.message(errors, 'form-error') return user = self.context.user user.name = data['name'] user.login = data['login'] user.email = data['login'] user.password = ptah.passwordTool.encode(data['password']) props = get_properties(user.uri) props.validated = data['validated'] props.suspended = data['suspended'] self.message("User properties has been updated.", 'info')
def create(self): data, errors = self.extract() if errors: self.message(errors, 'form-error') return # create user user = CrowdUser(data['name'], data['login'], data['login']) # set password user.password = ptah.passwordTool.encode(data['password']) props = get_properties(user.uri) props.validated = data['validated'] props.suspended = data['suspended'] Session.add(user) Session.flush() self.request.registry.notify(PrincipalAddedEvent(user)) self.message('User has been created.', 'success') raise HTTPFound(location='.')