Esempio n. 1
0
def was_survey_submitted(survey):
    """Check whether the current user has submitted a survey"""
    if session.user and session.user.survey_submissions.filter_by(survey=survey).count():
        return True
    submission_id = session.get("submitted_surveys", {}).get(survey.id)
    if submission_id is None:
        return False
    return bool(SurveySubmission.find(id=submission_id).count())
Esempio n. 2
0
def was_survey_submitted(survey):
    """Check whether the current user has submitted a survey"""
    if session.user and session.user.survey_submissions.filter_by(survey=survey).count():
        return True
    submission_id = session.get('submitted_surveys', {}).get(survey.id)
    if submission_id is None:
        return False
    return bool(SurveySubmission.find(id=submission_id).count())
Esempio n. 3
0
 def _process_args(self):
     RHManageSurveysBase._process_args(self)
     survey_strategy = joinedload('survey')
     answers_strategy = defaultload('answers').joinedload('question')
     sections_strategy = joinedload('survey').defaultload(
         'sections').joinedload('children')
     self.submission = (SurveySubmission.find(
         id=request.view_args['submission_id']).options(
             answers_strategy, survey_strategy, sections_strategy).one())
Esempio n. 4
0
def was_survey_submitted(survey):
    """Check whether the current user has submitted a survey"""
    from indico.modules.events.surveys.models.surveys import Survey
    query = (Survey.query.with_parent(survey.event)
             .filter(Survey.submissions.any(db.and_(SurveySubmission.is_submitted,
                                                    SurveySubmission.user == session.user))))
    user_submitted_surveys = set(query)
    if session.user and survey in user_submitted_surveys:
        return True
    submission_id = session.get('submitted_surveys', {}).get(survey.id)
    if submission_id is None:
        return False
    return SurveySubmission.find(id=submission_id, is_submitted=True).has_rows()
Esempio n. 5
0
def was_survey_submitted(survey):
    """Check whether the current user has submitted a survey"""
    from indico.modules.events.surveys.models.surveys import Survey
    query = (Survey.query.with_parent(survey.event)
             .filter(Survey.submissions.any(db.and_(SurveySubmission.is_submitted,
                                                    SurveySubmission.user == session.user))))
    user_submitted_surveys = set(query)
    if session.user and survey in user_submitted_surveys:
        return True
    submission_id = session.get('submitted_surveys', {}).get(survey.id)
    if submission_id is None:
        return False
    return SurveySubmission.find(id=submission_id, is_submitted=True).has_rows()
Esempio n. 6
0
def _merge_users(target, source, **kwargs):
    from indico.modules.events.surveys.models.submissions import SurveySubmission
    SurveySubmission.find(user_id=source.id).update(
        {SurveySubmission.user_id: target.id})
Esempio n. 7
0
def _merge_users(target, source, **kwargs):
    from indico.modules.events.surveys.models.submissions import SurveySubmission
    SurveySubmission.find(user_id=source.id).update({SurveySubmission.user_id: target.id})