Skip to content

Commit e3d191f

Browse files
authored
Merge pull request #602 from ComputerScienceHouse/bootstrap-5
Bootstrap 5
2 parents 18ea5d3 + b913e68 commit e3d191f

86 files changed

Lines changed: 4338 additions & 5340 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.env.example‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CONDITIONAL_DEBUG=true
2+
CONDITIONAL_HOST_NAME="localhost:8080"
3+
CONDITIONAL_SERVER_NAME="localhost:8080"
4+
CONDITIONAL_IP="0.0.0.0"
5+
CONDITIONAL_PORT=8080
6+
CONDITIONAL_PROFILING=false # change this to true if you want to see function call times
7+
CONDITIONAL_LDAP_BIND_DN="uid=<you>,cn=users,cn=accounts,dc=csh,dc=rit,dc=edu"
8+
CONDITIONAL_LDAP_BIND_PW=
9+
CONDITIONAL_OIDC_ISSUER="https://sso.csh.rit.edu/auth/realms/csh"
10+
CONDITIONAL_OIDC_CLIENT_ID=develop
11+
CONDITIONAL_OIDC_CLIENT_SECRET=
12+
CONDITIONAL_OIDC_CLIENT_REDIRECT_URI="http://localhost:8080/redirect_uri"
13+
CONDITIONAL_OIDC_CLIENT_LOGOUT="http://localhost:8080/logout"

‎README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ python -m gunicorn
7070

7171
## Config
7272

73-
You must create `config.py` in the top-level directory with the appropriate credentials for the application to run. See `config.env.py` for an example.
73+
Either copy `.env.example` to `.env` or `config.env.py` to `config.py`, and change the variables in the newly copied file accordingly. The only three variables you should need to change are:
74+
- LDAP_BIND_DN, replacing `<you>` for your username
75+
- LDAP_BIND_PW, your password
76+
- OIDC_CLIENT_SECRET, from the Wiki
7477

7578
### Add OIDC Config
7679
Reach out to an RTP to get OIDC credentials that will allow you to develop locally behind OIDC auth

‎conditional/blueprints/attendance.py‎

Lines changed: 82 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ def get_all_members(user_dict=None):
3636
log.info('Retrieve Technical Seminar Attendance List')
3737

3838
members = ldap.get_group_member_attributes(groups=['current_student'],
39-
excluded_groups=[], attributes=['uid', 'displayName'])
39+
attributes=['uid', 'displayName'])
4040

