Exemplo n.º 1
0
def alter_committee_attendance(cid, user_dict=None):
    log = logger.new(request=request, auth_dict=user_dict)
    log.info('Edit Committee Meeting Attendance')

    if not ldap_is_eboard(user_dict['account']):
        return jsonify({"success": False, "error": "Not EBoard"}), 403

    post_data = request.get_json()
    meeting_id = cid
    m_attendees = post_data['members']
    f_attendees = post_data['freshmen']

    FreshmanCommitteeAttendance.query.filter(
        FreshmanCommitteeAttendance.meeting_id == meeting_id).delete()

    MemberCommitteeAttendance.query.filter(
        MemberCommitteeAttendance.meeting_id == meeting_id).delete()

    for m in m_attendees:
        db.session.add(MemberCommitteeAttendance(m, meeting_id))

    for f in f_attendees:
        db.session.add(FreshmanCommitteeAttendance(f, meeting_id))

    db.session.flush()
    db.session.commit()
    return jsonify({"success": True}), 200
Exemplo n.º 2
0
def member_management_upgrade_user():
    log = logger.new(user_name=request.headers.get("x-webauth-user"),
                     request_id=str(uuid.uuid4()))
    log.info('api', action='convert fid to uid entry')

    user_name = request.headers.get('x-webauth-user')

    if not ldap_is_eval_director(user_name):
        return "must be eval director", 403

    post_data = request.get_json()

    fid = post_data['fid']
    uid = post_data['uid']
    signatures_missed = post_data['sigsMissed']

    logger.info('backend',
                action="upgrade freshman-%s to %s sigsMissed: %s" %
                (fid, uid, signatures_missed))
    acct = FreshmanAccount.query.filter(FreshmanAccount.id == fid).first()

    new_acct = FreshmanEvalData(uid, signatures_missed)
    new_acct.eval_date = acct.eval_date

    db.session.add(new_acct)
    for fca in FreshmanCommitteeAttendance.query.filter(
            FreshmanCommitteeAttendance.fid == fid):
        db.session.add(MemberCommitteeAttendance(uid, fca.meeting_id))
        # XXX this might fail horribly #yoloswag
        db.session.delete(fca)

    for fts in FreshmanSeminarAttendance.query.filter(
            FreshmanSeminarAttendance.fid == fid):
        db.session.add(MemberSeminarAttendance(uid, fts.seminar_id))
        # XXX this might fail horribly #yoloswag
        db.session.delete(fts)

    for fhm in FreshmanHouseMeetingAttendance.query.filter(
            FreshmanHouseMeetingAttendance.fid == fid):
        db.session.add(
            MemberHouseMeetingAttendance(uid, fhm.meeting_id, fhm.excuse,
                                         fhm.attendance_status))
        # XXX this might fail horribly #yoloswag
        db.session.delete(fhm)

    if acct.onfloor_status:
        db.session.add(OnFloorStatusAssigned(uid, datetime.now()))

    if acct.room_number:
        ldap_set_roomnumber(uid, acct.room_number)

    # XXX this might fail horribly #yoloswag
    db.session.delete(acct)

    db.session.flush()
    db.session.commit()

    clear_onfloor_members_cache()

    return jsonify({"success": True}), 200
Exemplo n.º 3
0
def submit_committee_attendance(user_dict=None):
    log = logger.new(request=request, auth_dict=user_dict)

    approved = ldap_is_eboard(user_dict['account'])
    post_data = request.get_json()

    committee = post_data['committee']
    m_attendees = post_data['members']
    f_attendees = post_data['freshmen']
    timestamp = post_data['timestamp']

    log.info('Submit {} Meeting Attendance'.format(committee))

    timestamp = datetime.strptime(timestamp, "%Y-%m-%d")
    meeting = CommitteeMeeting(committee, timestamp, approved)

    db.session.add(meeting)
    db.session.flush()
    db.session.refresh(meeting)

    for m in m_attendees:
        log.info('Gave Attendance to {} for {}'.format(m, committee))
        db.session.add(MemberCommitteeAttendance(m, meeting.id))

    for f in f_attendees:
        log.info('Gave Attendance to freshman-{} for {}'.format(f, committee))
        db.session.add(FreshmanCommitteeAttendance(f, meeting.id))

    db.session.commit()
    return jsonify({"success": True}), 200
