Skip to content

Commit 1c2dd20

Browse files
committed
Add vote count to dashboard for eboard memebrs #67
1 parent dc789f5 commit 1c2dd20

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

conditional/blueprints/dashboard.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
from conditional.models.models import HouseMeeting
2323
from conditional.models.models import CommitteeMeeting
2424

25+
from conditional.blueprints.member_management import get_members_info
26+
2527
from conditional.util.housing import get_queue_length, get_queue_position
2628
from conditional.util.flask import render_template
2729

@@ -106,6 +108,9 @@ def display_dashboard():
106108
# Voting Status
107109
data['voting'] = bool(user_name in can_vote)
108110

111+
active_list = get_members_info()[0]
112+
data['voting_count'] = {"Voting Members": len(can_vote),
113+
"Active Members": len(active_list)}
109114
# freshman shit
110115
if ldap_is_intromember(user_name):
111116
data['freshman'] = get_freshman_data(user_name)

conditional/blueprints/member_management.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import uuid
44

55
from datetime import datetime
6+
from functools import lru_cache
67

78
import structlog
89

@@ -50,7 +51,9 @@
5051
member_management_bp = Blueprint('member_management_bp', __name__)
5152

5253

53-
def get_members_info(members):
54+
@lru_cache(maxsize=1024)
55+
def get_members_info():
56+
members = [m['uid'] for m in ldap_get_current_students()]
5457
member_list = []
5558
number_onfloor = 0
5659

@@ -88,8 +91,7 @@ def display_member_management():
8891
if not ldap_is_eval_director(user_name) and not ldap_is_financial_director(user_name):
8992
return "must be eval director", 403
9093

91-
members = [m['uid'] for m in ldap_get_current_students()]
92-
member_list, onfloor_number = get_members_info(members)
94+
member_list, onfloor_number = get_members_info()
9395

9496
freshmen = FreshmanAccount.query
9597
freshmen_list = []

conditional/templates/dashboard.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,35 @@ <h3 class="panel-title">Conditionals</h3>
194194
</div>
195195
{% endif %}
196196

197+
198+
{% if is_eboard %}
199+
<div class="panel panel-default">
200+
<div class="panel-heading">
201+
<h3 class="panel-title">Member Statistics</h3>
202+
</div>
203+
<div class="panel-body table-fill">
204+
<div class="table-responsive">
205+
<table class="table table-striped no-bottom-margin">
206+
<tbody>
207+
<tr>
208+
<th>Category</th>
209+
<th><span class="pull-right">Members</span></th>
210+
</tr>
211+
{% for title in voting_count %}
212+
<tr>
213+
<td>{{ title }}</td>
214+
<td><span class="pull-right">{{ voting_count[title] }}</span></td>
215+
</tr>
216+
{% endfor %}
217+
</tbody>
218+
</table>
219+
220+
</div>
221+
</div>
222+
</div>
223+
{% endif %}
224+
225+
197226
{% if major_projects_count == 0 and not active%}
198227
<div class="alert alert-warning" role="alert"> <span class="glyphicon glyphicon-exclamation-sign white" style="padding-right:5px"> </span> You have no major projects.</div>
199228
{% elif major_projects_count > 0 %}

0 commit comments

Comments
 (0)