4141
named_members = [
4242
{
43-
'display': f.name,
43+
'label': f.name,
4444
'value': f.id,
4545
'freshman': True
4646
} for f in FreshmanAccount.query.filter(
@@ -49,7 +49,7 @@ def get_all_members(user_dict=None):
4949
for account in members:
5050
named_members.append(
5151
{
52-
'display': account['displayName'],
52+
'label': account['displayName'],
5353
'value': account['uid'],
5454
'freshman': False
5555
})
@@ -66,7 +66,7 @@ def get_non_alumni_non_coop(internal=False, user_dict=None):
6666

6767
# Get all active members as a base house meeting attendance.
6868
active_members = ldap.get_group_member_attributes(groups=['active'],
69-
excluded_groups=[], attributes=['uid', 'displayName'])
69+
attributes=['uid', 'displayName'])
7070

7171
if datetime.today() < datetime(start_of_year().year, 12, 31):
7272
semester = 'Fall'
@@ -79,7 +79,7 @@ def get_non_alumni_non_coop(internal=False, user_dict=None):
7979

8080
eligible_members = [
8181
{
82-
'display': f.name,
82+
'label': f.name,
8383
'value': f.id,
8484
'freshman': True
8585
} for f in FreshmanAccount.query.filter(
@@ -92,7 +92,7 @@ def get_non_alumni_non_coop(internal=False, user_dict=None):
9292

9393
eligible_members.append(
9494
{
95-
'display': account['displayName'],
95+
'label': account['displayName'],
9696
'value': account['uid'],
9797
'freshman': False
9898
})
@@ -112,12 +112,11 @@ def get_non_alumni(user_dict=None):
112112

113113
current_students = ldap.get_group_member_attributes(
114114
groups=['current_student'],
115-
excluded_groups=[],
116115
attributes=['uid', 'displayName', 'nsAccountLock'])
117116

118117
eligible_members = [
119118
{
120-
'display': f.name,
119+
'label': f.name,
121120
'value': f.id,
122121
'freshman': True
123122
} for f in FreshmanAccount.query.filter(
@@ -129,7 +128,7 @@ def get_non_alumni(user_dict=None):
129128

130129
eligible_members.append(
131130
{
132-
'display': account['displayName'],
131+
'label': account['displayName'],
133132
'value': account['uid'],
134133
'freshman': False
135134
})
@@ -171,10 +170,14 @@ def display_attendance_hm(user_dict=None):
171170
if not user_dict_is_eval_director(user_dict):
172171
return redirect("/dashboard")
173172

173+
members = get_non_alumni_non_coop(internal=True)
174+
175+
print(members)
176+
174177
return render_template('attendance_hm.html',
175178
username=user_dict['username'],
176179
date=datetime.now().strftime("%Y-%m-%d"),
177-
members=get_non_alumni_non_coop(internal=True))
180+
members=members)
178181

179182

180183
@attendance_bp.route('/attendance/adhoc_history', methods=['GET'])
@@ -394,53 +397,73 @@ def alter_house_excuse(uid, hid, user_dict=None):
394397
@auth.oidc_auth("default")
395398
@get_user
396399
def attendance_history(user_dict=None):
400+
member_names = { member['uid']: member['displayName']
401+
for member in ldap.get_group_member_attributes(groups=['current_student'],
402+
attributes=['uid', 'displayName']) }
403+
404+
def get_member_name(uid):
405+
if uid in member_names:
406+
return member_names[uid]
407+
408+
name = ldap_get_member(uid).displayName
409+
member_names[uid] = name
410+
return name
397411

398412
def get_meeting_attendees(meeting_id):
399-
attendees = [ldap_get_member(a.uid).displayName for a in
413+
attendees = [get_member_name(a.uid) for a in
400414
MemberCommitteeAttendance.query.filter(
401415
MemberCommitteeAttendance.meeting_id == meeting_id).all()]
402416

403-
for freshman in [a.fid for a in
417+
freshmen_attendees = [a.fid for a in
404418
FreshmanCommitteeAttendance.query.filter(
405-
FreshmanCommitteeAttendance.meeting_id == meeting_id).all()]:
419+
FreshmanCommitteeAttendance.meeting_id == meeting_id).all()]
420+
421+
for freshman in freshmen_attendees:
406422
attendees.append(FreshmanAccount.query.filter(
407423
FreshmanAccount.id == freshman).first().name)
424+
408425
return attendees
409426

410427
def get_seminar_attendees(meeting_id):
411-
attendees = [ldap_get_member(a.uid).displayName for a in
428+
attendees = [get_member_name(a.uid) for a in
412429
MemberSeminarAttendance.query.filter(
413430
MemberSeminarAttendance.seminar_id == meeting_id).all()]
414-
415-
for freshman in [a.fid for a in
431+
freshmen_attendees = [a.fid for a in
416432
FreshmanSeminarAttendance.query.filter(
417-
FreshmanSeminarAttendance.seminar_id == meeting_id).all()]:
433+
FreshmanSeminarAttendance.seminar_id == meeting_id).all()]
434+
435+
for freshman in freshmen_attendees:
418436
attendees.append(FreshmanAccount.query.filter(
419437
FreshmanAccount.id == freshman).first().name)
438+
420439
return attendees
421440

422441
def get_seminar_hosts(meeting_id):
423-
hosts = [ldap_get_member(a.uid).displayName for a in
442+
hosts = [get_member_name(a.uid) for a in
424443
MemberSeminarHost.query.filter(
425444
MemberSeminarHost.seminar_id == meeting_id).all()]
426445

427-
for freshman in [a.fid for a in
446+
freshmen_hosts = [a.fid for a in
428447
FreshmanSeminarHost.query.filter(
429-
FreshmanSeminarHost.seminar_id == meeting_id).all()]:
448+
FreshmanSeminarHost.seminar_id == meeting_id).all()]
449+
450+
for freshman in freshmen_hosts:
430451
hosts.append(FreshmanAccount.query.filter(
431452
FreshmanAccount.id == freshman).first().name)
453+
432454
return hosts
433455

434456
log = logger.new(request=request, auth_dict=user_dict)
435457

436458
if not user_dict_is_eboard(user_dict):
437459
return jsonify({"success": False, "error": "Not EBoard"}), 403
438460

439-
440461
page = request.args.get('page', 1)
462+
page_size = int(request.args.get('size', 10))
463+
441464
log.info('View Past Attendance Submitions')
442-
offset = 0 if int(page) == 1 else ((int(page)-1)*10)
443-
limit = int(page)*10
465+
offset = 0 if int(page) == 1 else ((int(page) - 1) * 10)
466+
limit = int(page) * page_size
444467
all_cm = [{"id": m.id,
445468
"name": m.committee,
446469
"adhoc": m.adhoc,
@@ -451,6 +474,7 @@ def get_seminar_hosts(meeting_id):
451474
} for m in CommitteeMeeting.query.filter(
452475
CommitteeMeeting.timestamp > start_of_year(),
453476
CommitteeMeeting.approved).all()]
477+
454478
all_ts = [{"id": m.id,
455479
"name": m.name,
456480
"dt_obj": m.timestamp,
@@ -461,6 +485,7 @@ def get_seminar_hosts(meeting_id):
461485
} for m in TechnicalSeminar.query.filter(
462486
TechnicalSeminar.timestamp > start_of_year(),
463487
TechnicalSeminar.approved).all()]
488+
464489
pend_cm = [{"id": m.id,
465490
"name": m.committee,
466491
"adhoc": m.adhoc,
@@ -470,6 +495,7 @@ def get_seminar_hosts(meeting_id):
470495
} for m in CommitteeMeeting.query.filter(
471496
CommitteeMeeting.timestamp > start_of_year(),
472497
CommitteeMeeting.approved == False).all()] # pylint: disable=singleton-comparison
498+
473499
pend_ts = [{"id": m.id,
474500
"name": m.name,
475501
"dt_obj": m.timestamp,
@@ -479,20 +505,47 @@ def get_seminar_hosts(meeting_id):
479505
} for m in TechnicalSeminar.query.filter(
480506
TechnicalSeminar.timestamp > start_of_year(),
481507
TechnicalSeminar.approved == False).all()] # pylint: disable=singleton-comparison
508+
482509
all_meetings = sorted((all_cm + all_ts), key=lambda k: k['dt_obj'], reverse=True)[offset:limit]
483-
if len(all_cm) % 10 != 0:
484-
total_pages = int(len(all_cm) / 10) + 1
510+
if len(all_cm) % page_size != 0:
511+
total_pages = int(len(all_cm) / page_size) + 1
485512
else:
486-
total_pages = int(len(all_cm) / 10)
513+
total_pages = int(len(all_cm) / page_size)
514+
515+
page_size_options = [
516+
{
517+
'value': 10,
518+
'label': '10'
519+
},
520+
{
521+
'value': 25,
522+
'label': '25'
523+
},
524+
{
525+
'value': 50,
526+
'label': '50'
527+
},
528+
{
529+
'value': 100,
530+
'label': '100'
531+
},
532+
{
533+
'value': -1,
534+
'label': 'all'
535+
}
536+
]
537+
538+
selected_page_size = list(filter(lambda opt: opt['value'] == page_size, page_size_options))[0]
539+
487540
return render_template('attendance_history.html',
488541
username=user_dict['username'],
489542
history=all_meetings,
490543
pending_cm=pend_cm,
491544
pending_ts=pend_ts,
492-
all_ts=all_ts,
493545
num_pages=total_pages,
494-
current_page=int(page))
495-
546+
page_size=selected_page_size,
547+
current_page=int(page),
548+
page_sizes=page_size_options)
496549

497550
@attendance_bp.route('/attendance/alter/cm/<cid>', methods=['POST'])
498551
@auth.oidc_auth("default")

‎conditional/blueprints/co_op.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from conditional import db, start_of_year, auth
55
from conditional.models.models import CurrentCoops
6-
from conditional.util.member import req_cm
76
from conditional.util.auth import get_user
87
from conditional.util.flask import render_template
98
from conditional.util.ldap import _ldap_add_member_to_group as ldap_add_member_to_group
@@ -58,7 +57,6 @@ def submit_co_op_form(user_dict=None):
5857
db.session.add(co_op)
5958
db.session.flush()
6059
db.session.commit()
61-
req_cm.cache_clear()
6260

6361
return jsonify({"success": True}), 200
6462

@@ -84,7 +82,6 @@ def delete_co_op(uid, user_dict=None):
8482

8583
db.session.flush()
8684
db.session.commit()
87-
req_cm.cache_clear()
8885

8986
return jsonify({"success": True}), 200
9087

@@ -99,7 +96,7 @@ def display_co_op_management(user_dict=None):
9996
if not user_dict_is_eval_director(user_dict):
10097
return "must be eval director", 403
10198

102-
co_op_list = [(member.semester, member.uid)
99+
co_op_list = [{ 'semester': member.semester, 'uid': member.uid}
103100
for member in CurrentCoops.query.filter(
104101
CurrentCoops.date_created > start_of_year(),
105102
CurrentCoops.semester != "Neither")]

‎conditional/blueprints/dashboard.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def display_dashboard(user_dict=None):
5454
"Active Members": len(ldap_get_active_member_uids())}
5555
# freshman shit
5656
if user_dict_is_intromember(user_dict):
57-
data['freshman'] = get_freshman_data(uid)
57+
data['intro'] = get_freshman_data(uid)
5858
else:
59-
data['freshman'] = None
59+
data['intro'] = None
6060

6161
spring = {}
6262
c_meetings = get_cm(user_dict['account'])
@@ -163,8 +163,9 @@ def display_dashboard(user_dict=None):
163163

164164
data['cm_attendance'] = c_meetings
165165
data['cm_attendance_len'] = len(c_meetings)
166-
data['hm_attendance'] = hm_attendance
167-
data['hm_attendance_len'] = len(hm_attendance)
166+
167+
data['missed_hm'] = hm_attendance
168+
data['missed_hm_len'] = len(hm_attendance)
168169

169170
gatekeep_info = gatekeep_values(uid)
170171
gatekeep_result = 'disenfranchised'

‎conditional/blueprints/gatekeep.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@gatekeep_bp.route('/gatekeep_status/')
1818
@auth.oidc_auth("default")
1919
@get_user
20-
def display_spring_evals(internal=False, user_dict=None):
20+
def display_spring_evals(internal=False, user_dict=None): # pylint: disable-msg=too-many-locals
2121
log = logger.new(request=request, auth_dict=user_dict)
2222
log.info('Display Gatekeep Status Listing')
2323

@@ -88,7 +88,7 @@ def display_spring_evals(internal=False, user_dict=None):
8888
).all()}
8989

9090
gk_members = []
91-
for account in ldap.get_group_member_attributes(groups=['active'], excluded_groups=[], attributes=['uid', 'cn']):
91+
for account in ldap.get_group_member_attributes(groups=['active'], attributes=['uid', 'cn']):
9292
uid = account['uid']
9393
name = account['cn']
9494

@@ -118,10 +118,16 @@ def display_spring_evals(internal=False, user_dict=None):
118118
if passing:
119119
status = 'passed'
120120

121+
status_int = 0
122+
123+
if passing:
124+
status_int = 1
125+
121126
member = {
122127
'name': name,
123128
'uid': uid,
124129
'status': status,
130+
'status_int': status_int,
125131
'committee_meetings': cm_attended_count,
126132
'technical_seminars': ts_attended_count,
127133
'technical_seminars_hosted': ts_hosted_count,
@@ -136,6 +142,7 @@ def display_spring_evals(internal=False, user_dict=None):
136142
gk_members.sort(key=lambda x: x['committee_meetings'], reverse=True)
137143
gk_members.sort(key=lambda x: x['technical_seminars'], reverse=True)
138144
gk_members.sort(key=lambda x: len(x['house_meetings_missed']))
145+
gk_members.sort(key=lambda x: x['status_int'], reverse=True)
139146
# return names in 'first last (username)' format
140147
if internal:
141148
return gk_members

0 commit comments

Comments
 (0)