Пример #1
0
def _create_checked_in_appointments():
    coe_scheduler_user_id = AuthorizedUser.get_id_per_uid('6972201')
    coe_advisor_uid = '90412'
    coe_advisor_user_id = AuthorizedUser.get_id_per_uid(coe_advisor_uid)
    l_s_director_uid = '53791'
    l_s_director_user_id = AuthorizedUser.get_id_per_uid(l_s_director_uid)

    check_me_in = Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_scheduler_user_id,
        dept_code='COENG',
        details='Pick me, pick me!',
        student_sid='3456789012',
        topics=['Topic for appointments, 2'],
    )
    Appointment.check_in(
        appointment_id=check_me_in.id,
        advisor_attrs=_advisor_attrs_for_uid(coe_advisor_uid),
        checked_in_by=coe_advisor_user_id,
    )
    check_me_in = Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_advisor_user_id,
        dept_code='COENG',
        details='Making appointments is da bomb.',
        student_sid='5678901234',
        topics=['Good Show'],
    )
    Appointment.check_in(
        appointment_id=check_me_in.id,
        advisor_attrs=_advisor_attrs_for_uid(coe_advisor_uid),
        checked_in_by=coe_advisor_user_id,
    )
    check_me_in = Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_scheduler_user_id,
        dept_code='COENG',
        details='We will check in this inactive student.',
        student_sid='3141592653',
        topics=['Please check me in.'],
    )
    Appointment.check_in(
        appointment_id=check_me_in.id,
        checked_in_by=coe_advisor_user_id,
        advisor_attrs=_advisor_attrs_for_uid(coe_advisor_uid),
    )
    # L&S College Advising
    check_me_in = Appointment.create(
        appointment_type='Drop-in',
        created_by=l_s_director_user_id,
        dept_code='QCADV',
        details='It is not the length of life, but depth of life.',
        student_sid='11667051',
        topics=['Topic for appointments, 1'],
    )
    Appointment.check_in(
        appointment_id=check_me_in.id,
        advisor_attrs=_advisor_attrs_for_uid(l_s_director_uid),
        checked_in_by=l_s_director_user_id,
    )
Пример #2
0
def create_appointment():
    params = request.get_json()
    dept_code = params.get('deptCode', None)
    sid = params.get('sid', None)
    advisor_uid = params.get('advisorUid', None)
    appointment_type = params.get('appointmentType', None)
    topics = params.get('topics', None)
    if not dept_code or not sid or not appointment_type or not len(topics):
        raise BadRequestError(
            'Appointment creation: required parameters were not provided')
    dept_code = dept_code.upper()
    if dept_code not in BERKELEY_DEPT_CODE_TO_NAME:
        raise ResourceNotFoundError(
            f'Unrecognized department code: {dept_code}')
    if dept_code not in _dept_codes_with_scheduler_privilege():
        raise ForbiddenRequestError(
            f'You are unauthorized to manage {dept_code} appointments.')
    appointment = Appointment.create(
        advisor_uid=advisor_uid,
        appointment_type=appointment_type,
        created_by=current_user.get_id(),
        dept_code=dept_code,
        details=params.get('details', None),
        student_sid=sid,
        topics=topics,
    )
    AppointmentRead.find_or_create(current_user.get_id(), appointment.id)
    api_json = appointment.to_api_json(current_user.get_id())
    _put_student_profile_per_appointment([api_json])
    return tolerant_jsonify(api_json)
Пример #3
0
def _create_reserved_appointments():
    coe_advisor_user_id = AuthorizedUser.get_id_per_uid('90412')
    reserve_me = Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_advisor_user_id,
        dept_code='COENG',
        details='I will reserve this appointment.',
        student_sid='7890123456',
        topics=['Whoops'],
    )
    Appointment.reserve(appointment_id=reserve_me.id,
                        reserved_by=coe_advisor_user_id)
