Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface graduation management #1355

Open
wants to merge 41 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4f963ed
Added graduation management to the sidebar, added html, started the r…
Karina-Agliullova Sep 6, 2024
e162b33
AModified html and route
Karina-Agliullova Sep 10, 2024
29e2a05
Imported graduationManagement in __init.py__
Sep 12, 2024
2a57481
Added datatable, checkbox, styling, UI, and redirecting
Karina-Agliullova Sep 12, 2024
f55fc2d
Modified js and route
Karina-Agliullova Sep 16, 2024
74c7dc8
Added buttons, fixed checkboxes
Karina-Agliullova Sep 17, 2024
d6cc41b
Added buttons
Karina-Agliullova Sep 17, 2024
031a7b8
changed filters on grad management drop down menu
Sep 19, 2024
3367862
Fixed filter for bonner students
Karina-Agliullova Sep 20, 2024
12b715c
got rid of print statements
Karina-Agliullova Sep 20, 2024
f25cd03
made changes to grad manag css file.
Sep 20, 2024
4befc1c
Fixed the buttons
Karina-Agliullova Sep 24, 2024
b354065
Adjusted positioning of the term bar in graduation management
Sep 24, 2024
201e985
Removed Header and dropdown menu for term on Grad Managment Page.
Sep 26, 2024
b01bbf4
added bonner dropdown menu and added new filter function in grad mana…
Sep 26, 2024
d9cbb52
Added JS for bonner cohorts menu
Oct 1, 2024
4c391de
Fixed the dropdowns
Karina-Agliullova Oct 1, 2024
1de2f16
Changes to table bonner cohorts
Karina-Agliullova Oct 9, 2024
f20b904
Users can now be passed into gradmanagment.js
Oct 10, 2024
1f28bea
Filter to show bonner stundents by year now works, but the filter is …
Oct 15, 2024
d797b30
added break to loop in grad management loop
Oct 15, 2024
5355c1a
Merge branch 'interface-graduation-management' of https://github.com/…
Oct 15, 2024
a25036b
git
Oct 15, 2024
13f81eb
Made it to where the table clears upon selecting a
Oct 15, 2024
1d1b1c8
Fixed the sidebar and bonner cohort drop down menu text
Oct 17, 2024
061de75
added CCE users to be passed from backend to javascript
Oct 22, 2024
2524f8f
CCE filter now works on graduation table
Oct 22, 2024
1ca4b3a
export functionality
Karina-Agliullova Oct 23, 2024
bd29bec
Fixed export button, it works but not for all filters
Karina-Agliullova Oct 24, 2024
ed01ecd
Fixed a few things with export, still need more work
Karina-Agliullova Oct 25, 2024
0bd62fe
added delay to messages on gradmanagment js
Oct 25, 2024
e783ebc
Merge branch 'interface-graduation-management' of https://github.com/…
Oct 25, 2024
749fabf
Add condition to where only one flash message shows up at a time on g…
Oct 29, 2024
2b405cf
modified flash message in grad managment
Nov 7, 2024
8bc7960
moved cohort filter to the left, modified css file.
Nov 12, 2024
3107435
slight adjustment to cohort button in grad management ccs file.
Nov 12, 2024
82c82e9
modiefied css
Nov 12, 2024
331b906
fixed the filter being passed through to the makegradstudentxls
Nov 15, 2024
ccc54ea
added some comments to gradmanagement.js and logic
Dec 3, 2024
4b545c1
Comment out the bonner filter portions of code in the graduationManag…
Dec 12, 2024
78a6ff8
Merge branch 'development' into interface-graduation-management
WackyWeaver Jan 8, 2025
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
39 changes: 39 additions & 0 deletions admin/graduationManagement
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% set title = "Graduation Management" %}
{% extends "base.html" %}

{% block scripts %}
{{super()}}
<script type="module" src="/static/js/graduationManagement.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>

{% block styles %}
{{super()}}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
{% endblock %}
{% endblock %}

{% block app_content %}
<h1 class="text-center mb-5">Graduation Management</h1>
<h2>Graduating/Graduated Students</h2>
<table class="display" id="gradStudentsTable">
<thead>
<tr>
<th>Name</th>
<th>Graduated</th>
<th>Class Level</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ user.hasGraduated }}</td>
<td>{{ user.classLevel }}</td>

</tr>
{%endfor%}
</tbody>
</table>

{% endblock %}
1 change: 1 addition & 0 deletions app/controllers/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
from app.controllers.admin import userManagement
from app.controllers.admin import volunteers
from app.controllers.admin import minor
from app.controllers.admin import graduationManagement

72 changes: 72 additions & 0 deletions app/controllers/admin/graduationManagement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from flask import render_template, g, abort, request, redirect, url_for, flash, send_file
from app.models.user import User
from app.controllers.admin import admin_bp
from app.logic.bonner import getBonnerCohorts
from app.models.bonnerCohort import BonnerCohort

from app.logic.graduationManagement import getGraduatedStudent, removeGraduatedStudent, makeGraduatedXls
from app.logic.minor import getMinorProgress


@admin_bp.route('/admin/graduationManagement', methods=['GET'])
def gradManagement():

if not g.current_user.isAdmin:
abort(403)

