Ejemplo n.º 1
0
def _create_demo_user(session):
    with session.begin():
        user = Administrator(name="demo_user", emails=[Email(address="*****@*****.**")])
        survey = models.construct_survey(
            title={"English": "Demo Education Survey"},
            survey_type="public",
            url_slug="demo",
            nodes=[
                models.construct_survey_node(
                    node=models.construct_node(type_constraint="photo", title={"English": "Photo of Facility Exterior"})
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint="facility",
                        title={"English": "Facility"},
                        hint={"English": ("Select the facility from the list, or add" " a new one.")},
                        logic={"slat": -85, "nlat": 85, "wlng": -180, "elng": 180},
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint="multiple_choice",
                        title={"English": "Education Type"},
                        choices=[
                            models.Choice(choice_text={"English": "public"}),
                            models.Choice(choice_text={"English": "private"}),
                        ],
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint="multiple_choice",
                        title={"English": "Education Level"},
                        allow_other=True,
                        choices=[
                            models.Choice(choice_text={"English": "primary"}),
                            models.Choice(choice_text={"English": "secondary"}),
                            models.Choice(choice_text={"English": "both"}),
                        ],
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint="integer", title={"English": "Number of Students"}, logic={"min": 0}
                    )
                ),
            ],
        )
        user.surveys.append(survey)
        session.add(user)
        session.flush()
        survey.submissions.extend(
            [
                models.construct_submission(
                    submission_type="public_submission",
                    submitter_name="Demo Submitter 1",
                    submission_time=(datetime.datetime.now() - datetime.timedelta(days=1)),
                    save_time=(datetime.datetime.now() - datetime.timedelta(days=1)),
                    answers=[
                        models.construct_answer(
                            survey_node=survey.nodes[1],
                            type_constraint="facility",
                            answer={
                                "facility_id": 1,
                                "lat": 40.8,
                                "lng": -73.9,
                                "facility_name": "Demo Facility 1",
                                "facility_sector": "Demo",
                            },
                        ),
                        models.construct_answer(
                            survey_node=survey.nodes[2],
                            type_constraint="multiple_choice",
                            answer=survey.nodes[2].node.choices[1].id,
                        ),
                        models.construct_answer(
                            survey_node=survey.nodes[3], type_constraint="multiple_choice", other="Technical"
                        ),
                        models.construct_answer(survey_node=survey.nodes[4], type_constraint="integer", answer=200),
                    ],
                ),
                models.construct_submission(
                    submission_type="public_submission",
                    submitter_name="Demo Submitter 2",
                    submission_time=(datetime.datetime.now() - datetime.timedelta(days=4)),
                    save_time=(datetime.datetime.now() - datetime.timedelta(days=4)),
                    answers=[
                        models.construct_answer(
                            survey_node=survey.nodes[1],
                            type_constraint="facility",
                            answer={
                                "facility_id": 2,
                                "lat": 42,
                                "lng": -74,
                                "facility_name": "Demo Facility 2",
                                "facility_sector": "Demo",
                            },
                        ),
                        models.construct_answer(
                            survey_node=survey.nodes[2],
                            type_constraint="multiple_choice",
                            answer=survey.nodes[2].node.choices[0].id,
                        ),
                        models.construct_answer(
                            survey_node=survey.nodes[3],
                            type_constraint="multiple_choice",
                            answer=survey.nodes[3].node.choices[0].id,
                        ),
                        models.construct_answer(survey_node=survey.nodes[4], type_constraint="integer", answer=300),
                    ],
                ),
            ]
        )
        session.add(survey)
    return user
Ejemplo n.º 2
0
def _create_answer(session, answer_dict) -> Answer:
    survey_node_id = answer_dict['survey_node_id']
    error = exc.BadRequest('survey_node not found: {}'.format(survey_node_id))
    survey_node = get_model(session, SurveyNode, survey_node_id, error)
    answer_dict['survey_node'] = survey_node
    return construct_answer(**answer_dict)
