def _get_active_surveys(event): if not event.has_feature('surveys'): return [] from indico.modules.events.surveys.models.surveys import Survey return (Survey.find(Survey.is_active, Survey.event_id == int(event.id)).order_by( db.func.lower(Survey.title)).all())
def validate_title(self, field): query = Survey.find(Survey.event_id == self.event.id, db.func.lower(Survey.title) == field.data.lower(), Survey.title != field.object_data, ~Survey.is_deleted) if query.count(): raise ValidationError(_("There is already an survey named \"{}\" on this event".format(escape(field.data))))
def _get_active_surveys(event): if not event.has_feature('surveys'): return [] from indico.modules.events.surveys.models.surveys import Survey return (Survey.find(Survey.is_active, Survey.event_id == int(event.id)) .order_by(db.func.lower(Survey.title)) .all())
def validate_title(self, field): query = Survey.find(Survey.event_id == self.event.id, db.func.lower(Survey.title) == field.data.lower(), Survey.title != field.object_data, ~Survey.is_deleted) if query.count(): raise ValidationError(_("There is already an survey named \"{}\" on this event".format(escape(field.data))))
def _process(self): surveys = Survey.find(event_id=self.event.id, is_deleted=False).order_by( db.func.lower(Survey.title)).all() return WPManageSurvey.render_template('management/survey_list.html', self.event, event=self.event, surveys=surveys)
def _render_questionnaire_preview(survey): # load the survey once again with all the necessary data survey = (Survey.find(id=survey.id).options( joinedload(Survey.sections).joinedload(SurveySection.children)).one()) tpl = get_template_module( 'events/surveys/management/_questionnaire_preview.html') form = make_survey_form(survey)() return tpl.render_questionnaire_preview(survey, form, get_field_types())
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 _process(self): surveys = Survey.find(event_id=self.event.id, is_deleted=False).order_by(db.func.lower(Survey.title)).all() return WPManageSurvey.render_template('management/survey_list.html', self.event, event=self.event, surveys=surveys)
def _visible(event): return (event.has_feature('surveys') and bool( Survey.find(Survey.is_visible, Survey.event_id == int( event.id)).count()))
def _visible(event): return (event.has_feature('surveys') and bool(Survey.find(Survey.is_visible, Survey.event_id == int(event.id)).count()))