Skip to content

Commit

Permalink
Merge branch 'development' into allTrainingTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianRamsay authored Jul 17, 2024
2 parents 3253075 + 70b9e75 commit f3271cf
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 21 deletions.
5 changes: 5 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def load_currentTerm():
session['current_term'] = model_to_dict(term)
g.current_term = term

import datetime
@app.before_request
def load_currentDateTime():
g.currentDateTime = datetime.datetime.now()

from flask import request
@app.context_processor
def load_visibleAccordion():
Expand Down
19 changes: 16 additions & 3 deletions app/controllers/admin/minor.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
from flask import render_template, g, abort
from flask import render_template, g, abort, request, redirect, url_for

from app.models.user import User

from app.controllers.admin import admin_bp

from app.logic.minor import getMinorInterest, getMinorProgress
from app.logic.minor import getMinorInterest, getMinorProgress, toggleMinorInterest

@admin_bp.route('/admin/cceMinor', methods=['GET'])
@admin_bp.route('/admin/cceMinor', methods=['POST','GET'])
def manageMinor():

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

if request.method == 'POST':
interested_students = request.form.getlist('interestedStudents[]')

for i in interested_students:
user = User.get(username=i)
if not user.minorInterest:
toggleMinorInterest(i)


interestedStudentsList = getMinorInterest()
interestedStudentEmailString = ';'.join([student['email'] for student in interestedStudentsList])
sustainedEngagement = getMinorProgress()


return render_template('/admin/cceMinor.html',
interestedStudentsList = interestedStudentsList,
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def eventDisplay(eventId):
eventData['timeEnd'] = event.timeEnd.strftime("%-I:%M %p")
eventData['startDate'] = event.startDate.strftime("%m/%d/%Y")
eventCountdown = getCountdownToEvent(event)


# Identify the next event in a recurring series
if event.recurringId:
Expand All @@ -320,7 +320,8 @@ def eventDisplay(eventId):
filepaths=filepaths,
image=image,
pageViewsCount=pageViewsCount,
eventCountdown=eventCountdown)
eventCountdown=eventCountdown
)