Ejemplo n.º 3
0
def load_fixtures(engine):
    """Create test users, surveys, and submissions."""
    # creates db schema
    session = Session(bind=engine, autocommit=True)

    with session.begin():
        creator = models.Administrator(
            name='test_user',
            # known ID against which we can test
            id='b7becd02-1a3f-4c1d-a0e1-286ba121aef4',
            emails=[models.Email(address='*****@*****.**')],
        )
        creator_b = models.Administrator(
            name='test_user_b',
            # known ID against which we can test
            id='e7becd02-1a3f-4c1d-a0e1-286ba121aef1',
            emails=[models.Email(address='*****@*****.**')],
        )
        enumerator = models.User(
            name='test_user',
            # known ID against which we can test
            id='a7becd02-1a3f-4c1d-a0e1-286ba121aef3',
            emails=[models.Email(address='*****@*****.**')],
        )
        node_types = list(models.NODE_TYPES)
        for node_type in node_types:
            node_dict = {
                'title': {
                    'English': node_type + '_node'
                },
                'type_constraint': node_type,
            }
            if node_type == 'facility':
                node_dict['logic'] = {
                    'slat': 39,
                    'nlat': 41,
                    'wlng': -71,
                    'elng': -69,
                }
            survey = models.Survey(
                title={'English': node_type + '_survey'},
                nodes=[
                    models.construct_survey_node(
                        node=models.construct_node(**node_dict), ),
                ],
            )
            creator.surveys.append(survey)

            # Add a single submission per survey
            regular_submission = models.PublicSubmission(
                survey=survey, submitter_name='regular')
            session.add(regular_submission)

        # Add another survey with known ID
        single_survey = models.Survey(
            id='b0816b52-204f-41d4-aaf0-ac6ae2970923',
            title={'English': 'single_survey'},
            nodes=[
                models.construct_survey_node(
                    id="60e56824-910c-47aa-b5c0-71493277b43f",
                    node=models.construct_node(
                        id="60e56824-910c-47aa-b5c0-71493277b43f",
                        title={'English': 'integer node'},
                        type_constraint='integer',
                    ),
                    sub_surveys=[
                        models.SubSurvey(
                            buckets=[
                                models.construct_bucket(bucket_type='integer',
                                                        bucket='(1, 2]'),
                            ],
                            nodes=[
                                models.construct_survey_node(
                                    node=models.construct_node(
                                        title={'English': 'decimal node'},
                                        type_constraint='decimal',
                                    ),
                                    sub_surveys=[
                                        models.SubSurvey(buckets=[
                                            models.construct_bucket(
                                                bucket_type='decimal',
                                                bucket='(1.3, 2.3]'),
                                        ], ),
                                    ],
                                ),
                                models.construct_survey_node(
                                    node=models.construct_node(
                                        title={'English': 'integer node'},
                                        type_constraint='integer',
                                    ),
                                    sub_surveys=[
                                        models.SubSurvey(buckets=[
                                            models.construct_bucket(
                                                bucket_type='integer',
                                                bucket='(1, 2]'),
                                        ])
                                    ],
                                ),
                                models.construct_survey_node(
                                    node=models.construct_node(
                                        title={'English': 'date node'},
                                        type_constraint='date',
                                    ),
                                    sub_surveys=[
                                        models.SubSurvey(buckets=[
                                            models.construct_bucket(
                                                bucket_type='date',
                                                bucket=(
                                                    '(2015-1-1, 2015-2-2]')),
                                        ], ),
                                    ],
                                )
                            ]),
                    ],
                ),
                models.construct_survey_node(
                    id="80e56824-910c-47aa-b5c0-71493277b439",
                    allow_dont_know=True,
                    node=models.construct_node(
                        id="80e56824-910c-47aa-b5c0-71493277b439",
                        title={'English': 'Mutliple Choices'},
                        type_constraint='multiple_choice',
                        allow_other=True,
                        choices=[
                            models.Choice(
                                id="99956824-910c-47aa-b5c0-71493277b439",
                                choice_text={"English": "first choice"}),
                            models.Choice(
                                id="11156824-910c-47aa-b5c0-71493277b439",
                                choice_text={"English": "second choice"}),
                        ])),
            ],
        )

        # Add another survey with known ID for creator_b
        single_survey_c_b = models.Survey(
            id='d0816b52-204f-41d4-aaf0-ac6ae2970923',
            title={'English': 'single_survey_c_b'},
            nodes=[],
        )

        # Add an enumerator only survey with known ID
        single_enum_survey = models.EnumeratorOnlySurvey(
            id='c0816b52-204f-41d4-aaf0-ac6ae2970925',
            languages=['English', 'Español', 'Russian'],
            default_language='Russian',
            title={
                'English': 'enumerator_only_single_survey',
                'Español': 'ENUMERATOR_ONLY_SINGLE_SURVEY',
                'Russian': 'enumerator_only_single_survey (Russian)'
            },
            nodes=[
                models.construct_survey_node(
                    allow_dont_know=True,
                    node=models.construct_node(
                        title={
                            'English': 'Engine Room Photo',
                            'Russian': 'Engine Room Photo (Russian)',
                            'Español': 'Photo de Engine Room'
                        },
                        hint={
                            'English': ('Tap the image to capture a photo.'),
                            'Español':
                            ('Marca la imagen para grabar una photo.'),
                            'Russian': ('Tap the image to capture a photo.'
                                        ' (Russian)')
                        },
                        type_constraint='photo',
                        allow_multiple=True)),
            ],
            enumerators=[creator])

        # Add another public submission with a known ID
        single_regular_submission = models.PublicSubmission(
            id='b0816b52-204f-41d4-aaf0-ac6ae2970924',
            survey=single_survey,
            submitter_name='regular_singular',
            answers=[
                models.construct_answer(
                    survey_node=single_survey.nodes[0],
                    type_constraint='integer',
                    answer=3,
                ),
            ])
        session.add(single_regular_submission)

        # Add 100 public submissions over the past 100 days
        today = datetime.date.today()
        for i in range(0, 100):
            sub_time = today - datetime.timedelta(days=i)
            sub = models.PublicSubmission(
                survey=single_survey,
                submitter_name='regular',
                save_time=sub_time,
                submission_time=sub_time,
            )
            session.add(sub)

        # Add surveys to creator and enumerator
        creator.surveys.append(single_survey)
        creator_b.surveys.append(single_survey_c_b)
        creator.surveys.append(single_enum_survey)
        enumerator.allowed_surveys.append(single_enum_survey)

        # Finally save the creator and enumerator
        session.add(creator)
        session.add(creator_b)
        session.add(enumerator)
