Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion conditional/blueprints/attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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),
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions conditional/models/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 3 additions & 1 deletion conditional/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions conditional/templates/attendance_cm.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,27 @@ <h3 class="page-title">Meeting Attendance</h3>
</div>
</div>
</div>
<!-- Ad-Hoc Name -->
<div class="row" id="adhoc-row" style="display: none;">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="panel panel-default">
<div class="panel-body" style="padding-top:10px;">
<div class="form-group">
<label for="adhoc" class="control-label" id="adhocLabel">Ad-Hoc Name</label>
<input type="text" name="adhoc" class="form-control" data-src="adhoc_history" data-follow="select[name=committee]" data-parent="adhoc-row" data-module="adhoc" list="adhoc-options" placeholder="Enter the Ad-Hoc name here."/>
<datalist id="adhoc-options"></datalist>
</div>
</div>
</div>
</div>
</div>
<!-- Date -->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="panel panel-default">
<div class="panel-body" style="padding-top:10px;">
<div class="form-group is-empty">
<label for="date" class=" control-label">Date</label>
<label for="date" class="control-label">Date</label>
<input type="text" name="date" class="form-control" value="{{date}}" data-module="datepicker"/>
</div>
</div>
Expand All @@ -49,7 +63,7 @@ <h3 class="page-title">Meeting Attendance</h3>
<div class="panel panel-default">
<div class="panel-body" style="padding-top:20px;">
<div class="form-group is-empty">
<label for="attendees" class=" control-label" id="attendeeLabel">Attendees</label>
<label for="attendees" class="control-label" id="attendeeLabel">Attendees</label>
<input type="text" name="attendees" class="form-control" data-module="memberSelect" data-src="cm_members"/>
</div>
</div>
Expand Down
14 changes: 12 additions & 2 deletions conditional/templates/attendance_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ <h3 class="page-title">Pending Submissions</h3>
<div class="panel-body eval-panel">
<div class="container-fluid">
<div class="col-xs-12 col-sm-3 vcenter">
<h5>{{meeting["name"]}}</h5>
<h5 class="text-truncate">
{{meeting["name"]}}
{% if meeting["name"] == "Ad-Hoc" %}
- {{meeting["adhoc"]}}
{% endif %}
</h5>
<p>{{meeting["date"]}}<p>
</div><!--
--><div class="com-xs-12 col-sm-7 vcenter">
Expand Down Expand Up @@ -69,7 +74,12 @@ <h3 class="page-title">Attendance History</h3>
<div class="panel-body eval-panel">
<div class="container-fluid">
<div class="col-xs-12 col-sm-3 vcenter">
<h5>{{meeting["name"]}}</h5>
<h5 class="text-truncate">
{{meeting["name"]}}
{% if meeting["name"] == "Ad-Hoc" %}
- {{meeting["adhoc"]}}
{% endif %}
</h5>
<p>{{meeting["date"]}}<p>
</div><!--
--><div class="com-xs-12 col-sm-7 vcenter">
Expand Down
7 changes: 6 additions & 1 deletion conditional/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,12 @@ <h3 class="panel-title">Directorship Meeting Attendance</h3>
<tbody>
{% for meeting in cm_attendance %}
<tr>
<td>{{meeting['committee']}}</td>
<td class="text-truncate">
{{meeting['committee']}}
{% if meeting['committee'] == "Ad-Hoc" %}
- {{meeting['adhoc']}}
{% endif %}
</td>
<td>{{meeting['timestamp'].strftime('%Y-%m-%d')}}</td>
</tr>
{% endfor %}
Expand Down
6 changes: 4 additions & 2 deletions conditional/util/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def get_cm(member):
).with_entities(
MemberCommitteeAttendance.uid,
CommitteeMeeting.timestamp,
CommitteeMeeting.committee
CommitteeMeeting.committee,
CommitteeMeeting.adhoc
).filter(
CommitteeMeeting.timestamp > start_of_year(),
MemberCommitteeAttendance.uid == member.uid,
Expand All @@ -84,7 +85,8 @@ def get_cm(member):
c_meetings = [{
"uid": cm.uid,
"timestamp": cm.timestamp,
"committee": cm.committee
"committee": cm.committee,
"adhoc": cm.adhoc
} for cm in query_result]

return c_meetings
Expand Down
12 changes: 12 additions & 0 deletions frontend/javascript/exceptions/adhocException.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Enumify } from 'enumify';

export default class AdHocException extends Enumify {
NO_FOLLOW_ATTRIBUTE = AdHocException("Unable to find follow query selector for adhoc module");
NO_PARENT_ATTRIBUTE = AdHocException("Unable to find parent element id for adhoc module");
_ = AdHocException.closeEnum();

constructor(message) {
super();
this.message = message;
}
}
68 changes: 68 additions & 0 deletions frontend/javascript/modules/adhoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* global fetch */
import "whatwg-fetch";
import "@selectize/selectize";
import FetchUtil from "../utils/fetchUtil";
import Exception from "../exceptions/exception";
import AttendanceException from "../exceptions/attendanceException";
import AdHocException from "../exceptions/adhocException";
import FetchException from "../exceptions/fetchException";

export default class AdHoc {
constructor(element) {
this.element = element;
this.dataSrc = element.dataset.src;
this.followSelector = element.dataset.follow;
this.parentId = element.dataset.parent;
this.list = element.list;

if (!this.followSelector) {
throw new Exception(AdHocException.NO_FOLLOW_ATTRIBUTE);
} else if (!this.parentId) {
throw new Exception(AdHocException.NO_PARENT_ATTRIBUTE);
}

if (this.dataSrc) {
fetch('/attendance/' + this.dataSrc, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
credentials: 'same-origin'
})
.then(FetchUtil.checkResponse)
.then(FetchUtil.parseJSON)
.then(response => {
response.adhocs.forEach(item => {
const option = document.createElement('option');
option.value = item
element.list.appendChild(option);
});
this.render();
})
.catch(error => {
throw new Exception(FetchException.REQUEST_FAILED, error);
});
} else {
throw new Exception(AttendanceException.NO_SRC_ATTRIBUTE);
}
}

render() {
const parentElem = document.getElementById(this.parentId);

document.querySelectorAll(this.followSelector).forEach(input => {
if (input.value === "Ad-Hoc") {
parentElem.style.display = "block";
}

input.addEventListener("change", event => {
if (event.target.value === "Ad-Hoc") {
parentElem.style.display = "block";
} else {
parentElem.style.display = "none";
}
});
});
}
}
5 changes: 5 additions & 0 deletions frontend/javascript/modules/attendanceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export default class AttendanceForm {
e.preventDefault();
let payload = {};


if (this.fields.committee.value === "Ad-Hoc") {
this.fields.adhoc = this.form.elements.adhoc;
}

Object.keys(this.fields).forEach(field => {
if (field === "attendees") {
let membersSplit = MemberUtil.splitFreshmenUpperclassmen(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""add adhoc column to committee_meetings

Revision ID: 3f094d78df95
Revises: 5e8db174ce30
Create Date: 2026-09-30 02:03:08.999839

"""

# revision identifiers, used by Alembic.
revision = '3f094d78df95'
down_revision = '5e8db174ce30'

from alembic import op
import sqlalchemy as sa


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('committee_meetings', schema=None) as batch_op:
batch_op.add_column(sa.Column('adhoc', sa.String(), nullable=True))

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('committee_meetings', schema=None) as batch_op:
batch_op.drop_column('adhoc')

# ### end Alembic commands ###
Loading