Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions app/controllers/main_routes/main_routes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from flask import render_template, request, json, redirect, url_for, send_file, g, flash, jsonify
from peewee import JOIN
from peewee import JOIN, DoesNotExist, fn
from functools import reduce
import operator
from app.models.department import Department
from app.models.allocation import Allocation
from app.models.supervisor import Supervisor
from app.models.supervisorDepartment import SupervisorDepartment
from app.models.student import Student
Expand All @@ -16,6 +17,7 @@
from app.login_manager import require_login, logout
from app.logic.getTableData import getDatatableData
from app.logic.banner import Banner
from app.logic.tracy import Tracy

@main_bp.route('/logout', methods=['GET'])
def triggerLogout():
Expand Down Expand Up @@ -47,6 +49,56 @@ def supervisorPortal():
currentUser = currentUser
)

@main_bp.route('/department', methods=['GET'])
@main_bp.route('/department/<org>', methods=['GET'])
@main_bp.route('/department/<org>/<account>', methods=['GET'])
def departmentPortal(org=None,account=None):
try:
dept = Department.get(Department.ORG == org, Department.ACCOUNT == account)
except (NameError, DoesNotExist):
dept = None



if g.currentUser.isLaborAdmin:
departments = list(Department.select().order_by(Department.isActive.desc(), Department.DEPT_NAME.asc()))
else:
departments = list(getDepartmentsForSupervisor(g.currentUser).order_by(Department.isActive.desc(), Department.DEPT_NAME.asc()))

pos = Tracy().getPositionsFromDepartment(org, account)
positions = []
for i in pos:
positions.append(i.POSN_TITLE + "" + "(" + i.WLS + ")")

staff = Tracy().getSupervisors()
supervisors = []

for i in staff:
if i.DEPT_NAME == Department.DEPT_NAME:
supervisors.append(i.FIRST_NAME + " " + i.LAST_NAME + " (" + i.EMAIL + ")")

allocation = None
positionsUsed = 0
breakHoursUsed = 0
if dept and g.openTerm:
allocation = Allocation.get_or_none(Allocation.department == dept, Allocation.term == g.openTerm)
usage = (LaborStatusForm
.select(fn.COUNT(LaborStatusForm.laborStatusFormID).alias('positionCount'),
fn.SUM(LaborStatusForm.contractHours).alias('hoursSum'))
.where(LaborStatusForm.department == dept, LaborStatusForm.termCode == g.openTerm)
.get())
positionsUsed = usage.positionCount or 0
breakHoursUsed = usage.hoursSum or 0

return render_template('main/departmentPortal.html',
departments = departments,
department = dept,
positions = positions,
supervisors = supervisors,
allocation = allocation,
positionsUsed = positionsUsed,
breakHoursUsed = breakHoursUsed)

@main_bp.route('/supervisorPortal/addUserToDept', methods=['GET', 'POST'])
def addUserToDept():
userDeptData = request.form
Expand Down Expand Up @@ -113,4 +165,4 @@ def submitToBanner(formHistoryId):
if save_form_status:
return "Form successfully submitted to Banner.", 200
else:
return "Submitting to Banner failed.", 500
return "Submitting to Banner failed.", 500
9 changes: 9 additions & 0 deletions app/models/allocation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from app.models import *
from app.models.department import Department
from app.models.term import Term

class Allocation(baseModel):
department = ForeignKeyField(Department, on_delete="cascade")
term = ForeignKeyField(Term, on_delete="cascade")
totalPositions = IntegerField()
totalBreakHours = IntegerField()
73 changes: 73 additions & 0 deletions app/static/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,76 @@ a {
font-size:1.2em;
z-index:999;
}

.card {
position: relative;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 0.25rem;
}

.card-body {
-webkit-box-flex: 1;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
padding: 1rem 1rem;
}

.card-title {
margin-bottom: 0.5rem;
font-size: 1.25rem;
font-weight: 500;
}

.card-subtitle {
margin-top: -0.25rem;
margin-bottom: 0;
}

.card-text:last-child {
margin-bottom: 0;
}