Expand Down
3 changes: 2 additions & 1 deletion app/static/js/manageVolunteers.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ $(document).ready(function() {
url: `/addVolunteersToEvent/${eventId}`,
type: "POST",
data: {"selectedVolunteers": selectedVolunteers, "ajax": true},
success: function(s){
success:
function(s){
location.reload()
},
error: function(request, status, error){
Expand Down
60 changes: 60 additions & 0 deletions app/static/js/minorAdminPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import searchUser from './searchUser.js'
function emailAllInterested(){
// Read all student emails from the input as a string and put them in mailto format
let interestedStudentEmails = $("#interestedStudentEmails").val();
Expand Down Expand Up @@ -37,6 +38,65 @@ $(document).ready(function() {




function getInterestedStudents() {
// get all the checkboxes and return a list of users who's
// checkboxes are selected
let checkboxesDisplayedInModal = $("#addInterestedStudentsModal input[type=checkbox]:checked")
let interestedStudentsList = []
checkboxesDisplayedInModal.each(function(index, checkbox){
interestedStudentsList.push(checkbox["value"])
})
return interestedStudentsList
}

function updateInterestedStudents(){
let interestedStudentList = getInterestedStudents()
let buttonContent = $("#addInterestedStudentsbtn").html()
if (interestedStudentList.length > 1) {
if (buttonContent.charAt(buttonContent.length-1) != "s") {
// make the button text plural if there are multiple users selected
$("#addInterestedStudentsbtn").html(buttonContent + "s")
}
} else if (buttonContent.charAt(buttonContent.length-1) == "s") {
// remove the s if it is plural and we have less than 2 volunteers
$("#addInterestedStudentsbtn").html(buttonContent.slice(0, -1))
}
// disable the submit button if there are no selectedCheckboxes
if (interestedStudentList.length == 0) {

$("#addInterestedStudentsbtn").prop("disabled", true)
} else {
$("#addInterestedStudentsbtn").prop("disabled", false)
}
}

var userlist = []
function callback(selected) {
let user = $("#addStudentInput").val()
if (userlist.includes(selected["username"]) == false){
userlist.push(user)
let i = userlist.length;
$("#interestedStudentList").prepend("<li class id= 'interestedStudentElement"+i+"'> </li>")
$("#interestedStudentElement"+i).append("<input name = 'interestedStudents[]' type='checkbox' id= 'userlistCheckbox"+i+"' checked value='" + user +"' > </input>",
"<label form for= 'userlistCheckbox"+i+"'>"+ selected["firstName"]+ " " + selected["lastName"] +"</label>")
$("#userlistCheckbox"+i).click(updateInterestedStudents)
updateInterestedStudents()
}
else {
msgFlash("User already selected.")
}
}
$("#addInterestedStudentsbtn").prop('disabled', true);
+
$("#addInterestedStudentsModal").on("shown.bs.modal", function() {
$('#addStudentInput').focus();
});

$("#addStudentInput").on("input", function() {
searchUser("addStudentInput", callback, true, "addInterestedStudentsModal");
});

$(document).ready(function() {
$('#engagedStudentsTable').DataTable();
$('#interestedStudentsTable').DataTable();
Expand Down
34 changes: 33 additions & 1 deletion app/templates/admin/cceMinor.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{% endblock %}
{% endblock %}
{% block app_content %}

<h1 class="text-center mb-5">CCE Minor Management</h1>
<h2>CCE Minor Progress</h2>
<table class="display" id="engagedStudentsTable">
Expand Down Expand Up @@ -50,6 +49,7 @@ <h2>CCE Minor Progress</h2>
<h2>Interested Students</h2>
</div>
<div class="col-auto">
<a class="btn btn-success" role="button" href="#" data-bs-toggle="modal" data-bs-target="#addInterestedStudentsModal" style="margin:5px;">Add Students</a>
<button class="btn btn-primary" id="emailAllInterested">Email All</button>
</div>
</div>
Expand Down Expand Up @@ -80,4 +80,36 @@ <h2>Interested Students</h2>
<input id="interestedStudentEmails" hidden value="{{interestedStudentEmailString}}"/>
</tbody>
</table>

<!-- ################# Modal ################# -->

<div class="modal fade float-start" id="addInterestedStudentsModal" tabindex="-1" aria-labelledby="addInterestedStudentsLbl" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{modalTitle}}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="input-group">
<div class="form-group input-group-x form-outline ui-widget" style="width:80%;">
<input type="input" id="addStudentInput" class="form-control" placeholder="Search" autocomplete="off"/>
</div>
<button type="button" class="btn btn-primary btn-sm">
<i class="bi bi-search ms-0"></i>
</button>
</div>
</div>
<form action = "{{ url_for('admin.manageMinor')}}" method = 'POST'>
<ul
class="list-unstyled mx-3 mt-2" id= "interestedStudentList">
</ul>
<div class="modal-footer">
<button type="button" class="btn btn-secondary me-auto" data-bs-dismiss="modal">Close</button>
<button id="addInterestedStudentsbtn" type="submit" class="btn btn-success" disabled>Add Students</button>
</div>
</form>
</div>
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion app/templates/admin/createEvent.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{% extends "eventNav.html"%}
{% endif %}

{% set eventPast = event.isPastStart if not isNewEvent else False %}
{% set eventPast = event.isPastEnd if not isNewEvent else False %}
{% set tabName = 'edit' %}


Expand Down
19 changes: 13 additions & 6 deletions app/templates/eventNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
{% if g.current_user.isAdmin %}
{{ eventheader(page_title, event, 'large', isNewEvent) }}
{% endif %}
{% set alertClass = "alert-danger" if isPastEnd else "alert-warning"%}
{% set display = "" if isPastEnd or event.isCanceled else "d-none"%}
{% set isInProg = not event.isPastEnd and event.isPastStart %}
{% set display = "" if eventPast or event.isCanceled or isInProg else "d-none"%}
{% set alertClass = ("alert-success" if isInProg else ( "alert-danger" if eventPast else "alert-warning")) %}
{% set event_year = event.endDate.strftime("%Y") | int %}
{% set currentYear = g.currentDateTime.year | int %}
{% set formatted_date = event.endDate.strftime("%B %d %Y") if currentYear > event_year else event.endDate.strftime("%B %d") %}

<div class = "{{alertClass}} {{display}} mb-2 pb-2 pt-2" role="alert">
{% if isPastEnd and event.isCanceled %}
{% if eventPast and event.isCanceled %}
This is a past event and it was canceled.
{% elif isPastEnd %}
This is a past event.
{% elif isInProg %}
This event is in-progress! It started at {{event.timeStart.strftime("%I:%M %p")}}.
{% elif eventPast %}
This event ended on {{ formatted_date }} at {{ event.timeEnd.strftime("%I:%M %p") }}.
{% elif event.isCanceled %}
This event has been canceled.
{% endif %}
Expand Down Expand Up @@ -57,4 +64,4 @@

{% endif %}
{% endblock %}
{% endblock %}
{% endblock %}
6 changes: 4 additions & 2 deletions app/templates/eventView.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{% set isPastEnd = event.isPastEnd %}
{% set tabName = 'view' %}
{% extends "eventNav.html"%}
<!-- Without eventPast view event cannot use it when called through eventNav -->
{% set eventPast = event.isPastStart if not isNewEvent else False %}

{% block scripts %}
{{super()}}
Expand Down Expand Up @@ -66,7 +68,7 @@ <h5 id="location"style="margin: 0;">Location:</h5>
<br>
<div>
{% if eventData.isRsvpRequired %}
{% if not eventPast %}
{% if not event.isPastStart %}
{% if userHasRSVPed %}
<button type="submit" class="btn btn-danger" value="{{eventData.id}}" id="removeRsvpBtn">Remove RSVP</button>
{% elif eventData.isRsvpRequired %}
Expand Down Expand Up @@ -128,7 +130,7 @@ <h3>Contact Information:</h3>
{% endif %}
<br>
</div>
<div class="col-md-6">
<div class="col-md-6">
{% if programTrainings %}
{% if program or not eventData.isAllVolunteerTraining %}
<h3>Program Trainings:</h3>
Expand Down
7 changes: 2 additions & 5 deletions app/templates/events/manageVolunteers.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
{% extends "eventNav.html" %}



{% block scripts %}
{{super()}}
<script type="module" src="/static/js/manageVolunteers.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.11.3/r-2.2.9/datatables.min.js"></script>
{% endblock %}





{% block styles %}

{{super()}}
Expand Down Expand Up @@ -367,4 +364,4 @@ <h5 class="modal-title">{{modalTitle}}</h5>
</div>
</div>
</div>
{% endblock %}
{% endblock %}

0 comments on commit f3271cf

Please sign in to comment.