Пример #4
0
def _create_reserved_appointments():
    coe_advisor_attrs = _advisor_attrs_for_uid('90412')
    reserve_me = Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_advisor_attrs['id'],
        dept_code='COENG',
        details='I will reserve this appointment.',
        student_sid='7890123456',
        topics=['Whoops'],
    )
    Appointment.reserve(appointment_id=reserve_me.id,
                        reserved_by=coe_advisor_attrs['id'],
                        advisor_attrs=coe_advisor_attrs)
Пример #5
0
def _create_cancelled_appointments():
    coe_advisor_user_id = AuthorizedUser.get_id_per_uid('90412')
    scheduler_user_id = AuthorizedUser.get_id_per_uid('6972201')
    cancel_me = Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_advisor_user_id,
        dept_code='COENG',
        details='We will cancel this appointment.',
        student_sid='7890123456',
        topics=['Whoops'],
    )
    Appointment.cancel(
        appointment_id=cancel_me.id,
        cancelled_by=scheduler_user_id,
        cancel_reason='Just because',
        cancel_reason_explained='I felt like it.',
    )
Пример #6
0
def create_appointment():
    params = request.get_json()
    dept_code = params.get('deptCode', None)
    sid = params.get('sid', None)
    appointment_type = params.get('appointmentType', None)
    topics = params.get('topics', None)
    if not dept_code or not sid or not appointment_type or not len(topics):
        raise BadRequestError('Appointment creation: required parameters were not provided')
    dept_code = dept_code.upper()
    if dept_code not in BERKELEY_DEPT_CODE_TO_NAME:
        raise ResourceNotFoundError(f'Unrecognized department code: {dept_code}')
    if dept_code not in _dept_codes_with_scheduler_privilege():
        raise ForbiddenRequestError(f'You are unauthorized to manage {dept_code} appointments.')
    advisor_attrs = None
    advisor_uid = params.get('advisorUid')
    if advisor_uid:
        advisor_attrs = _advisor_attrs_for_uid(advisor_uid)
        if not advisor_attrs:
            raise BadRequestError('Invalid "advisorUid"')
    details = params.get('details', None)
    scheduled_time = params.get('scheduledTime', None)
    if scheduled_time:
        scheduled_time = localized_timestamp_to_utc(scheduled_time)
    student_contact_info = params.get('studentContactInfo', None)
    student_contact_type = params.get('studentContactType', None)
    appointment = Appointment.create(
        advisor_attrs=advisor_attrs,
        appointment_type=appointment_type,
        created_by=current_user.get_id(),
        dept_code=dept_code,
        details=process_input_from_rich_text_editor(details),
        scheduled_time=scheduled_time,
        student_contact_info=student_contact_info,
        student_contact_type=student_contact_type,
        student_sid=sid,
        topics=topics,
    )
    AppointmentRead.find_or_create(current_user.get_id(), appointment.id)
    api_json = appointment.to_api_json(current_user.get_id())
    _put_student_profile_per_appointment([api_json])
    return tolerant_jsonify(api_json)
Пример #7
0
def _create_waiting_appointments():
    coe_advisor_user_id = AuthorizedUser.get_id_per_uid('90412')
    coe_scheduler_user_id = AuthorizedUser.get_id_per_uid('6972201')
    l_s_director_user_id = AuthorizedUser.get_id_per_uid('53791')
    Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_scheduler_user_id,
        dept_code='COENG',
        details='Meet me at the crossroads.',
        student_sid='3456789012',
        topics=['Topic for appointments, 2'],
    )
    Appointment.create(
        appointment_type='Drop-in',
        created_by=coe_advisor_user_id,
        dept_code='COENG',
        details='Life is what happens while you\'re making appointments.',
        student_sid='5678901234',
        topics=['Good Show'],
    )
    # L&S College Advising
    Appointment.create(
        appointment_type='Drop-in',
        created_by=l_s_director_user_id,
        dept_code='QCADV',
        details='C-c-catch the wave!',
        student_sid='5678901234',
        topics=['Topic for appointments, 1', 'Good Show'],
    )
    Appointment.create(
        appointment_type='Drop-in',
        created_by=l_s_director_user_id,
        dept_code='QCADV',
        details='You be you.',
        student_sid='11667051',
        topics=['Topic for appointments, 1'],
    )