Skip to content

Commit

Permalink
Merge pull request #165 from ComputerScienceHouse/develop
Browse files Browse the repository at this point in the history
Conditional 1.6.1
  • Loading branch information
mbillow authored Jan 6, 2018
2 parents 276b093 + b579158 commit bdb6d21
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 34 deletions.
18 changes: 9 additions & 9 deletions conditional/blueprints/attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -528,15 +528,15 @@ 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))

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

FreshmanSeminarAttendance.query.filter(
FreshmanSeminarAttendance.seminar_id == sid).delete()
Expand Down Expand Up @@ -567,15 +567,15 @@ 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))

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

FreshmanCommitteeAttendance.query.filter(
FreshmanCommitteeAttendance.meeting_id == cid).delete()
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions conditional/blueprints/cache_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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__)

Expand Down
3 changes: 2 additions & 1 deletion conditional/blueprints/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion conditional/blueprints/major_project_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

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
from conditional.util.ldap import ldap_get_member
from conditional.util.flask import render_template

from conditional import db, start_of_year
from sqlalchemy import desc


logger = structlog.get_logger()
Expand Down
3 changes: 2 additions & 1 deletion conditional/blueprints/spring_evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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':
[
{
Expand Down
4 changes: 2 additions & 2 deletions conditional/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ <h3 class="panel-title">Membership Evaluations
<tr>
<td class="title">Directorship Meetings</td>
<td><span class="pull-right">
{% if spring['committee_meetings'] >= 25 %}
{% if spring['committee_meetings'] >= spring['req_meetings'] %}
<span class="glyphicon glyphicon-ok-sign green"></span> {% else %}
<span class="glyphicon glyphicon-remove-sign red"></span> {% endif %} {{ spring['committee_meetings'] }} / 25</span>
<span class="glyphicon glyphicon-remove-sign red"></span> {% endif %} {{ spring['committee_meetings'] }} / {{ spring['req_meetings'] }}</span>
</td>
</tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion conditional/templates/spring_eval_slideshow.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<h1>{{m['name']}}</h1>
<div class="row">
<div class="col-xs-12 col-md-4">
{% set committee_meetings_passed = m['committee_meetings'] >= 25 %}
{% set committee_meetings_passed = m['committee_meetings'] >= m['req_meetings'] %}
<div class="item{% if committee_meetings_passed %} passed{% endif %}" >
<span class="icon glyphicon glyphicon-{% if committee_meetings_passed %}ok passed{%else%}remove{% endif %}" aria-hidden="true"></span>
<h3>{{m['committee_meetings']}}</h3>
Expand Down
8 changes: 4 additions & 4 deletions conditional/templates/spring_evals.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ <h6 class="eval-uid">{{m['uid']}}</h6>
<div class="col-sm-5 col-md-6 col-lg-4">
<div class="spring-info row">
<div class="text-center">
{% if m['committee_meetings'] < 25 %}
{% if m['committee_meetings'] < m['req_meetings'] %}
<div class="eval-info-label">
<span class="glyphicon glyphicon-remove-sign red eval-info-status"></span>Directorship Meetings
<span class="eval-info-number">{{m['committee_meetings']}} / 25</span>
<span class="eval-info-number">{{m['committee_meetings']}} / {{m['req_meetings']}}</span>
</div>
{% else %}
<div class="eval-info-label">
<span class="glyphicon glyphicon-ok-sign green eval-info-status"></span>Directorship Meetings
<span class="eval-info-number">{{m['committee_meetings']}} / 25</span>
<span class="eval-info-number">{{m['committee_meetings']}} / {{m['req_meetings']}}</span>
</div>
{% endif %}

Expand Down Expand Up @@ -208,7 +208,7 @@ <h4>Major Projects</h4>
{% endif %}
</td>
<td>
{% if m['committee_meetings'] < 25 %}
{% if m['committee_meetings'] < m['req_meetings'] %}
<span class="glyphicon glyphicon-remove-sign red eval-info-status"></span> {{m['committee_meetings']}}
{% else %}
<span class="glyphicon glyphicon-ok-sign green eval-info-status"></span> {{m['committee_meetings']}}
Expand Down
1 change: 1 addition & 0 deletions conditional/util/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions conditional/util/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 26 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bdb6d21

Please sign in to comment.