Skip to content

Commit ed3b653

Browse files
Add fid listing to the intro evals page
1 parent 6e96c35 commit ed3b653

File tree

1 file changed

+59
-3
lines changed

1 file changed

+59
-3
lines changed

conditional/blueprints/intro_evals.py

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime
12
import uuid
23
import structlog
34

@@ -6,8 +7,12 @@
67
from conditional.util.ldap import ldap_get_intro_members
78
from conditional.util.ldap import ldap_get_name
89

10+
from conditional.models.models import FreshmanCommitteeAttendance
911
from conditional.models.models import MemberCommitteeAttendance
12+
from conditional.models.models import FreshmanAccount
1013
from conditional.models.models import FreshmanEvalData
14+
from conditional.models.models import FreshmanHouseMeetingAttendance
15+
from conditional.models.models import FreshmanSeminarAttendance
1116
from conditional.models.models import MemberHouseMeetingAttendance
1217
from conditional.models.models import MemberSeminarAttendance
1318
from conditional.models.models import HouseMeeting
@@ -26,17 +31,68 @@ def display_intro_evals(internal=False):
2631
log.info('frontend', action='display intro evals listing')
2732

2833
# get user data
29-
def get_cm_count(member_id):
34+
def get_uid_cm_count(member_id):
3035
return len([a for a in MemberCommitteeAttendance.query.filter(
3136
MemberCommitteeAttendance.uid == member_id)])
3237

38+
def get_fid_cm_count(member_id):
39+
return len([a for a in FreshmanCommitteeAttendance.query.filter(
40+
FreshmanCommitteeAttendance.fid == member_id)])
41+
3342
user_name = None
3443
if not internal:
3544
user_name = request.headers.get('x-webauth-user')
3645

3746
members = [m['uid'] for m in ldap_get_intro_members()]
3847

3948
ie_members = []
49+
50+
# freshmen who don't have accounts
51+
fids = [f for f in FreshmanAccount.query.filter(
52+
FreshmanAccount.eval_date > datetime.now())]
53+
54+
for fid in fids:
55+
h_meetings = [m.meeting_id for m in
56+
FreshmanHouseMeetingAttendance.query.filter(
57+
FreshmanHouseMeetingAttendance.fid == fid.id
58+
).filter(
59+
FreshmanHouseMeetingAttendance.attendance_status == "Absent"
60+
)]
61+
freshman = {
62+
'name': fid.name,
63+
'uid': fid.id,
64+
'eval_date': fid.eval_date.strftime("%Y-%m-%d"),
65+
'signatures_missed': 65535,
66+
'committee_meetings': get_fid_cm_count(fid.id),
67+
'committee_meetings_passed': get_fid_cm_count(fid.id) >= 10,
68+
'house_meetings_missed':
69+
[
70+
{
71+
"date": m.date.strftime("%Y-%m-%d"),
72+
"reason":
73+
FreshmanHouseMeetingAttendance.query.filter(
74+
FreshmanHouseMeetingAttendance.fid == fid.id).filter(
75+
FreshmanHouseMeetingAttendance.meeting_id == m.id).first().excuse
76+
}
77+
for m in HouseMeeting.query.filter(
78+
HouseMeeting.id.in_(h_meetings)
79+
)
80+
],
81+
'technical_seminars':
82+
[s.name for s in TechnicalSeminar.query.filter(
83+
TechnicalSeminar.id.in_(
84+
[a.seminar_id for a in FreshmanSeminarAttendance.query.filter(
85+
FreshmanSeminarAttendance.fid == fid.id)]
86+
))
87+
],
88+
'social_events': '',
89+
'freshman_project': "Pending",
90+
'comments': 'Does not have account yet',
91+
'status': "Pending"
92+
}
93+
ie_members.append(freshman)
94+
95+
# freshmen who have accounts
4096
for member_uid in members:
4197
uid = member_uid[0].decode('utf-8')
4298
freshman_data = FreshmanEvalData.query.filter(
@@ -57,8 +113,8 @@ def get_cm_count(member_id):
57113
'uid': uid,
58114
'eval_date': freshman_data.eval_date.strftime("%Y-%m-%d"),
59115
'signatures_missed': freshman_data.signatures_missed,
60-
'committee_meetings': get_cm_count(uid),
61-
'committee_meetings_passed': get_cm_count(uid) >= 10,
116+
'committee_meetings': get_uid_cm_count(uid),
117+
'committee_meetings_passed': get_uid_cm_count(uid) >= 10,
62118
'house_meetings_missed':
63119
[
64120
{

0 commit comments

Comments
 (0)