Skip to content

Commit b20c083

Browse files
committed
Add Co-Op Submission Page
1 parent 4e9b599 commit b20c083

File tree

7 files changed

+152
-1
lines changed

7 files changed

+152
-1
lines changed

conditional/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def start_of_year():
5050
from conditional.blueprints.member_management import member_management_bp
5151
from conditional.blueprints.slideshow import slideshow_bp
5252
from conditional.blueprints.cache_management import cache_bp
53+
from conditional.blueprints.co_op import co_op_bp
5354

5455
app.register_blueprint(dashboard_bp)
5556
app.register_blueprint(attendance_bp)
@@ -62,6 +63,7 @@ def start_of_year():
6263
app.register_blueprint(member_management_bp)
6364
app.register_blueprint(slideshow_bp)
6465
app.register_blueprint(cache_bp)
66+
app.register_blueprint(co_op_bp)
6567

6668
from conditional.util.ldap import ldap_get_member
6769

conditional/blueprints/co_op.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import uuid
2+
import structlog
3+
4+
from flask import Blueprint, request, jsonify
5+
6+
from conditional.util.flask import render_template
7+
8+
from conditional.models.models import CurrentCoops
9+
10+
from conditional import db, start_of_year
11+
12+
co_op_bp = Blueprint('co_op_bp', __name__)
13+
14+
logger = structlog.get_logger()
15+
16+
@co_op_bp.route('/co_op/')
17+
def display_conditionals():
18+
log = logger.new(user_name=request.headers.get("x-webauth-user"),
19+
request_id=str(uuid.uuid4()))
20+
log.info('frontend', action='display conditional listing page')
21+
22+
# get user data
23+
user_name = request.headers.get('x-webauth-user')
24+
co_op = CurrentCoops.query.filter(CurrentCoops.uid == user_name, CurrentCoops.date_created > start_of_year()).first()
25+
26+
return render_template(request,
27+
'co_op.html',
28+
username=user_name,
29+
year=start_of_year().year,
30+
on_coop=co_op)
31+
32+
33+
@co_op_bp.route('/co_op/submit', methods=['POST'])
34+
def submit_major_project():
35+
log = logger.new(user_name=request.headers.get("x-webauth-user"),
36+
request_id=str(uuid.uuid4()))
37+
38+
user_name = request.headers.get('x-webauth-user')
39+
40+
post_data = request.get_json()
41+
semester = post_data['semester']
42+
43+
log.info('api', action='Submit %s Co-Op' % semester)
44+
45+
if CurrentCoops.query.filter(CurrentCoops.uid == user_name, CurrentCoops.date_created > start_of_year()).first():
46+
return "User has already submitted this form!", 403
47+
48+
co_op = CurrentCoops(uid=user_name, semester=semester)
49+
db.session.add(co_op)
50+
db.session.flush()
51+
db.session.commit()
52+
53+
return jsonify({"success": True}), 200

