diff --git a/conditional/blueprints/attendance.py b/conditional/blueprints/attendance.py index 78a20e62..fe1bc94b 100644 --- a/conditional/blueprints/attendance.py +++ b/conditional/blueprints/attendance.py @@ -391,7 +391,7 @@ def get_seminar_attendees(meeting_id): user_name = request.headers.get('x-webauth-user') account = ldap_get_member(user_name) if not ldap_is_eboard(account): - return "must be eboard", 403 + return jsonify({"success": False, "error": "Not EBoard"}), 403 page = request.args.get('page', 1) @@ -455,7 +455,7 @@ def alter_committee_attendance(cid): account = ldap_get_member(user_name) if not ldap_is_eboard(account): - return "must be eboard", 403 + return jsonify({"success": False, "error": "Not EBoard"}), 403 post_data = request.get_json() meeting_id = cid @@ -488,7 +488,7 @@ def alter_seminar_attendance(sid): account = ldap_get_member(user_name) if not ldap_is_eboard(account): - return "must be eboard", 403 + return jsonify({"success": False, "error": "Not EBoard"}), 403 post_data = request.get_json() meeting_id = sid @@ -528,7 +528,7 @@ def get_cm_attendees(sid): attendees.append(freshman) return jsonify({"attendees": attendees}), 200 - elif request.method == 'DELETE': + else: log = logger.new(request=request) log.info('Delete Technical Seminar {}'.format(sid)) @@ -536,7 +536,7 @@ def get_cm_attendees(sid): account = ldap_get_member(user_name) if not ldap_is_eboard(account): - return "must be eboard", 403 + return jsonify({"success": False, "error": "Not EBoard"}), 403 FreshmanSeminarAttendance.query.filter( FreshmanSeminarAttendance.seminar_id == sid).delete() @@ -567,7 +567,7 @@ def get_ts_attendees(cid): attendees.append(freshman) return jsonify({"attendees": attendees}), 200 - elif request.method == 'DELETE': + else: log = logger.new(request=request) log.info('Delete Committee Meeting {}'.format(cid)) @@ -575,7 +575,7 @@ def get_ts_attendees(cid): account = ldap_get_member(user_name) if not ldap_is_eboard(account): - return "must be eboard", 403 + return jsonify({"success": False, "error": "Not EBoard"}), 403 FreshmanCommitteeAttendance.query.filter( FreshmanCommitteeAttendance.meeting_id == cid).delete() @@ -599,7 +599,7 @@ def approve_cm(cid): account = ldap_get_member(user_name) if not ldap_is_eboard(account): - return "must be eboard", 403 + return jsonify({"success": False, "error": "Not EBoard"}), 403 CommitteeMeeting.query.filter( CommitteeMeeting.id == cid).first().approved = True @@ -618,7 +618,7 @@ def approve_ts(sid): account = ldap_get_member(user_name) if not ldap_is_eboard(account): - return "must be eboard", 403 + return jsonify({"success": False, "error": "Not EBoard"}), 403 TechnicalSeminar.query.filter( TechnicalSeminar.id == sid).first().approved = True diff --git a/conditional/blueprints/cache_management.py b/conditional/blueprints/cache_management.py index 907b8a8b..3f179331 100644 --- a/conditional/blueprints/cache_management.py +++ b/conditional/blueprints/cache_management.py @@ -2,6 +2,8 @@ import signal import structlog +from flask import Blueprint, request, redirect + from conditional.util.ldap import ldap_is_eval_director from conditional.util.ldap import ldap_is_rtp @@ -17,8 +19,6 @@ from conditional.util.member import get_onfloor_members -from flask import Blueprint, request, redirect - logger = structlog.get_logger() cache_bp = Blueprint('cache_bp', __name__) diff --git a/conditional/blueprints/dashboard.py b/conditional/blueprints/dashboard.py index fe60b2bd..73bd2340 100644 --- a/conditional/blueprints/dashboard.py +++ b/conditional/blueprints/dashboard.py @@ -17,7 +17,7 @@ from conditional.util.housing import get_queue_position from conditional.util.flask import render_template -from conditional.util.member import get_freshman_data, get_voting_members, get_cm, get_hm +from conditional.util.member import get_freshman_data, get_voting_members, get_cm, get_hm, req_cm from conditional import start_of_year @@ -58,6 +58,7 @@ def display_dashboard(): spring = {} c_meetings = get_cm(member) spring['committee_meetings'] = len(c_meetings) + spring['req_meetings'] = req_cm(member) h_meetings = [(m.meeting_id, m.attendance_status) for m in get_hm(member)] spring['hm_missed'] = len([h for h in h_meetings if h[1] == "Absent"]) eval_entry = SpringEval.query.filter(SpringEval.uid == member.uid, diff --git a/conditional/blueprints/major_project_submission.py b/conditional/blueprints/major_project_submission.py index e8fd6be7..300b80de 100644 --- a/conditional/blueprints/major_project_submission.py +++ b/conditional/blueprints/major_project_submission.py @@ -2,6 +2,8 @@ from flask import Blueprint, request, jsonify, redirect +from sqlalchemy import desc + from conditional.models.models import MajorProject from conditional.util.ldap import ldap_is_eval_director @@ -9,7 +11,6 @@ from conditional.util.flask import render_template from conditional import db, start_of_year -from sqlalchemy import desc logger = structlog.get_logger() diff --git a/conditional/blueprints/spring_evals.py b/conditional/blueprints/spring_evals.py index 620a7164..326002e3 100644 --- a/conditional/blueprints/spring_evals.py +++ b/conditional/blueprints/spring_evals.py @@ -11,7 +11,7 @@ from conditional.util.flask import render_template -from conditional.util.member import get_cm, get_hm +from conditional.util.member import get_cm, get_hm, req_cm from conditional import db, start_of_year @@ -55,6 +55,7 @@ def display_spring_evals(internal=False): 'uid': uid, 'status': spring_entry.status, 'committee_meetings': len(get_cm(account)), + 'req_meetings': req_cm(account), 'house_meetings_missed': [ { diff --git a/conditional/templates/dashboard.html b/conditional/templates/dashboard.html index bc37db88..0b57fee6 100644 --- a/conditional/templates/dashboard.html +++ b/conditional/templates/dashboard.html @@ -127,9 +127,9 @@

Membership Evaluations Directorship Meetings - {% if spring['committee_meetings'] >= 25 %} + {% if spring['committee_meetings'] >= spring['req_meetings'] %} {% else %} - {% endif %} {{ spring['committee_meetings'] }} / 25 + {% endif %} {{ spring['committee_meetings'] }} / {{ spring['req_meetings'] }} diff --git a/conditional/templates/spring_eval_slideshow.html b/conditional/templates/spring_eval_slideshow.html index 23ba82b8..9104ebb4 100644 --- a/conditional/templates/spring_eval_slideshow.html +++ b/conditional/templates/spring_eval_slideshow.html @@ -15,7 +15,7 @@

{{m['name']}}

- {% set committee_meetings_passed = m['committee_meetings'] >= 25 %} + {% set committee_meetings_passed = m['committee_meetings'] >= m['req_meetings'] %}

{{m['committee_meetings']}}

diff --git a/conditional/templates/spring_evals.html b/conditional/templates/spring_evals.html index 80f8ef2c..02fcd5bf 100644 --- a/conditional/templates/spring_evals.html +++ b/conditional/templates/spring_evals.html @@ -47,15 +47,15 @@
{{m['uid']}}
- {% if m['committee_meetings'] < 25 %} + {% if m['committee_meetings'] < m['req_meetings'] %}
Directorship Meetings - {{m['committee_meetings']}} / 25 + {{m['committee_meetings']}} / {{m['req_meetings']}}
{% else %}
Directorship Meetings - {{m['committee_meetings']}} / 25 + {{m['committee_meetings']}} / {{m['req_meetings']}}
{% endif %} @@ -208,7 +208,7 @@

Major Projects

{% endif %} - {% if m['committee_meetings'] < 25 %} + {% if m['committee_meetings'] < m['req_meetings'] %} {{m['committee_meetings']}} {% else %} {{m['committee_meetings']}} diff --git a/conditional/util/ldap.py b/conditional/util/ldap.py index 443c877d..6b3d7de2 100644 --- a/conditional/util/ldap.py +++ b/conditional/util/ldap.py @@ -31,6 +31,7 @@ def _ldap_is_member_of_directorship(account, directorship): for director in directors: if director.uid == account.uid: return True + return False @lru_cache(maxsize=1024) diff --git a/conditional/util/member.py b/conditional/util/member.py index 8bc6d691..cad2b387 100644 --- a/conditional/util/member.py +++ b/conditional/util/member.py @@ -147,3 +147,13 @@ def get_hm(member, only_absent=False): if only_absent: h_meetings = h_meetings.filter(MemberHouseMeetingAttendance.attendance_status == "Absent") return h_meetings + +def req_cm(member): + # Get the number of required committee meetings based on if the member + # is going on co-op in the current operating session. + co_op = CurrentCoops.query.filter( + CurrentCoops.uid == member.uid, + CurrentCoops.date_created > start_of_year()).first() + if co_op: + return 15 + return 30 diff --git a/requirements.txt b/requirements.txt index 32586b08..068a5218 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,26 @@ -Flask -itsdangerous -Jinja2 -MarkupSafe -csh_ldap -SQLAlchemy -Werkzeug -structlog -flask_sqlalchemy -flask_migrate -pylint -#psycopg2 -raven[flask] +alembic==0.9.6 +astroid==1.6.0 +blinker==1.4 +click==6.7 +csh-ldap==1.2.4.dev41 +Flask==0.12.2 +Flask-Migrate==2.1.1 +Flask-SQLAlchemy==2.3.2 +isort==4.2.15 +itsdangerous==0.24 +Jinja2==2.9.6 +lazy-object-proxy==1.3.1 +Mako==1.0.7 +MarkupSafe==1.0 +mccabe==0.6.1 +psycopg2==2.7.3.2 +pyldap==2.4.37 +pylint==1.8.1 +python-dateutil==2.6.1 +python-editor==1.0.3 +raven==6.3.0 +six==1.11.0 +SQLAlchemy==1.1.15 +structlog==17.2.0 +Werkzeug==0.12.2 +wrapt==1.10.11