Skip to content

Commit 4735583

Browse files
committed
Add current student pruning
1 parent 16bed12 commit 4735583

File tree

3 files changed

+82
-4
lines changed

3 files changed

+82
-4
lines changed

conditional/blueprints/member_management.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from conditional.util.ldap import ldap_set_housingpoints
3636
from conditional.util.ldap import ldap_get_active_members
3737
from conditional.util.ldap import ldap_get_member
38+
from conditional.util.ldap import ldap_get_current_students
3839
from conditional.util.ldap import _ldap_add_member_to_group as ldap_add_member_to_group
3940
from conditional.util.ldap import _ldap_remove_member_from_group as ldap_remove_member_from_group
4041
from conditional.util.ldap import _ldap_is_member_of_group as ldap_is_member_of_group
@@ -586,6 +587,29 @@ def clear_active_members():
586587
ldap_remove_member_from_group(account, 'active')
587588
return jsonify({"success": True}), 200
588589

590+
591+
@member_management_bp.route('/manage/current/<uid>', methods=['POST', 'DELETE'])
592+
def remove_current_student(uid):
593+
log = logger.new(user_name=request.headers.get("x-webauth-user"),
594+
request_id=str(uuid.uuid4()))
595+
596+
597+
username = request.headers.get('x-webauth-user')
598+
account = ldap_get_member(username)
599+
600+
if not ldap_is_eval_director(account):
601+
return "must be eval director", 403
602+
603+
member = ldap_get_member(uid)
604+
if request.method == 'DELETE':
605+
log.info('api', action='remove %s from current_student' % uid)
606+
ldap_remove_member_from_group(member, 'current_student')
607+
elif request.method == 'POST':
608+
log.info('api', action='add %s to current_student' % uid)
609+
ldap_add_member_to_group(member, 'current_student')
610+
return jsonify({"success": True}), 200
611+
612+
589613
@member_management_bp.route('/manage/new', methods=['GET'])
590614
def new_year():
591615
log = logger.new(user_name=request.headers.get("x-webauth-user"),
@@ -598,6 +622,10 @@ def new_year():
598622
if not ldap_is_eval_director(account):
599623
return "must be eval director", 403
600624

625+
current_students = ldap_get_current_students()
626+
627+
601628
return render_template(request,
602629
'new_year.html',
603-
username=username)
630+
username=username,
631+
current_students=current_students)

conditional/templates/new_year.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,39 @@
77
<div id="new-welcome">
88
<h3 class="page-title">Welcome!</h3>
99
<p>Is it that time of year already? Before we get started, please <strong>be careful and ready everything before continuing</strong>. Some actions taken on the next few steps can be detrimental if followed in the middle of the year. Once you are ready to proceed, click 'Begin' below.</p>
10-
<a href="#" data-module="newYear" data-step="welcome" class="btn btn-primary btn-new-next center-block"><span class="glyphicon glyphicon-chevron-down"></span> Begin</a>
10+
<a href="#" data-module="newYear" data-step="welcome" class="btn btn-primary btn-new-next center-block"><span class="glyphicon glyphicon-ok"></span> Begin</a>
1111
</div>
1212
<div id="new-clear" style="display: none;">
1313
<h3 class="page-title">Clear Active Members and Floor Roster</h3>
1414
<p>This is the scary part. In order to get everything ready for next year, we need to clear everyone from Active status and then clear the housing board. Once we get a fresh start, we will forward you onto the housing page to fill out the new housing board.</p>
1515
<a href="#" data-module="newYear" data-step="clear" class="btn btn-primary btn-new-next center-block"><span class="glyphicon glyphicon-erase"></span> Clear Active Group and Housing Board</a>
1616
</div>
17+
<div id="new-current" style="display: none;">
18+
<h3 class="page-title">Prune Current Students Group</h3>
19+
<p>Take a second and scroll down the list, remove anyone who has graduated. Anyone in this list who is in good standing can become active, so it is important it is correct.</p>
20+
<table class="table table-striped no-bottom-margin" data-module="table" data-searchable="true" data-sort-column="0" data-sort-order="asc" data-length-changable="true">
21+
<thead>
22+
<tr>
23+
<th>Name</th>
24+
<th>Remove</th>
25+
</tr>
26+
</thead>
27+
<tbody>
28+
{% for student in current_students %}
29+
<tr>
30+
<td id="row-{{student.uid}}">{{student.displayName}}</td>
31+
<td width=100px>
32+
<a href="#" data-module="newYear" data-uid="{{student.uid}}">
33+
<span id="rem-{{student.uid}}" class="glyphicon glyphicon-remove red align-center" style="width: 100%"></span>
34+
<span id="add-{{student.uid}}" class="glyphicon glyphicon-plus green align-center" style="width: 100%; display: none;"></span>
35+
</a>
36+
</td>
37+
</tr>
38+
{% endfor %}
39+
</tbody>
40+
</table>
41+
<a href="#" data-module="newYear" data-step="current" class="btn btn-primary btn-new-next center-block"><span class="glyphicon glyphicon-ok"></span> Next Step</a>
42+
</div>
1743
<div id="new-housing" style="display: none;">
1844
<h3 class="page-title">That was easy!</h3>
1945
<p>The next and final step is to go through and populate the housing board, the button below will even take you there. Just a note: adding people will automatically mark them as active, since they will be charged dues.</p>

frontend/javascript/modules/newYear.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ export default class NewYear {
44
constructor(link) {
55
this.link = link;
66
this.step = this.link.dataset.step;
7+
this.uid = this.link.dataset.uid;
78

89
this.endpoints = {
910
housing: '/housing',
10-
active: '/manage/active'
11+
active: '/manage/active',
12+
current: '/manage/current/'
1113
};
1214

1315
this.render();
@@ -29,10 +31,32 @@ export default class NewYear {
2931
method: 'DELETE'
3032
})
3133
.then($('#new-clear').fadeOut(function() {
32-
$("#new-housing").fadeIn();
34+
$("#new-current").fadeIn();
3335
})
3436
);
3537
});
38+
} else if (this.uid) {
39+
if ($('#rem-' + this.uid).is(":visible")) {
40+
fetch(this.endpoints.current + this.uid, {
41+
method: 'DELETE'
42+
});
43+
$('#rem-' + this.uid).hide();
44+
$('#add-' + this.uid).show();
45+
var userRow = $('#row-' + this.uid)[0];
46+
userRow.style.setProperty("text-decoration", "line-through");
47+
} else {
48+
fetch(this.endpoints.current + this.uid, {
49+
method: 'POST'
50+
});
51+
$('#add-' + this.uid).hide();
52+
$('#rem-' + this.uid).show();
53+
var lineRow = $('#row-' + this.uid)[0];
54+
lineRow.style.setProperty("text-decoration", "none");
55+
}
56+
} else if (this.step === "current") {
57+
$('#new-current').fadeOut(function() {
58+
$("#new-housing").fadeIn();
59+
});
3660
}
3761
});
3862
}

0 commit comments

Comments
 (0)