-
Notifications
You must be signed in to change notification settings - Fork 8
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
thealphagurlux
wants to merge
41
commits into
development
Choose a base branch
from
interface-graduation-management
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 e162b33
AModified html and route
Karina-Agliullova 29e2a05
Imported graduationManagement in __init.py__
2a57481
Added datatable, checkbox, styling, UI, and redirecting
Karina-Agliullova f55fc2d
Modified js and route
Karina-Agliullova 74c7dc8
Added buttons, fixed checkboxes
Karina-Agliullova d6cc41b
Added buttons
Karina-Agliullova 031a7b8
changed filters on grad management drop down menu
3367862
Fixed filter for bonner students
Karina-Agliullova 12b715c
got rid of print statements
Karina-Agliullova f25cd03
made changes to grad manag css file.
4befc1c
Fixed the buttons
Karina-Agliullova b354065
Adjusted positioning of the term bar in graduation management
201e985
Removed Header and dropdown menu for term on Grad Managment Page.
b01bbf4
added bonner dropdown menu and added new filter function in grad mana…
d9cbb52
Added JS for bonner cohorts menu
4c391de
Fixed the dropdowns
Karina-Agliullova 1de2f16
Changes to table bonner cohorts
Karina-Agliullova f20b904
Users can now be passed into gradmanagment.js
1f28bea
Filter to show bonner stundents by year now works, but the filter is …
d797b30
added break to loop in grad management loop
5355c1a
Merge branch 'interface-graduation-management' of https://github.com/…
a25036b
git
13f81eb
Made it to where the table clears upon selecting a
1d1b1c8
Fixed the sidebar and bonner cohort drop down menu text
061de75
added CCE users to be passed from backend to javascript
2524f8f
CCE filter now works on graduation table
1ca4b3a
export functionality
Karina-Agliullova bd29bec
Fixed export button, it works but not for all filters
Karina-Agliullova ed01ecd
Fixed a few things with export, still need more work
Karina-Agliullova 0bd62fe
added delay to messages on gradmanagment js
e783ebc
Merge branch 'interface-graduation-management' of https://github.com/…
749fabf
Add condition to where only one flash message shows up at a time on g…
2b405cf
modified flash message in grad managment
8bc7960
moved cohort filter to the left, modified css file.
3107435
slight adjustment to cohort button in grad management ccs file.
82c82e9
modiefied css
331b906
fixed the filter being passed through to the makegradstudentxls
ccc54ea
added some comments to gradmanagement.js and logic
4b545c1
Comment out the bonner filter portions of code in the graduationManag…
78a6ff8
Merge branch 'development' into interface-graduation-management
WackyWeaver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | ||
""" | ||
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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.