def alter_seminar_attendance(sid, user_dict=None): log = logger.new(request=request, auth_dict=user_dict) log.info('Edit Technical Seminar Attendance') if not ldap_is_eboard(user_dict['account']): return jsonify({"success": False, "error": "Not EBoard"}), 403 post_data = request.get_json() meeting_id = sid m_attendees = post_data['members'] f_attendees = post_data['freshmen'] FreshmanSeminarAttendance.query.filter( FreshmanSeminarAttendance.seminar_id == meeting_id).delete() MemberSeminarAttendance.query.filter( MemberSeminarAttendance.seminar_id == meeting_id).delete() for m in m_attendees: db.session.add(MemberSeminarAttendance(m, meeting_id)) for f in f_attendees: db.session.add(FreshmanSeminarAttendance(f, meeting_id)) db.session.flush() db.session.commit() return jsonify({"success": True}), 200
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
def submit_seminar_attendance(user_dict=None): log = logger.new(request=request, auth_dict=user_dict) log.info('Submit Technical Seminar Attendance') approved = ldap_is_eboard(user_dict['account']) post_data = request.get_json() seminar_name = post_data['name'] m_attendees = post_data['members'] f_attendees = post_data['freshmen'] timestamp = post_data['timestamp'] timestamp = datetime.strptime(timestamp, "%Y-%m-%d") seminar = TechnicalSeminar(seminar_name, timestamp, approved) db.session.add(seminar) db.session.flush() db.session.refresh(seminar) for m in m_attendees: log.info('Gave Attendance to {} for {}'.format(m, seminar_name)) db.session.add(MemberSeminarAttendance(m, seminar.id)) for f in f_attendees: log.info('Gave Attendance to freshman-{} for {}'.format( f, seminar_name)) db.session.add(FreshmanSeminarAttendance(f, seminar.id)) db.session.commit() return jsonify({"success": True}), 200
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
def submit_seminar_attendance(): log = logger.new(user_name=request.headers.get("x-webauth-user"), request_id=str(uuid.uuid4())) log.info('api', action='submit technical seminar 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() seminar_name = post_data['name'] m_attendees = post_data['members'] f_attendees = post_data['freshmen'] timestamp = post_data['timestamp'] timestamp = datetime.strptime(timestamp, "%Y-%m-%d") seminar = TechnicalSeminar(seminar_name, timestamp) db.session.add(seminar) db.session.flush() db.session.refresh(seminar) for m in m_attendees: logger.info('backend', action=("gave attendance to %s for %s" % (m, seminar_name))) db.session.add(MemberSeminarAttendance(m, seminar.id)) for f in f_attendees: logger.info('backend', action=("gave attendance to freshman-%s for %s" % (f, seminar_name))) db.session.add(FreshmanSeminarAttendance(f, seminar.id)) db.session.commit() return jsonify({"success": True}), 200