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
110 changes: 110 additions & 0 deletions conditional/blueprints/attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,113 @@ def alter_house_excuse(uid, hid):
db.session.flush()
db.session.commit()
return jsonify({"success": True}), 200


@attendance_bp.route('/attendance/history', methods=['GET'])
def attendance_history():


def get_meeting_attendees(meeting_id):
attendees = [ldap_get_member(a.uid).displayName for a in
MemberCommitteeAttendance.query.filter(
MemberCommitteeAttendance.meeting_id == meeting_id).all()]

for freshman in [a.fid for a in
FreshmanCommitteeAttendance.query.filter(
FreshmanCommitteeAttendance.meeting_id == meeting_id).all()]:
attendees.append(FreshmanAccount.query.filter(
FreshmanAccount.id == freshman).first().name)
return attendees

log = logger.new(user_name=request.headers.get("x-webauth-user"),
request_id=str(uuid.uuid4()))

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

if request.method == 'GET':
page = request.args.get('page', 1)
log.info('api', action='view past attendance submitions')
offset = 0 if int(page) == 1 else ((int(page)-1)*10)
limit = int(page)*10
all_cm = [{"meeting_id": m.id,
"directorship": m.committee,
"dt_obj": m.timestamp,
"date": m.timestamp.strftime("%a %m/%d/%Y"),
"attendees": get_meeting_attendees(m.id)
} for m in CommitteeMeeting.query.all()]
c_meetings = sorted(all_cm, key=lambda k: k['dt_obj'], reverse=True)[offset:limit]
if len(all_cm) % 10 != 0:
total_pages = (int(len(all_cm) / 10) + 1)
else:
total_pages = (int(len(all_cm) / 10))
return render_template(request,
'attendance_history.html',
username=user_name,
history=c_meetings,
num_pages=total_pages,
current_page=int(page))

@attendance_bp.route('/attendance/alter/cm/<cid>', methods=['POST'])
def alter_committee_attendance(cid):
log = logger.new(user_name=request.headers.get("x-webauth-user"),
request_id=str(uuid.uuid4()))
log.info('api', action='edit committee meeting attendance')

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

post_data = request.get_json()
meeting_id = cid
m_attendees = post_data['members']
f_attendees = post_data['freshmen']

FreshmanCommitteeAttendance.query.filter(
FreshmanCommitteeAttendance.meeting_id == meeting_id).delete()

MemberCommitteeAttendance.query.filter(
MemberCommitteeAttendance.meeting_id == meeting_id).delete()

for m in m_attendees:
db.session.add(MemberCommitteeAttendance(m, meeting_id))

for f in f_attendees:
db.session.add(FreshmanCommitteeAttendance(f, meeting_id))

db.session.flush()
db.session.commit()
return jsonify({"success": True}), 200

@attendance_bp.route('/attendance/cm/<cid>', methods=['GET', 'DELETE'])
def get_cm_attendees(cid):
if request.method == 'GET':
attendees = [{"value": a.uid,
"display": ldap_get_member(a.uid).displayName
} for a in
MemberCommitteeAttendance.query.filter(
MemberCommitteeAttendance.meeting_id == cid).all()]

for freshman in [{"value": a.fid,
"display": FreshmanAccount.query.filter(FreshmanAccount.id == a.fid).first().name
} for a in FreshmanCommitteeAttendance.query.filter(
FreshmanCommitteeAttendance.meeting_id == cid).all()]:
attendees.append(freshman)
return jsonify({"attendees": attendees}), 200

elif request.method == 'DELETE':
FreshmanCommitteeAttendance.query.filter(
FreshmanCommitteeAttendance.meeting_id == cid).delete()
MemberCommitteeAttendance.query.filter(
MemberCommitteeAttendance.meeting_id == cid).delete()
CommitteeMeeting.query.filter(
CommitteeMeeting.id == cid).delete()

db.session.flush()
db.session.commit()

return jsonify({"success": True}), 200
84 changes: 84 additions & 0 deletions conditional/templates/attendance_history.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{% extends "nav.html" %}
{% block title %}
Attendance History
{% endblock %}
{% block body %}
<div class="container main">
<h3 class="page-title">Attendance History</h3>
{% for meeting in history %}
<div class="panel panel-default">
<div class="panel-body eval-panel">
<div class="container-fluid">
<div class="col-xs-12 col-sm-3 vcenter">
<h5>{{meeting["directorship"]}}</h5>
<p>{{meeting["date"]}}<p>
</div><!--
--><div class="com-xs-12 col-sm-7 vcenter">
<p class="attend-list" id="attendees-{{meeting["id"]}}">
{% for name in meeting["attendees"] %}
{{name}}{% if not loop.last %}, {% endif %}
{% endfor %}
</p>
</div><!--
--><div class="col-xs-12 col-sm-2 vcenter text-center">
<button type="button" class="btn btn-default navbar-btn" data-module="cmAttendance" data-modal="editMeeting" data-cid="{{meeting["id"]}}">
<span class="glyphicon glyphicon-edit attend-edit-icon"></span> Edit
</button>
</div>
</div>
</div>
</div>
{% endfor %}
{% if num_pages > 1 or current_page > 1%}

