Skip to content

Commit 3e491bf

Browse files
committed
Cleanup and allowing to run
1 parent fc91f6f commit 3e491bf

20 files changed

+193
-118
lines changed

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6
1+
6.3.1

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
2525

2626
RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
2727

28-
CMD ["gunicorn", "conditional:app", "--bind=0.0.0.0:8080", "--access-logfile=-"]
28+
CMD ["gunicorn", "conditional:app", "--bind=0.0.0.0:8080", "--access-logfile=-", "--timeout=256"]

conditional/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
8888
logger = structlog.get_logger()
8989

9090
# pylint: disable=wrong-import-order
91+
from conditional.util import context_processors
9192
from conditional.util.auth import get_user
92-
9393
from .blueprints.dashboard import dashboard_bp # pylint: disable=ungrouped-imports
9494
from .blueprints.attendance import attendance_bp
9595
from .blueprints.major_project_submission import major_project_bp

conditional/blueprints/cache_management.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from conditional import auth
88
from conditional.util.auth import get_user
9+
from conditional.util.cache import clear_all_cached_functions
910
from conditional.util.ldap import _ldap_is_member_of_directorship
1011
from conditional.util.ldap import ldap_get_active_members
1112
from conditional.util.ldap import ldap_get_current_students
@@ -14,9 +15,6 @@
1415
from conditional.util.ldap import ldap_get_onfloor_members
1516
from conditional.util.ldap import ldap_is_eval_director
1617
from conditional.util.ldap import ldap_is_rtp
17-
from conditional.util.member import get_members_info
18-
from conditional.util.member import get_onfloor_members
19-
from conditional.util.member import get_voting_members
2018

2119
logger = structlog.get_logger()
2220
cache_bp = Blueprint('cache_bp', __name__)
@@ -45,16 +43,8 @@ def clear_cache(user_dict=None):
4543
log = logger.new(request=request, auth_dict=user_dict)
4644
log.info('Purge All Caches')
4745

48-
_ldap_is_member_of_directorship.cache_clear()
49-
ldap_get_member.cache_clear()
50-
ldap_get_active_members.cache_clear()
51-
ldap_get_intro_members.cache_clear()
52-
ldap_get_onfloor_members.cache_clear()
53-
ldap_get_current_students.cache_clear()
46+
clear_all_cached_functions()
5447

55-
get_voting_members.cache_clear()
56-
get_members_info.cache_clear()
57-
get_onfloor_members.cache_clear()
5848
return "cache cleared", 200
5949

6050

conditional/blueprints/co_op.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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
67
from conditional.util.auth import get_user
78
from conditional.util.flask import render_template
89
from conditional.util.ldap import ldap_is_eval_director, ldap_is_current_student
@@ -58,6 +59,7 @@ def submit_co_op_form(user_dict=None):
5859
db.session.add(co_op)
5960
db.session.flush()
6061
db.session.commit()
62+
req_cm.cache_clear()
6163

6264
return jsonify({"success": True}), 200
6365

@@ -83,5 +85,27 @@ def delete_co_op(uid, user_dict=None):
8385

8486
db.session.flush()
8587
db.session.commit()
88+
req_cm.cache_clear()
8689

8790
return jsonify({"success": True}), 200
91+
92+
93+
@co_op_bp.route('/co_op/manage')
94+
@auth.oidc_auth
95+
@get_user
96+
def display_co_op_management(user_dict=None):
97+
log = logger.new(request=request, auth_dict=user_dict)
98+
log.info('Display Co-Op Management')
99+
100+
if not ldap_is_eval_director(user_dict['account']):
101+
return "must be eval director", 403
102+
103+
co_op_list = [(member.semester, member.uid)
104+
for member in CurrentCoops.query.filter(
105+
CurrentCoops.date_created > start_of_year(),
106+
CurrentCoops.semester != "Neither")]
107+
108+
return render_template("co_op_management.html",
109+
username=user_dict['username'],
110+
co_op=co_op_list,
111+
)

conditional/blueprints/conditional.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from conditional.models.models import Conditional, SpringEval, FreshmanEvalData
88
from conditional.util.auth import get_user
99
from conditional.util.flask import render_template
10-
from conditional.util.ldap import ldap_get_member
1110
from conditional.util.ldap import ldap_is_eval_director
1211

1312
conditionals_bp = Blueprint('conditionals_bp', __name__)
@@ -24,15 +23,15 @@ def display_conditionals(user_dict=None):
2423