conditional/templates/co_op.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{% extends "nav.html" %}
2+
{% block title %}
3+
Co-Op Submission
4+
{% endblock %}
5+
{% block body %}
6+
<div class="container main">
7+
<h3 class="page-title">Co-Op Submission</h3>
8+
<div class="row">
9+
<div class="col-xs-12 col-sm-12 col-md-12">
10+
<div class="panel panel-default">
11+
<div class="panel-body" style="padding-top:25px">
12+
{% if not on_coop %}
13+
<p>Please select one of the following options below if you are going to be on co-op during either semester this year. In the case you are going to be on co-op for both semesters, please contact the Evaluations Director and have them remove you from Active status.</p>
14+
<p>By selecting an option and submitting this form you are forfeiting your right to vote in house matters during the selected period. You are not required to attend house meetings but are still eligable for directorship meeting attendance.</p>
15+
<form data-module="coopSubmitForm">
16+
<div class="co-op-group">
17+
<div class="col-xs-12 col-sm-6">
18+
<div class="radio">
19+
<label>
20+
<input type="radio" name="semester" id="fall" value="Fall">
21+
<div class="co-op-option">
22+
<h4 class="list-group-item-heading">Fall Semester</h4>
23+
<p class='co-op-description'>August - December {{year}}</p>
24+
</div>
25+
</label>
26+
</div>
27+
</div>
28+
<div class="col-xs-12 col-sm-6">
29+
<div class="radio">
30+
<label>
31+
<input type="radio" name="semester" id="spring" value="Spring">
32+
<div class="co-op-option">
33+
<h4 class="list-group-item-heading">Spring Semester</h4>
34+
<p class='co-op-description'>January - May {{year + 1}}</p>
35+
</div>
36+
</label>
37+
</div>
38+
</div>
39+
</div>
40+
<input type="submit" role="button" class="btn btn-raised btn-primary" style="width:100%;" value="Submit Form"/>
41+
</form>
42+
{% else %}
43+
<p class="align-center">Thanks for submitting this form. Good luck on your {{on_coop.semester}} co-op!</p>
44+
{% endif %}
45+
</div>
46+
</div>
47+
</div>
48+
</div>
49+
</div>
50+
{% endblock %}

conditional/templates/nav.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-list-alt"></span> Forms <span class="caret"></span></a>
2626
<ul class="dropdown-menu">
2727
<li><a href="/major_project"><span class="glyphicon glyphicon-star"></span> Major Project</a></li>
28+
<li><a href="/co_op"><span class="glyphicon glyphicon-briefcase"></span> Co-Op Submission</a></li>
2829
{% if is_intromember %}
2930
<li><a href="/intro_evals_form"><span class="glyphicon glyphicon-blackboard"></span> Introductory Evaluations</a></li>
3031
{% endif %}
@@ -40,7 +41,7 @@
4041
{% endif %}
4142
<span class="caret"></span></a>
4243
<ul class="dropdown-menu">
43-
<li><a href="/attendance_cm"><span class="glyphicon glyphicon-briefcase"></span> Directorship Meeting </a></li>
44+
<li><a href="/attendance_cm"><span class="glyphicon glyphicon-user"></span> Directorship Meeting </a></li>
4445
<li><a href="/attendance_ts"><span class="glyphicon glyphicon-blackboard"></span> Technical Seminar</a></li>
4546
{% if is_eboard %}
4647
<li><a href="/attendance/history"><span class="glyphicon glyphicon-calendar"></span> Attendance History</a></li>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import FetchUtil from "../utils/fetchUtil";
2+
3+
export default class coopSubmitForm {
4+
constructor(form) {
5+
this.form = form;
6+
this.endpoint = '/co_op/submit';
7+
this.render();
8+
}
9+
10+
render() {
11+
this.form.querySelector('input[type=submit]')
12+
.addEventListener('click', e => this._submitForm(e));
13+
}
14+
15+
_submitForm(e) {
16+
e.preventDefault();
17+
18+
let payload = {
19+
semester: this.form.querySelector('input[name=semester]:checked').value
20+
};
21+
22+
FetchUtil.postWithWarning(this.endpoint, payload, {
23+
warningText: "You will not be able to edit your " +
24+
"submission once it is submitted!",
25+
successText: "Your co-op has been submitted."
26+
});
27+
}
28+
}

frontend/stylesheets/app.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
@import 'pages/hm-attendance';
2828
@import 'pages/attendance-hist';
2929
@import 'pages/errors';
30+
@import 'pages/co-op';
3031
@import 'components/reveal';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.co-op-description {
2+
margin-bottom: 25px;
3+
}
4+
5+
.co-op-group {
6+
margin-top: 25px;
7+
}
8+
9+
.co-op-option {
10+
padding-left: 10px;
11+
}
12+
13+
.radio-inline input[type='radio'], .radio input[type='radio'], input[type='radio'] {
14+
position: fixed;
15+
margin-top: 20px;
16+
}

0 commit comments

Comments
 (0)