Пример #1
0
def _create_topics():
    Topic.create_topic(
        'Other / Reason not listed',
        available_in_notes=True,
        available_in_appointments=True,
    )
    for index in range(10):
        true_for_both = index in [1, 5, 7]
        available_in_appointments = true_for_both or index % 2 == 0
        available_in_notes = true_for_both or index % 3 == 0
        if true_for_both:
            topic = f'Topic for all, {index}'
        elif available_in_appointments:
            topic = f'Topic for appointments, {index}'
        else:
            topic = f'Topic for notes, {index}'
        Topic.create_topic(
            topic=topic,
            available_in_appointments=available_in_appointments,
            available_in_notes=available_in_notes,
        )
    Topic.delete(
        Topic.create_topic('Topic for all, deleted',
                           available_in_appointments=True).id)
    Topic.delete(
        Topic.create_topic('Topic for appointments, deleted',
                           available_in_appointments=True).id)
    Topic.delete(
        Topic.create_topic('Topic for notes, deleted',
                           available_in_notes=True).id)
    std_commit(allow_test_environment=True)
Пример #2
0
def create_topic():
    params = request.json
    topic = params.get('topic', '').strip()
    available_in_notes = to_bool_or_none(
        params.get('availableInNotes')) or False
    available_in_appointments = to_bool_or_none(
        params.get('availableInAppointments')) or False
    if not topic or not (available_in_notes or available_in_appointments):
        raise BadRequestError('Required parameters are missing.')
    topic = Topic.create_topic(
        topic,
        available_in_notes=available_in_notes,
        available_in_appointments=available_in_appointments,
    )
    return tolerant_jsonify(topic.to_api_json())
Пример #3
0
def create_advising_note_topics():
    for i in range(5):
        Topic.create_topic(f'Topic {i}')
    delete_me = Topic.create_topic('I am a deleted topic')
    Topic.delete(delete_me.id)
    std_commit(allow_test_environment=True)