diff --git a/conditional/blueprints/attendance.py b/conditional/blueprints/attendance.py index 62135f2c..2d0e5570 100644 --- a/conditional/blueprints/attendance.py +++ b/conditional/blueprints/attendance.py @@ -177,6 +177,23 @@ def display_attendance_hm(user_dict=None): members=get_non_alumni_non_coop(internal=True)) +@attendance_bp.route('/attendance/adhoc_history', methods=['GET']) +@auth.oidc_auth("default") +@get_user +def get_adhoc_history(user_dict=None): + log = logger.new(request=request, auth_dict=user_dict) + log.info('Retrieve Ad-Hoc Committee Meeting History') + + adhoc_meetings = db.session.query(CommitteeMeeting.adhoc).filter( + CommitteeMeeting.adhoc.isnot(None), + CommitteeMeeting.timestamp > start_of_year() + ).distinct().all() + + adhoc_names = [row[0] for row in adhoc_meetings] + + return jsonify({"adhocs": adhoc_names}), 200 + + @attendance_bp.route('/attendance/submit/cm', methods=['POST']) @auth.oidc_auth("default") @get_user @@ -190,11 +207,12 @@ def submit_committee_attendance(user_dict=None): m_attendees = post_data['members'] f_attendees = post_data['freshmen'] timestamp = post_data['timestamp'] + adhoc = post_data.get('adhoc', None) log.info(f'Submit {committee} Meeting Attendance') timestamp = datetime.strptime(timestamp, "%Y-%m-%d") - meeting = CommitteeMeeting(committee, timestamp, approved) + meeting = CommitteeMeeting(committee, adhoc, timestamp, approved) db.session.add(meeting) db.session.flush() @@ -425,6 +443,7 @@ def get_seminar_hosts(meeting_id): limit = int(page)*10 all_cm = [{"id": m.id, "name": m.committee, + "adhoc": m.adhoc, "dt_obj": m.timestamp, "date": m.timestamp.strftime("%a %m/%d/%Y"), "attendees": get_meeting_attendees(m.id), @@ -444,6 +463,7 @@ def get_seminar_hosts(meeting_id): TechnicalSeminar.approved).all()] pend_cm = [{"id": m.id, "name": m.committee, + "adhoc": m.adhoc, "dt_obj": m.timestamp, "date": m.timestamp.strftime("%a %m/%d/%Y"), "attendees": get_meeting_attendees(m.id) diff --git a/conditional/models/docs.md b/conditional/models/docs.md index 33697e10..1fb7e471 100644 --- a/conditional/models/docs.md +++ b/conditional/models/docs.md @@ -33,6 +33,7 @@ This table stores a list of committee meetings. | ------------- | ------------- | ------------------- | | `id` | `INTEGER` | Autoincrementing primary key. | `committee` | `ENUM` | The committee the meeting belongs to. +| `adhoc` | `STRING` | The Ad-Hoc committee's name when applicable. | `timestamp` | `TIMESTAMP` | The date and time of the meeting. | `active` | `BOOLEAN` | Whether the meeting applies to the current year or not. diff --git a/conditional/models/models.py b/conditional/models/models.py index 51b58cc6..604ea423 100644 --- a/conditional/models/models.py +++ b/conditional/models/models.py @@ -58,12 +58,14 @@ class CommitteeMeeting(db.Model): 'R&D', 'House Improvements', 'Financial', 'Public Relations', 'Chairman', 'Ad-Hoc', name="committees_enum"), nullable=False) + adhoc = Column(String, nullable=True) timestamp = Column(DateTime, nullable=False) approved = Column(Boolean, nullable=False) active = Column(Boolean) - def __init__(self, committee, timestamp, approved): + def __init__(self, committee, adhoc, timestamp, approved): self.committee = committee + self.adhoc = adhoc self.timestamp = timestamp self.approved = approved self.active = True diff --git a/conditional/templates/attendance_cm.html b/conditional/templates/attendance_cm.html index 80c26ea1..cb012b6c 100644 --- a/conditional/templates/attendance_cm.html +++ b/conditional/templates/attendance_cm.html @@ -30,13 +30,27 @@
{{meeting["date"]}}
{{meeting["date"]}}