def submit_success(self, appstruct): model = self.schema.objectify(appstruct) model.userdatas_id = self.current_userdatas.id model = self.dbsession.merge(model) self.dbsession.flush() # Update CareerPath with chosen CareerStage's data model.cae_situation_id = model.career_stage.cae_situation_id model.stage_type = model.career_stage.stage_type model = self.dbsession.merge(model) self.dbsession.flush() # Redirect to login or stage's edition if needed dest_route = self.request.current_route_path(_query='') msg = u"L'étape de parcours a bien été ajoutée" if model.career_stage.cae_situation is not None: if model.career_stage.cae_situation.is_integration: login = Login.query().filter( Login.user_id == self.context.userdatas.user_id).first() if login is None: dest_route = self.request.route_path( '/users/{id}/login', id=self.context.userdatas.user_id) msg = u"L'étape de parcours a bien été ajoutée, \ vous devez maintenant créer les identifiants de l'utilisateur" if model.stage_type is not None: if model.stage_type in ("contract", "amendment", "exit"): dest_route = self.request.route_path('career_path', id=model.id, _query='') self.session.flash(msg) return HTTPFound(dest_route)
def test_submit_success_next_step( self, config, get_csrf_request_with_db, user, groups, ): from autonomie.views.user.login import LoginAddView from autonomie.models.user.login import Login config.add_route('/path1/{id}', '/path1/{id}') config.add_route('/path2/{id}', '/path2/{id}') req = get_csrf_request_with_db() req.context = user req.session['user_form'] = { 'callback_urls': ['/path1/{id}', '/path2/{id}'] } appstruct = {'pwd_hash': 'password', 'login': '******'} view = LoginAddView(req) result = view.submit_success(appstruct) new_login = Login.query().filter_by(login='******').one() assert result.code == 302 assert result.location == '/path2/{0}'.format(user.id) assert req.session['user_form']['callback_urls'] == ['/path1/{id}'] assert new_login.auth('password')
def test_submit_success( self, config, get_csrf_request_with_db, user, groups, ): from autonomie.views.user.login import LoginAddView from autonomie.models.user.login import Login config.add_route('/users/{id}', '/users/{id}') req = get_csrf_request_with_db() req.context = user appstruct = { 'pwd_hash': 'password', 'login': '******', 'primary_group': 'contractor', 'groups': ['trainer'], } view = LoginAddView(req) result = view.submit_success(appstruct) new_login = Login.query().filter_by(login='******').one() assert result.code == 302 assert result.location == '/users/{0}'.format(user.id) assert new_login.groups == ['trainer', 'contractor'] assert new_login.auth('password')
def submit_success(self, appstruct): model = self.schema.objectify(appstruct) model.userdatas_id = self.current_userdatas.id model = self.dbsession.merge(model) self.dbsession.flush() self.session.flash(u"L'étape de parcours a bien été enregistrée") dest = u"userdatas/career_path" # Redirect to login management if new CAE situation is integration and no active login if self.context.cae_situation is not None: if self.context.cae_situation.is_integration: login = Login.query().filter( Login.user_id == self.context.userdatas.user_id).first() if login is None: dest = u"login" return HTTPFound( self.request.route_path('/users/{id}/%s' % dest, id=self.context.userdatas_id))
def submit_success(self, appstruct): model = self.schema.objectify(appstruct) model.userdatas_id = self.current_userdatas.id model = self.dbsession.merge(model) self.dbsession.flush() # Update CareerPath with chosen CareerStage's data model.cae_situation_id = model.career_stage.cae_situation_id model.stage_type = model.career_stage.stage_type model = self.dbsession.merge(model) self.dbsession.flush() # Redirect to login or stage's edition if needed dest_route = self.request.current_route_path(_query='') msg = u"L'étape de parcours a bien été ajoutée" if model.career_stage.cae_situation is not None: if model.career_stage.cae_situation.is_integration: login = Login.query().filter( Login.user_id == self.context.userdatas.user_id ).first() if login is None: dest_route = self.request.route_path( '/users/{id}/login', id=self.context.userdatas.user_id ) msg = u"L'étape de parcours a bien été ajoutée, \ vous devez maintenant créer les identifiants de l'utilisateur" if model.stage_type is not None: if model.stage_type in ("contract", "amendment", "exit"): dest_route = self.request.route_path( 'career_path', id=model.id, _query='' ) self.session.flash(msg) return HTTPFound(dest_route)
def submit_success(self, appstruct): model = self.schema.objectify(appstruct) model.userdatas_id = self.current_userdatas.id model = self.dbsession.merge(model) self.dbsession.flush() self.session.flash(u"L'étape de parcours a bien été enregistrée") dest = u"userdatas/career_path" # Redirect to login management if new CAE situation is integration and # no active login if self.context.cae_situation is not None: if self.context.cae_situation.is_integration: login = Login.query().filter( Login.user_id == self.context.userdatas.user_id ).first() if login is None: dest = u"login" return HTTPFound( self.request.route_path( '/users/{id}/%s' % dest, id=self.context.userdatas.user_id ) )