users = User.select(User.username, User.hasGraduated, User.classLevel, User.firstName, User.lastName).where(User.classLevel=='Senior')

CCEusers = getMinorProgress()

bonnercohorts = getBonnerCohorts()

return render_template('/admin/graduationManagement.html',
users = users,
bonnercohorts = bonnercohorts,
CCEstudents = CCEusers)


@admin_bp.route('/<username>/hasGraduated/', methods=['POST'])
def hasGraduated(username):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "has" at the beginning of the function was a bit confusing, because it is an attributing verb. I usually associate it with a check, like "isDead" or "hasDied". Maybe change this use a better helping verb like "setGraduationStatus" or something similar.

"""
This function
username: unique value of a user to correctly identify them
"""
try:
success = getGraduatedStudent(username)
if success:
return "", 200
else:
return "", 500

except Exception as e:
print(e)
return "Error Updating Graduation Status", 500

@admin_bp.route('/<username>/hasNotGraduated/', methods=['POST'])
def hasNotGraduated(username):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

"""
This function removes
username: unique value of a user to correctly identify them
"""
try:
removed = removeGraduatedStudent(username)
if removed:
flash("Graduation status has been updated!", "success")
return "", 200
else:
flash("Error!", "Failed to update graduation status.")
return "", 500
except Exception as e:
print(e)
return "Error Updating Graduation Status", 500

@admin_bp.route("/gradStudentsxls/<filterType>", methods=['GET'])
def gradsxls(filterType):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this camelCase to match the rest of the functions.

if not g.current_user.isCeltsAdmin:
abort(403)
print(filterType, '#####')
# filterType = request.args.get('filterType', 'all')
newfile = makeGraduatedXls(filterType)
return send_file(open(newfile, 'rb'), download_name='GraduatedStudents.xlsx', as_attachment=True)

104 changes: 104 additions & 0 deletions app/logic/graduationManagement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from collections import defaultdict
from typing import List, Dict
from playhouse.shortcuts import model_to_dict
from peewee import JOIN, fn, Case, DoesNotExist
import xlsxwriter
from app import app

from app.models.user import User
from app.logic.minor import getMinorProgress
from app.logic.bonner import getBonnerCohorts
from app.models.bonnerCohort import BonnerCohort
from app.models.term import Term


def getGraduatedStudent(username):
"""
This function marks students as graduated
Parameters:
username: username of the user graduating
"""
gradStudent = User.get(User.username == username)
if gradStudent:
gradStudent.hasGraduated = True
gradStudent.save()
return True
return False

def removeGraduatedStudent(username):
"""
This function unmarks students as graduated
Parameters:
username: username of the user graduating

"""
notGradStudent = User.get(User.username == username)
if notGradStudent:
notGradStudent.hasGraduated = False
notGradStudent.save()
return True
return False

def makeGraduatedXls(filterType):
"""
Create and save a GraduatedStudent.xlsx file with all of the graduated students.
Working with XLSX files: https://xlsxwriter.readthedocs.io/index.html

Returns:
The file path and name to the newly created file, relative to the web root.
"""

print('filtertype:' , filterType, "#####")


CCEusers = getMinorProgress()
bonnercohorts = getBonnerCohorts()

filepath = app.config['files']['base_path'] + '/GraduatedStudents.xlsx'
workbook = xlsxwriter.Workbook(filepath, {'in_memory': True})
worksheet = workbook.add_worksheet('students')
bold = workbook.add_format({'bold': True})

worksheet.write('A1', 'Graduated Students', bold)
worksheet.set_column('A:A', 20)
prev_year = 1
row = 1

if filterType == 'all':
students = User.select().where(User.hasGraduated == True)
elif filterType == 'cce':
students = [student for student in CCEusers if student['hasGraduated']]
# elif filterType == 'bonner':
# students = BonnerCohort.select(BonnerCohort, User).join(User).where(User.hasGraduated == True)

# print('##### Student list')

# for name in User.select(User.username):

# print(name)

# print('##### Student list')
# print('bonner filter selected #####')
# elif filterType == 'bonnercohorts':
# students = [student for student in bonnercohorts if student['hasGraduated']]
else:
students = User.select()

for student in students:
# if filterType == 'bonner' and prev_year != student.year:
# row += 1
# prev_year = student.year
# worksheet.write(row, 0, f"{student.year} - {student.year+1}", bold)

if filterType == 'cce':
worksheet.write(row, 0, f"{student['firstName']} {student['lastName']}")
print('CCE student found #####')
else:
worksheet.write(row, 0, f"{student.firstName} {student.lastName}")
print(' (all) student found #####')

row += 1

workbook.close()

return filepath
33 changes: 33 additions & 0 deletions app/static/css/graduationManagement.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#selectAll-container {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-bottom: 15px;
}

.btn-group {
margin-right: 10px; /* Space between the dropdown and the buttons */

}

h1 {
margin-bottom: 0px;
margin-top: 10px;
}

.container {
margin-bottom: 20px; /* Adjust this as needed for proper spacing */
}

.w-25{
margin-bottom: 50px;

}


#cohortFilter{
position:absolute;
right: 170px;
top: -19px;

}
Loading
Loading