.card-link + .card-link {
margin-left: 1rem;
}

.card-header {
padding: 0.5rem 1rem;
margin-bottom: 0;
background-color: rgba(0, 0, 0, 0.03);
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

.card-header:first-child {
border-radius: calc(0.25rem - 1px) calc(0.25rem - 1px) 0 0;
}

.card-footer {
padding: 0.5rem 1rem;
background-color: rgba(0, 0, 0, 0.03);
border-top: 1px solid rgba(0, 0, 0, 0.125);
}

.card-footer:last-child {
border-radius: 0 0 calc(0.25rem - 1px) calc(0.25rem - 1px);
}

.card-img, .card-img-top {
width: 100%;
}

.card-img-top {
border-top-left-radius: calc(0.25rem - 1px);
border-top-right-radius: calc(0.25rem - 1px);
}
6 changes: 6 additions & 0 deletions app/static/js/departmentPortal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$(document).ready(function() {
$("#selectedDepartment").on("change",function() {
deptData = $(this).find('option:selected').data();
window.location = `/department/${deptData.org}/${deptData.account}`;
});
});
165 changes: 165 additions & 0 deletions app/templates/main/departmentPortal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{% extends "base.html" %}

{% block scripts %}
{{super()}}
<script type="text/javascript" src="{{url_for('static', filename='js/departmentPortal.js') }}?u={{lastStaticUpdate}}"></script>
<link rel="stylesheet" type="text/css"
href="{{url_for('static', filename ='css/departmentPortal.css')}}?u={{lastStaticUpdate}}">
{% endblock %}
{% block app_content %}
<h2 class="text-center">{% if department %} {{department.DEPT_NAME}} Portal {% else %} Choose a Department: {% endif %} </h2>


<!--selectpicker for department-->
<div class="form-group">
<select class="selectpicker"
name='department'
id='selectedDepartment'
data-live-search='true'
title="Department"
data-width="100%">
<option value = "" disabled selected>Select a Department</option>
{% for d in departments %}
<option data-account="{{d.ACCOUNT}}" data-org="{{d.ORG}}"{% if department and d == department %} selected {% endif %} data-content=
"<span>{{d.DEPT_NAME}}</span><small class='text-muted'> ({{d.ORG}}-{{d.ACCOUNT}}) </small>">{{d.DEPT_NAME}}</option>
{% endfor %}
</select>

</div>

{% if department %}
<div class="card-group" style="display:flex" style="height: 1000px">

<section class="card "style="width:50rem" aria-labelledby="current_allocation-title">
<div class="card-body">
<div class="media">
<div class="media-left">
<span>
<h2>
<i class="bi bi-clock" style="border: 1px solid #c0c0c0; border-radius: 12px; padding: 3px 3.5px 1.5px 3.5px; font-size: 1.5em; color: #6e6e6e"></i> Current Allocation
</h2>
</span>
</div>
</div>
<div>
<div class="header-container" style="display: flex; justify-content: space-between; align-items: center; padding-left: 10px; padding-right: 10px;">
<h3>AY 26/27</h3> <h3>15/20 Positions</h3>
</div>
<ul style="font-size: 1.2em; padding-left: 75px;">
<li>10 HR : 2</li>
<li>12 HR : 3</li>
<li>15 HR : 5</li>
<li>20 HR : 5</li>
</ul>
</div>
<div class="header-container" style="display: flex; justify-content: space-between; align-items: center; padding-left: 10px; padding-right: 10px;">
<h3>Break Hours</h3> <h3>0 of 200 Hrs.</h3>
</div>
</div>


<div class="card-footer text-center">
<a href="#" class="btn btn-primary btn-sm">
View Details <span class="glyphicon glyphicon-chevron-right"></span>
</a>
<a href="#" class="btn btn-primary btn-sm">
Request Allocation <span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</section>

<section class="card "style="width:50rem" aria-labelledby="members-title">
<div class="card-body">
<div class="media">
<div class="media-left">
<span class="btn btn-default btn-lg img-circle disabled" aria-hidden="true">
<i class="fa fa-users"></i>
</span>
</div>
<div class="media-body media-middle">
<h1>
Members
</h1>
</div>
</div>
<h4>Labor Coordinator(s)</h4>
<p>Dr. Jones</p>

<h2>Supervisors</h2>
{% for s in supervisors %}
{% if 3 > loop.index0 %}
<p>{{ s }}</p>
{% elif 4 > loop.index0 %}
<p>and {{ supervisors | length}} more...</p>
{% endif %}
{% endfor %}
</div>

<div class="card-footer text-center">
<a href="#" class="btn btn-primary">View Details
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</section>

<div class="card mb-3" style="width:50rem">
<div class="card-body">
<h1>Positions</h1>
{% for p in positions %}
{% if 10 > loop.index0 %}
<p class="card-text">{{ p }}</p>
{% endif %}
{% endfor %}
<a href="#" class="btn btn-primary">View Details</a>
</div>
</div>
</div>

{% endif %}


<!-- <div class="col-sm-4">
<section class="card members-card" aria-labelledby="members-title">
<div class="card-body">

<div class="media">
<div class="media-left">
<span class="members-card-icon" aria-hidden="true">
<i class="fa fa-users"></i>
</span>
</div>

<div class="media-body media-middle">
<h3 id="members-title" class="media-heading card-title">
<strong>Members</strong>
</h3>
</div>
</div>

<h4 class="text-primary"><strong>Labor Coordinator</strong></h4>
<p class="card-text">Dr. Jones</p>

<h4 class="text-primary"><strong>Supervisors</strong></h4>
<p class="card-text">
Dr. Heggen<br>
Dr. Nakazawa
</p>

<p class="text-center">
<span class="members-card-cta">
<a href="#" class="btn btn-primary btn-sm members-card-btn">
View Details <span class="glyphicon glyphicon-chevron-right"></span>
</a>

</span>
</p>

</div>
</section>
</div> -->

{% endblock %}\




2 changes: 1 addition & 1 deletion app/templates/main/supervisorPortal.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ <h1 class="fs-1" data-toggle="collapse">Form Search</h1>
</div>
<br>
<div style="position: relative; z-index: 1;" id="sortOptions">
<div class="container-fluid" style="margin-bottom: -40px; float: right;">
<div class="container-fluid" style="margin-bottom: 15px; float: right;">
<label for="columnPicker">Sorting Options:</label>
<select id="columnPicker" name="columnPicker" class="selectpicker" title="Column">
<option value="term">Term</option>
Expand Down
15 changes: 11 additions & 4 deletions app/templates/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,32 @@ <h4>Labor History</h4>
{% if currentUser.supervisor %}
<div class="container-fluid">
<div class="panel panel-default">
<a class="adminTest" href="/">
<a href="/">
<div {% if request.path =="/" %} class="panel-heading active"{% endif %} class="panel-heading" tabindex="5">
<h4>Supervisor Portal</h4>
</div>
</a>
</div>
<div class="panel panel-default">
<a href="/department">
<div {% if "/department" in request.path %} class="panel-heading active"{% endif %} class="panel-heading" tabindex="5.5">
<h4>Department Portal</h4>
</div>
</a>
</div>
{% endif %}
{% if currentUser.supervisor or (currentUser.student and currentUser.isLaborAdmin) %}
<div class="panel panel-default">
<a class="adminTest" href="/laborstatusform">
<div {% if request.path == "/laborstatusform" %} class="panel-heading active"{% endif %} class="panel-heading" tabindex="5">
<a href="/laborstatusform">
<div {% if request.path == "/laborstatusform" %} class="panel-heading active"{% endif %} class="panel-heading" tabindex="6">
<h4>New Labor Status Form</h4>
</div>
</a>
</div>
{% endif %}
{% if currentUser.supervisor or (currentUser.student and currentUser.isLaborAdmin) %}
<div class="panel panel-default">
<a class="adminTest" href="/main/search">
<a href="/main/search">
<div {% if request.path =="/main/search" %} class="panel-heading active"{% endif %} class="panel-heading" tabindex="7">
<h4>Student Search</h4>
</div>
Expand Down
Loading