Ejemplo n.º 4
0
def _create_demo_user(session):
    with session.begin():
        user = Administrator(
            name='demo_user',
            emails=[Email(address='*****@*****.**')],
        )
        survey = models.construct_survey(
            title={'English': 'Demo Education Survey'},
            survey_type='public',
            url_slug='demo',
            nodes=[
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='photo',
                        title={'English': 'Photo of Facility Exterior'}
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='facility',
                        title={'English': 'Facility'},
                        hint={'English': (
                            'Select the facility from the list, or add'
                            ' a new one.'
                        )},
                        logic={
                            'slat': -85,
                            'nlat': 85,
                            'wlng': -180,
                            'elng': 180,
                        }
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='multiple_choice',
                        title={'English': 'Education Type'},
                        choices=[
                            models.Choice(
                                choice_text={
                                    'English': 'public',
                                }
                            ),
                            models.Choice(
                                choice_text={
                                    'English': 'private',
                                }
                            )
                        ]
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='multiple_choice',
                        title={'English': 'Education Level'},
                        allow_other=True,
                        choices=[
                            models.Choice(
                                choice_text={
                                    'English': 'primary',
                                }
                            ),
                            models.Choice(
                                choice_text={
                                    'English': 'secondary',
                                }
                            ),
                            models.Choice(
                                choice_text={
                                    'English': 'both',
                                }
                            )
                        ]
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='integer',
                        title={'English': 'Number of Students'},
                        logic={'min': 0}
                    )
                ),
            ],
        )
        user.surveys.append(survey)
        session.add(user)
        session.flush()
        survey.submissions.extend([
            models.construct_submission(
                submission_type='public_submission',
                submitter_name='Demo Submitter 1',
                submission_time=(
                    datetime.datetime.now() - datetime.timedelta(days=1)
                ),
                save_time=(
                    datetime.datetime.now() - datetime.timedelta(days=1)
                ),
                answers=[
                    models.construct_answer(
                        survey_node=survey.nodes[1],
                        type_constraint='facility',
                        answer={
                            'facility_id': 1,
                            'lat': 40.8,
                            'lng': -73.9,
                            'facility_name': 'Demo Facility 1',
                            'facility_sector': 'Demo',
                        },
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[2],
                        type_constraint='multiple_choice',
                        answer=survey.nodes[2].node.choices[1].id,
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[3],
                        type_constraint='multiple_choice',
                        other='Technical',
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[4],
                        type_constraint='integer',
                        answer=200,
                    ),
                ],
            ),
            models.construct_submission(
                submission_type='public_submission',
                submitter_name='Demo Submitter 2',
                submission_time=(
                    datetime.datetime.now() - datetime.timedelta(days=4)
                ),
                save_time=(
                    datetime.datetime.now() - datetime.timedelta(days=4)
                ),
                answers=[
                    models.construct_answer(
                        survey_node=survey.nodes[1],
                        type_constraint='facility',
                        answer={
                            'facility_id': 2,
                            'lat': 42,
                            'lng': -74,
                            'facility_name': 'Demo Facility 2',
                            'facility_sector': 'Demo',
                        },
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[2],
                        type_constraint='multiple_choice',
                        answer=survey.nodes[2].node.choices[0].id,
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[3],
                        type_constraint='multiple_choice',
                        answer=survey.nodes[3].node.choices[0].id,
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[4],
                        type_constraint='integer',
                        answer=300,
                    ),
                ],
            ),
        ])
        session.add(survey)
    return user
