def post(self): form_data = { "username": self.get_argument('username', ''), "password": self.get_argument('password',''), "type": "admin", "servers": [], "apps": [] } try: valid_data = CreateUserForm.to_python(form_data) user_model.create_user(valid_data) self.session['message'] = 'User successfuly created. You can now log in' try: del self.session['errors'] del self.session['form_data'] except: pass self.redirect('/login') except InvalidForm, e: self.session['errors'] = e.unpack_errors() self.session['form_data'] = form_data self.redirect('/create_user')
def post(self): form_data = { "username": self.get_argument('username', None), "password": self.get_argument('password', None), "type": self.get_argument('type', None), "servers": self.get_arguments('servers[]', None) } try: CreateUserForm.to_python(form_data) self.delete_session_key('errors') self.delete_session_key('form_data') user_model.create_user(form_data) self.redirect(self.reverse_url('settings_users')) except InvalidForm, e: self.session['errors'] = e.unpack_errors() self.session['form_data'] = form_data self.redirect(self.reverse_url('settings_create_user'))
def post(self): form_data = { "username": self.get_argument('username', None), "password" : self.get_argument('password', None), "type": self.get_argument('type', None), "servers": self.get_arguments('servers[]',None) } try: CreateUserForm.to_python(form_data) self.delete_session_key('errors') self.delete_session_key('form_data') user_model.create_user(form_data) self.redirect(self.reverse_url('settings_users')) except InvalidForm, e: self.session['errors'] = e.unpack_errors() self.session['form_data'] = form_data self.redirect(self.reverse_url('settings_create_user'))