Esempio n. 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,
    )
Esempio n. 2
0
def appointment_check_in(appointment_id):
    appointment = Appointment.find_by_id(appointment_id)
    if not appointment:
        raise ResourceNotFoundError('Unknown path')
    if appointment.dept_code in _dept_codes_with_scheduler_privilege():
        params = request.get_json()
        advisor_uid = params.get('advisorUid', None)
        if not advisor_uid:
            raise BadRequestError(
                'Appointment check-in requires \'advisor_uid\'')
        appointment = Appointment.check_in(
            appointment_id=appointment_id,
            checked_in_by=current_user.get_id(),
            advisor_dept_codes=params.get('advisorDeptCodes', None),
            advisor_name=params.get('advisorName', None),
            advisor_role=params.get('advisorRole', None),
            advisor_uid=advisor_uid,
        )
        api_json = appointment.to_api_json(current_user.get_id())
        _put_student_profile_per_appointment([api_json])
        return tolerant_jsonify(api_json)
    else:
        raise ForbiddenRequestError(
            f'You are unauthorized to manage {appointment.dept_code} appointments.'
        )
def appointment_check_in(appointment_id):
    appointment = Appointment.find_by_id(appointment_id)
    if not appointment:
        raise ResourceNotFoundError('Unknown path')
    if appointment.dept_code not in _dept_codes_with_scheduler_privilege():
        raise ForbiddenRequestError(f'You are unauthorized to manage {appointment.dept_code} appointments.')
    if not appointment.status_change_available():
        raise BadRequestError(appointment.to_api_json(current_user.get_id()))
    params = request.get_json()
    advisor_attrs = _advisor_attrs_for_uid(params.get('advisorUid'))
    if not advisor_attrs:
        raise BadRequestError('Appointment reservation requires valid "advisorUid"')
    Appointment.check_in(
        appointment_id=appointment_id,
        checked_in_by=current_user.get_id(),
        advisor_attrs=advisor_attrs,
    )
    return Response(status=200)