Пример #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
Пример #2
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
Пример #3
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