Ejemplo n.º 5
0
def _create_demo_user(session):
    with session.begin():
        user = Administrator(
            name='demo_user',
            emails=[Email(address='*****@*****.**')],
        )
        survey = models.construct_survey(
            title={'English': 'Demo Education Survey'},
            survey_type='public',
            url_slug='demo',
            nodes=[
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='photo',
                        title={'English': 'Photo of Facility Exterior'}
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='facility',
                        title={'English': 'Facility'},
                        hint={'English': (
                            'Select the facility from the list, or add'
                            ' a new one.'
                        )},
                        logic={
                            'slat': -85,
                            'nlat': 85,
                            'wlng': -180,
                            'elng': 180,
                        }
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='multiple_choice',
                        title={'English': 'Education Type'},
                        choices=[
                            models.Choice(
                                choice_text={
                                    'English': 'public',
                                }
                            ),
                            models.Choice(
                                choice_text={
                                    'English': 'private',
                                }
                            )
                        ]
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='multiple_choice',
                        title={'English': 'Education Level'},
                        allow_other=True,
                        choices=[
                            models.Choice(
                                choice_text={
                                    'English': 'primary',
                                }
                            ),
                            models.Choice(
                                choice_text={
                                    'English': 'secondary',
                                }
                            ),
                            models.Choice(
                                choice_text={
                                    'English': 'both',
                                }
                            )
                        ]
                    )
                ),
                models.construct_survey_node(
                    node=models.construct_node(
                        type_constraint='integer',
                        title={'English': 'Number of Students'},
                        logic={'min': 0}
                    )
                ),
            ],
        )
        user.surveys.append(survey)
        session.add(user)
        session.flush()
        survey.submissions.extend([
            models.construct_submission(
                submission_type='public_submission',
                submitter_name='Demo Submitter 1',
                submission_time=(
                    datetime.datetime.now() - datetime.timedelta(days=1)
                ),
                save_time=(
                    datetime.datetime.now() - datetime.timedelta(days=1)
                ),
                answers=[
                    models.construct_answer(
                        survey_node=survey.nodes[1],
                        type_constraint='facility',
                        answer={
                            'facility_id': 1,
                            'lat': 40.8,
                            'lng': -73.9,
                            'facility_name': 'Demo Facility 1',
                            'facility_sector': 'Demo',
                        },
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[2],
                        type_constraint='multiple_choice',
                        answer=survey.nodes[2].node.choices[1].id,
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[3],
                        type_constraint='multiple_choice',
                        other='Technical',
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[4],
                        type_constraint='integer',
                        answer=200,
                    ),
                ],
            ),
            models.construct_submission(
                submission_type='public_submission',
                submitter_name='Demo Submitter 2',
                submission_time=(
                    datetime.datetime.now() - datetime.timedelta(days=4)
                ),
                save_time=(
                    datetime.datetime.now() - datetime.timedelta(days=4)
                ),
                answers=[
                    models.construct_answer(
                        survey_node=survey.nodes[1],
                        type_constraint='facility',
                        answer={
                            'facility_id': 2,
                            'lat': 42,
                            'lng': -74,
                            'facility_name': 'Demo Facility 2',
                            'facility_sector': 'Demo',
                        },
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[2],
                        type_constraint='multiple_choice',
                        answer=survey.nodes[2].node.choices[0].id,
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[3],
                        type_constraint='multiple_choice',
                        answer=survey.nodes[3].node.choices[0].id,
                    ),
                    models.construct_answer(
                        survey_node=survey.nodes[4],
                        type_constraint='integer',
                        answer=300,
                    ),
                ],
            ),
        ])
        session.add(survey)
    return user
