Skip to content

Commit 7fb7270

Browse files
committed
Work on Become Active functionality
1 parent 2d06e8d commit 7fb7270

File tree

5 files changed

+70
-0
lines changed

5 files changed

+70
-0
lines changed

conditional/blueprints/dashboard.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from conditional.util.ldap import ldap_is_onfloor
66
from conditional.util.ldap import ldap_is_active
77
from conditional.util.ldap import ldap_is_intromember
8+
from conditional.util.ldap import ldap_is_current_student
89
from conditional.util.ldap import ldap_get_member
910
from conditional.util.ldap import ldap_get_active_members
1011

@@ -44,6 +45,8 @@ def display_dashboard():
4445
data['active'] = ldap_is_active(member)
4546
data['onfloor'] = ldap_is_onfloor(member)
4647
data['voting'] = bool(member.uid in can_vote)
48+
data['student'] = ldap_is_current_student(member)
49+
4750

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

conditional/blueprints/member_management.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from conditional.util.ldap import ldap_is_financial_director
2929
from conditional.util.ldap import ldap_is_active
3030
from conditional.util.ldap import ldap_is_onfloor
31+
from conditional.util.ldap import ldap_is_current_student
3132
from conditional.util.ldap import ldap_set_roomnumber
3233
from conditional.util.ldap import ldap_set_active
3334
from conditional.util.ldap import ldap_set_inactive
@@ -491,6 +492,25 @@ def member_management_upgrade_user():
491492
return jsonify({"success": True}), 200
492493

493494

495+
@member_management_bp.route('/manage/make_user_active', methods=['POST'])
496+
def member_management_make_user_active():
497+
log = logger.new(request=request)
498+
499+
post_data = request.get_json()
500+
501+
uid = post_data['uid']
502+
account = ldap_get_member(uid)
503+
504+
if not ldap_is_current_student(account) or ldap_is_active(account):
505+
return jsonify({"success": False}), 403
506+
507+
ldap_set_active(account)
508+
log.info("Make user {} active".format(uid))
509+
510+
clear_members_cache()
511+
return jsonify({"success": True}), 200
512+
513+
494514
@member_management_bp.route('/manage/intro_project', methods=['GET'])
495515
def introductory_project():
496516
log = logger.new(request=request)

conditional/templates/dashboard.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,16 @@ <h3 class="panel-title">Major Projects</h3>
251251
</div>
252252
{% endif %}
253253

254+
{% if student and not active %}
255+
<div class="alert alert-info"><span class="glyphicon glyphicon-exclamation-sign white" style="padding-right:5px"></span>
256+
Hey there! You're eligible to become an active member, click the button below if you'd like to pay dues and become active!
257+
<br />
258+
<a href="#" id="becomeActive" data-module="becomeActive" data-uid="{{username}}" class="btn btn-default">Become Active</a>
259+
</div>
260+
{% endif %}
261+
254262
</div>
263+
255264
<div class="col-lg-6 col-md-6">
256265
{% if housing %}
257266
<div class="panel panel-default">
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import FetchUtil from "../utils/fetchUtil";
2+
3+
export default class becomeActive {
4+
constructor(link) {
5+
this.link = link;
6+
this.uid = this.link.dataset.uid;
7+
this.endpoint = '/manage/make_user_active';
8+
this.render();
9+
}
10+
11+
render() {
12+
this.link.addEventListener('click', e => this._delete(e));
13+
}
14+
15+
_delete(e) {
16+
e.preventDefault();
17+
18+
let payload = {
19+
uid: this.uid
20+
};
21+
22+
FetchUtil.postWithWarning(this.endpoint, payload, {
23+
warningText: "Becoming an active member means that you will be charged" +
24+
" dues, which are $80 per semester.",
25+
successText: "You are now an active member."
26+
}, () => {
27+
document.getElementById('becomeActive').remove();
28+
});
29+
}
30+
}
31+

frontend/stylesheets/pages/_dashboard.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@
4141
margin: 5px 0;
4242
}
4343
}
44+
45+
.alert-info {
46+
.btn {
47+
margin-top: 10px;
48+
}
49+
}
50+

0 commit comments

Comments
 (0)