<nav aria-label="Page navigation" class="align-center">
<ul class="pagination">
<li {%if current_page == 1 %}class="disabled"{% endif %}>
{%if current_page != 1 %}
<a href="?page={{ current_page - 1 }}" aria-label="Previous">
{% endif %}
<span aria-hidden="true">&laquo;</span>
</a>
</li>
{% for number in range(1, num_pages+1) %}
<li {% if number == current_page %} class="active" {% endif %}>
<a href="?page={{ number }}">{{ number }}</a>
</li>
{% endfor %}
<li {%if current_page == num_pages %}class="disabled"{% endif %}>
{%if current_page != num_pages %}
<a href="?page={{ current_page + 1 }}" aria-label="Next">
{% endif %}
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</ul>
</nav>
{% endif %}
</div>

<div class="modal fade" id="editMeeting" tabindex="-1">
<div class="vertical-alignment-helper">
<div class="modal-dialog vertical-align-center">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="editMeetingTitle">Edit Meeting</h4>
</div>
<form method="post">
<div class="modal-body">
<div class="row user-edit-row">
<label class="control-label" for="attendees">Attendees</label>
<input type="text" name="attendees" class="form-control" />
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger delete-btn pull-left">Delete</button>
<input type="submit" class="btn btn-primary" value="Submit">
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
4 changes: 2 additions & 2 deletions conditional/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<div class="panel panel-default">
<div class="panel-body dashboard-user">
<div class="row">
<div class="col-md-2 col-sm-3 col-xs-12 vcenter profile-container">
<div class="col-md-2 col-sm-3 col-xs-12 profile-container">
<img class="profile-image" src="https://profiles.csh.rit.edu/image/{{username}}">
</div>
<div class="col-xs-12 col-sm-9 col-md-9 vcenter profile-container">
<div class="col-xs-12 col-sm-9 col-md-9 profile-container">
<h3 class="username">{{name}}</h3>
<h5 class="email">{{username}}@csh.rit.edu</h5>
<div class="profile-badges">
Expand Down
4 changes: 2 additions & 2 deletions conditional/templates/intro_evals.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="container-fluid">
<div class="row">
<div class="col-sm-2 col-md-2 col-lg-2 vcenter">
<div class="col-sm-2 col-md-2 col-lg-2">
<div style="margin:auto; width:100px">
<img class="eval-user-img" alt="{{m['uid']}}" src="https://profiles.csh.rit.edu/image/{{m['uid']}}" width="100" height="100" />
{% if m['ldap_account'] %}
Expand Down Expand Up @@ -40,7 +40,7 @@ <h6 class="eval-uid">{{ m['uid'] }}</h6>

</div>
<!---->
<div class="col-sm-5 col-md-6 col-lg-4 vcenter">
<div class="col-sm-5 col-md-6 col-lg-4">
<div class="intro-info row">
<div class="text-center">
{% if m['signatures_missed'] == 0 %}
Expand Down
1 change: 1 addition & 0 deletions conditional/templates/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-ok"></span> Attendance <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/attendance_cm"><span class="glyphicon glyphicon-briefcase"></span> Directorship Meeting </a></li>
<li><a href="/attendance/history"><span class="glyphicon glyphicon-calendar"></span> Attendance History </a></li>
<li><a href="/attendance_ts"><span class="glyphicon glyphicon-blackboard"></span> Technical Seminar</a></li>
{% if is_eval_director %}
<li><a href="/attendance_hm"><span class="glyphicon glyphicon-home"></span> House Meeting</a></li>
Expand Down
4 changes: 2 additions & 2 deletions conditional/templates/spring_evals.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<div class="container-fluid">
<div class="row">
<div class="col-sm-2 col-md-2 col-lg-2 vcenter">
<div class="col-sm-2 col-md-2 col-lg-2">
<div style="margin:auto; width:100px">
<img class="eval-user-img" alt="{{m['uid']}}" src="https://profiles.csh.rit.edu/image/{{m['uid']}}" width="100" height="100" />

Expand All @@ -31,7 +31,7 @@ <h4 class="eval-name">{{m['name']}}</h4>
<h6 class="eval-uid">{{m['uid']}}</h6>
</div>
<!---->
<div class="col-sm-5 col-md-6 col-lg-4 vcenter">
<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 %}
Expand Down
14 changes: 14 additions & 0 deletions frontend/javascript/exceptions/cmAttendanceException.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {Enum} from 'enumify';

class CmAttendanceException extends Enum {
}

CmAttendanceException.initEnum({
SUBMIT_BEFORE_RENDER: {
get message() {
return "Cannot submit updated attendance before the modal renders.";
}
}
});

export default CmAttendanceException;
Loading