2524
conditionals = [
2625
{
27-
'name': ldap_get_member(c.uid).cn,
26+
'uid': c.uid,
2827
'date_created': c.date_created,
2928
'date_due': c.date_due,
3029
'description': c.description,
3130
'id': c.id
3231
} for c in
3332
Conditional.query.filter(
3433
Conditional.status == "Pending")]
35-
# return names in 'first last (username)' format
34+
3635
return render_template('conditional.html',
3736
username=user_dict['username'],
3837
conditionals=conditionals,

conditional/blueprints/dashboard.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ def display_dashboard(user_dict=None):
3434

3535
data = dict()
3636
data['username'] = user_dict['account'].uid
37-
data['name'] = user_dict['account'].cn
3837
data['active'] = ldap_is_active(user_dict['account'])
3938
data['bad_standing'] = ldap_is_bad_standing(user_dict['account'])
4039
data['onfloor'] = ldap_is_onfloor(user_dict['account'])
4140
data['voting'] = bool(user_dict['account'].uid in can_vote)
42-
data['student'] = ldap_is_current_student(user_dict['account'])
4341

4442
data['voting_count'] = {"Voting Members": len(can_vote),
4543
"Active Members": len(ldap_get_active_members())}

conditional/blueprints/member_management.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import csv
22
import io
3-
43
from datetime import datetime
54
from distutils.util import strtobool # pylint: disable=no-name-in-module,import-error
65

76
import structlog
8-
97
from flask import Blueprint, request, jsonify, make_response
108

119
from conditional import app, get_user, auth
@@ -43,14 +41,11 @@
4341
from conditional.util.ldap import ldap_get_current_students
4442
from conditional.util.ldap import _ldap_add_member_to_group as ldap_add_member_to_group
4543
from conditional.util.ldap import _ldap_remove_member_from_group as ldap_remove_member_from_group
46-
from conditional.util.ldap import _ldap_is_member_of_group as ldap_is_member_of_group
4744

4845
from conditional.util.flask import render_template
4946
from conditional.models.models import attendance_enum
5047
from conditional.util.member import get_members_info, get_onfloor_members
5148

52-
from conditional import db, start_of_year
53-
5449
logger = structlog.get_logger()
5550

5651
member_management_bp = Blueprint('member_management_bp', __name__)
@@ -69,11 +64,6 @@ def display_member_management(user_dict=None):
6964
member_list = get_members_info()
7065
onfloor_list = get_onfloor_members()
7166

72-
co_op_list = [(ldap_get_member(member.uid).displayName, member.semester, member.uid) \
73-
for member in CurrentCoops.query.filter(
74-
CurrentCoops.date_created > start_of_year(),
75-
CurrentCoops.semester != "Neither")]
76-
7767
freshmen = FreshmanAccount.query
7868
freshmen_list = []
7969

@@ -104,7 +94,6 @@ def display_member_management(user_dict=None):
10494
num_fresh=len(freshmen_list),
10595
num_onfloor=len(onfloor_list),
10696
freshmen=freshmen_list,
107-
co_op=co_op_list,
10897
site_lockdown=lockdown,
10998
accept_dues_until=accept_dues_until,
11099
intro_form=intro_form)
@@ -268,7 +257,7 @@ def edit_uid(uid, flask_request, username):
268257
ldap_set_roomnumber(account, room_number)
269258
if onfloor_status:
270259
# If a OnFloorStatusAssigned object exists, don't make another
271-
if not ldap_is_member_of_group(account, "onfloor"):
260+
if not ldap_is_onfloor(account):
272261
db.session.add(OnFloorStatusAssigned(uid, datetime.now()))
273262
ldap_add_member_to_group(account, "onfloor")
274263
else:
@@ -277,7 +266,7 @@ def edit_uid(uid, flask_request, username):
277266
db.session.flush()
278267
db.session.commit()
279268

280-
if ldap_is_member_of_group(account, "onfloor"):
269+
if ldap_is_onfloor(account):
281270
ldap_remove_member_from_group(account, "onfloor")
282271
ldap_set_housingpoints(account, housing_points)
283272

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{% extends "nav.html" %}
2+
{% block title %}
3+
Co-Op Management
4+
{% endblock %}
5+
{% block body %}
6+
<div class="container main">
7+
{% if is_eval_director%}
8+
<div class="panel panel-default">
9+
<div class="panel-heading">
10+
<h3 class="panel-title">Co-Op Management</h3>
11+
</div>
12+
<div class="panel-body table-fill">
13+
<div class="table-responsive">
14+
<table class="table table-striped no-bottom-margin" data-module="table" data-searchable="false" data-sort-column="1" data-sort-order="asc" data-length-changable="true" data-paginated="false">
15+
<thead>
16+
<tr>
17+
<th>Name</th>
18+
<th>Semester</th>
19+
<th>Delete</th>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
{% for c in co_op %}
24+
<tr id="coop-{{c[1]}}">
25+
<td>
26+
<img class="table-img mobile-hide" src="https://profiles.csh.rit.edu/image/{{c[1]}}"> {{ get_member_name(c[1]) }}
27+
</td>
28+
<td>
29+
{{c[0]}}
30+
</td>
31+
<td width=100px>
32+
<a href="#" data-module="coopDelete" data-uid="{{c[1]}}">
33+
<span class="glyphicon glyphicon-trash red align-center" style="width: 100%"></span>
34+
</a>
35+
</td>
36+
</tr>
37+
{% endfor %}
38+
</tbody>
39+
</table>
40+
</div>
41+
</div>
42+
</div>
43+
{% endif %}
44+
</div>
45+
{% endblock %}

conditional/templates/conditional.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h3 class="panel-title">
3535
<tbody>
3636
{% for c in conditionals %}
3737
<tr id="conditional-{{ c['id'] }}" conditional_id="{{ c['id'] }}">
38-
<td>{{ c['name'] }}</td>
38+
<td>{{ get_member_name(c['uid']) }}</td>
3939
<td>{{ c['date_created'] }}</td>
4040
<td>{{ c['date_due'] }}</td>
4141
<td>{{ c['description'] }}</td>

0 commit comments

Comments
 (0)