Ejemplo n.º 6
0
def load_fixtures(engine):
    """Create test users, surveys, and submissions."""
    # creates db schema
    session = Session(bind=engine, autocommit=True)

    with session.begin():
        creator = models.Administrator(
            name='test_user',
            # known ID against which we can test
            id='b7becd02-1a3f-4c1d-a0e1-286ba121aef4',
            emails=[models.Email(address='*****@*****.**')],
        )
        creator_b = models.Administrator(
            name='test_user_b',
            # known ID against which we can test
            id='e7becd02-1a3f-4c1d-a0e1-286ba121aef1',
            emails=[models.Email(address='*****@*****.**')],
        )
        enumerator = models.User(
            name='test_user',
            # known ID against which we can test
            id='a7becd02-1a3f-4c1d-a0e1-286ba121aef3',
            emails=[models.Email(address='*****@*****.**')],
        )
        node_types = list(models.NODE_TYPES)
        for node_type in node_types:
            node_dict = {
                'title': {'English': node_type + '_node'},
                'type_constraint': node_type,
            }
            if node_type == 'facility':
                node_dict['logic'] = {
                    'slat': 39,
                    'nlat': 41,
                    'wlng': -71,
                    'elng': -69,
                }
            survey = models.Survey(
                title={'English': node_type + '_survey'},
                nodes=[
                    models.construct_survey_node(
                        node=models.construct_node(**node_dict),
                    ),
                ],
            )
            creator.surveys.append(survey)

            # Add a single submission per survey
            regular_submission = models.PublicSubmission(
                survey=survey,
                submitter_name='regular'
            )
            session.add(regular_submission)

        # Add another survey with known ID
        single_survey = models.Survey(
            id='b0816b52-204f-41d4-aaf0-ac6ae2970923',
            title={'English': 'single_survey'},
            nodes=[
                models.construct_survey_node(
                    id="60e56824-910c-47aa-b5c0-71493277b43f",
                    node=models.construct_node(
                        id="60e56824-910c-47aa-b5c0-71493277b43f",
                        title={'English': 'integer node'},
                        type_constraint='integer',
                    ),
                    sub_surveys=[
                        models.SubSurvey(
                            buckets=[
                                models.construct_bucket(
                                    bucket_type='integer',
                                    bucket='(1, 2]'
                                ),
                            ],
                            nodes=[
                                models.construct_survey_node(
                                    node=models.construct_node(
                                        title={'English': 'decimal node'},
                                        type_constraint='decimal',
                                    ),
                                    sub_surveys=[
                                        models.SubSurvey(
                                            buckets=[
                                                models.construct_bucket(
                                                    bucket_type='decimal',
                                                    bucket='(1.3, 2.3]'
                                                ),
                                            ],
                                        ),
                                    ],
                                ),
                                models.construct_survey_node(
                                    node=models.construct_node(
                                        title={'English': 'integer node'},
                                        type_constraint='integer',
                                    ),
                                    sub_surveys=[
                                        models.SubSurvey(
                                            buckets=[
                                                models.construct_bucket(
                                                    bucket_type='integer',
                                                    bucket='(1, 2]'
                                                ),
                                            ]
                                        )
                                    ],
                                ),
                                models.construct_survey_node(
                                    node=models.construct_node(
                                        title={'English': 'date node'},
                                        type_constraint='date',
                                    ),
                                    sub_surveys=[
                                        models.SubSurvey(
                                            buckets=[
                                                models.construct_bucket(
                                                    bucket_type='date',
                                                    bucket=(
                                                        '(2015-1-1, 2015-2-2]'
                                                    )
                                                ),
                                            ],
                                        ),
                                    ],
                                )
                            ]
                        ),
                    ],
                ),
                models.construct_survey_node(
                    id="80e56824-910c-47aa-b5c0-71493277b439",
                    allow_dont_know=True,
                    node=models.construct_node(
                        id="80e56824-910c-47aa-b5c0-71493277b439",
                        title={'English': 'Mutliple Choices'},
                        type_constraint='multiple_choice',
                        allow_other=True,
                        choices=[
                            models.Choice(
                                id="99956824-910c-47aa-b5c0-71493277b439",
                                choice_text={"English": "first choice"}),
                            models.Choice(
                                id="11156824-910c-47aa-b5c0-71493277b439",
                                choice_text={"English": "second choice"}),
                        ]
                    )
                ),
            ],
        )

        # Add another survey with known ID for creator_b
        single_survey_c_b = models.Survey(
            id='d0816b52-204f-41d4-aaf0-ac6ae2970923',
            title={'English': 'single_survey_c_b'},
            nodes=[],
        )

        # Add an enumerator only survey with known ID
        single_enum_survey = models.EnumeratorOnlySurvey(
            id='c0816b52-204f-41d4-aaf0-ac6ae2970925',
            languages=['English', 'Español', 'Russian'],
            default_language='Russian',
            title={
                'English': 'enumerator_only_single_survey',
                'Español': 'ENUMERATOR_ONLY_SINGLE_SURVEY',
                'Russian': 'enumerator_only_single_survey (Russian)'
            },
            nodes=[
                models.construct_survey_node(
                    allow_dont_know=True,
                    node=models.construct_node(
                        title={
                            'English': 'Engine Room Photo',
                            'Russian': 'Engine Room Photo (Russian)',
                            'Español': 'Photo de Engine Room'
                        },
                        hint={'English': (
                            'Tap the image to capture a photo.'
                        ), 'Español': (
                            'Marca la imagen para grabar una photo.'
                        ), 'Russian': (
                            'Tap the image to capture a photo.'
                            ' (Russian)'
                        )},
                        type_constraint='photo',
                        allow_multiple=True
                    )
                ),
            ],
            enumerators=[
                creator
            ]
        )

        # Add another public submission with a known ID
        single_regular_submission = models.PublicSubmission(
            id='b0816b52-204f-41d4-aaf0-ac6ae2970924',
            survey=single_survey,
            submitter_name='regular_singular',
            answers=[
                models.construct_answer(
                    survey_node=single_survey.nodes[0],
                    type_constraint='integer',
                    answer=3,
                ),
            ]
        )
        session.add(single_regular_submission)

        # Add 100 public submissions over the past 100 days
        today = datetime.date.today()
        for i in range(0, 100):
            sub_time = today - datetime.timedelta(days=i)
            sub = models.PublicSubmission(
                survey=single_survey,
                submitter_name='regular',
                save_time=sub_time,
                submission_time=sub_time,
            )
            session.add(sub)

        # Add surveys to creator and enumerator
        creator.surveys.append(single_survey)
        creator_b.surveys.append(single_survey_c_b)
        creator.surveys.append(single_enum_survey)
        enumerator.allowed_surveys.append(single_enum_survey)

        # Finally save the creator and enumerator
        session.add(creator)
        session.add(creator_b)
        session.add(enumerator)