Exemplo n.º 4
0
def member_management_upgrade_user(user_dict=None):
    log = logger.new(request=request, auth_dict=user_dict)

    if not ldap_is_eval_director(user_dict['account']):
        return "must be eval director", 403

    post_data = request.get_json()

    fid = post_data['fid']
    uid = post_data['uid']
    signatures_missed = post_data['sigsMissed']

    log.info('Upgrade freshman-{} to Account: {}'.format(fid, uid))

    acct = FreshmanAccount.query.filter(
        FreshmanAccount.id == fid).first()

    new_acct = FreshmanEvalData(uid, signatures_missed)
    new_acct.eval_date = acct.eval_date

    db.session.add(new_acct)
    for fca in FreshmanCommitteeAttendance.query.filter(FreshmanCommitteeAttendance.fid == fid):
        db.session.add(MemberCommitteeAttendance(uid, fca.meeting_id))
        db.session.delete(fca)

    for fts in FreshmanSeminarAttendance.query.filter(FreshmanSeminarAttendance.fid == fid):
        db.session.add(MemberSeminarAttendance(uid, fts.seminar_id))
        db.session.delete(fts)

    for fhm in FreshmanHouseMeetingAttendance.query.filter(FreshmanHouseMeetingAttendance.fid == fid):
        # Don't duplicate HM attendance records
        mhm = MemberHouseMeetingAttendance.query.filter(
            MemberHouseMeetingAttendance.meeting_id == fhm.meeting_id).first()
        if mhm is None:
            db.session.add(MemberHouseMeetingAttendance(
                uid, fhm.meeting_id, fhm.excuse, fhm.attendance_status))
        else:
            log.info('Duplicate house meeting attendance! fid: {}, uid: {}, id: {}'.format(
                fid,
                uid,
                fhm.meeting_id))
        db.session.delete(fhm)

    new_account = ldap_get_member(uid)
    if acct.onfloor_status:
        db.session.add(OnFloorStatusAssigned(uid, datetime.now()))
        ldap_set_onfloor(new_account)

    if acct.room_number:
        ldap_set_roomnumber(new_account, acct.room_number)

    db.session.delete(acct)

    db.session.flush()
    db.session.commit()

    clear_members_cache()

    return jsonify({"success": True}), 200
Exemplo n.º 5
0
def submit_committee_attendance():
    log = logger.new(user_name=request.headers.get("x-webauth-user"),
                     request_id=str(uuid.uuid4()))
    log.info('api', action='submit committee meeting attendance')

    user_name = request.headers.get('x-webauth-user')

    if not ldap_is_eboard(user_name):
        return "must be eboard", 403

    post_data = request.get_json()

    committee = post_data['committee']
    m_attendees = post_data['members']
    f_attendees = post_data['freshmen']
    timestamp = post_data['timestamp']

    timestamp = datetime.strptime(timestamp, "%Y-%m-%d")
    meeting = CommitteeMeeting(committee, timestamp)

    db.session.add(meeting)
    db.session.flush()
    db.session.refresh(meeting)

    for m in m_attendees:
        logger.info('backend',
                    action=("gave attendance to %s for %s" % (m, committee)))
        db.session.add(MemberCommitteeAttendance(m, meeting.id))

    for f in f_attendees:
        logger.info('backend',
                    action=("gave attendance to freshman-%s for %s" %
                            (f, committee)))
        db.session.add(FreshmanCommitteeAttendance(f, meeting.id))

    db.session.commit()
    return jsonify({"success": True}), 200