def _can_redirect_to_single_survey(surveys): # Make sure redirection to first survey does not happen before login if user is required. if not session.user and len( surveys) == 1 and surveys[0].is_active and surveys[0].require_user: return False return len( surveys) == 1 and surveys[0].is_active and not was_survey_submitted( surveys[0])
def _checkParams(self, params): RHSurveyBaseDisplay._checkParams(self, params) self.survey = (Survey.query .filter(Survey.id == request.view_args['survey_id'], Survey.is_visible) .options(joinedload('submissions'), joinedload('sections').joinedload('children')) .one()) if not self.survey.is_active: flash(_('This survey is not active'), 'error') return redirect(url_for('.display_survey_list', self.event_new)) elif was_survey_submitted(self.survey): flash(_('You have already answered this survey'), 'error') return redirect(url_for('.display_survey_list', self.event_new))
def _checkParams(self, params): RHSurveyBaseDisplay._checkParams(self, params) self.survey = (Survey .find(Survey.id == request.view_args['survey_id'], Survey.is_visible) .options(joinedload(Survey.submissions)) .options(joinedload(Survey.sections).joinedload(SurveySection.children)) .one()) if not self.survey.is_active: flash(_('This survey is not active'), 'error') return redirect(url_for('.display_survey_list', self.event)) elif was_survey_submitted(self.survey): flash(_('You have already answered this survey'), 'error') return redirect(url_for('.display_survey_list', self.event))
def _checkParams(self, params): RHSurveyBaseDisplay._checkParams(self, params) self.survey = ( Survey.query.filter(Survey.id == request.view_args["survey_id"], Survey.is_visible) .options(joinedload("submissions"), joinedload("sections").joinedload("children")) .one() ) if not self.survey.is_active: flash(_("This survey is not active"), "error") return redirect(url_for(".display_survey_list", self.event_new)) elif was_survey_submitted(self.survey): flash(_("You have already answered this survey"), "error") return redirect(url_for(".display_survey_list", self.event_new))
def _process_args(self): RHSurveyBaseDisplay._process_args(self) self.survey = (Survey.query .filter(Survey.id == request.view_args['survey_id'], Survey.is_visible) .options(joinedload('submissions'), joinedload('sections').joinedload('children')) .one()) self.submission = (session.user.survey_submissions.filter_by(survey=self.survey, is_submitted=False).first() if session.user else None) if not self.survey.is_active: flash(_('This survey is not active'), 'error') return redirect(url_for('.display_survey_list', self.event)) elif was_survey_submitted(self.survey): flash(_('You have already answered this survey'), 'error') return redirect(url_for('.display_survey_list', self.event))
def _can_redirect_to_single_survey(surveys): return len(surveys) == 1 and surveys[0].is_active and not was_survey_submitted(surveys[0])
def _can_redirect_to_single_survey(surveys): return len( surveys) == 1 and surveys[0].is_active and not was_survey_submitted( surveys[0])