From b417d7b9bdf758f02f87d6a98bdd122be8667e9f Mon Sep 17 00:00:00 2001 From: bledsoef Date: Mon, 17 Mar 2025 19:03:51 -0400 Subject: [PATCH 01/59] got most the way done with editing and viewing functionality --- app/controllers/minor/routes.py | 36 +++++++++++++++++-- app/logic/minor.py | 19 ++++++++++ app/static/js/cceMinorProposalManagement.js | 15 ++++++++ .../minor/cceMinorProposalManagement.html | 2 +- .../minor/companyOrganizationInformation.html | 8 ++--- app/templates/minor/profile.html | 1 + .../minor/requestOtherEngagement.html | 30 +++++++++------- app/templates/minor/summerExperience.html | 3 +- .../minor/supervisorInformation.html | 6 ++-- 9 files changed, 96 insertions(+), 24 deletions(-) create mode 100644 app/static/js/cceMinorProposalManagement.js diff --git a/app/controllers/minor/routes.py b/app/controllers/minor/routes.py index 35063dd7e..667ede871 100644 --- a/app/controllers/minor/routes.py +++ b/app/controllers/minor/routes.py @@ -3,10 +3,11 @@ from app.controllers.minor import minor_bp from app.models.user import User +from app.models.cceMinorProposal import CCEMinorProposal from app.models.term import Term from app.logic.fileHandler import FileHandler from app.logic.utils import selectSurroundingTerms, getFilesFromRequest -from app.logic.minor import createOtherEngagementRequest, setCommunityEngagementForUser, getSummerExperience, getEngagementTotal, createSummerExperience, getProgramEngagementHistory, getCourseInformation, getCommunityEngagementByTerm, getCCEMinorProposals +from app.logic.minor import createOtherEngagementRequest, updateOtherEngagementRequest, setCommunityEngagementForUser, getSummerExperience, getEngagementTotal, createSummerExperience, updateSummerExperience, getProgramEngagementHistory, getCourseInformation, getCommunityEngagementByTerm, getCCEMinorProposals @minor_bp.route('/profile//cceMinor', methods=['GET']) def viewCceMinor(username): @@ -39,10 +40,39 @@ def requestOtherEngagement(username): return redirect(url_for('minor.viewCceMinor', username=username)) return render_template("minor/requestOtherEngagement.html", + editable = True, user = User.get_by_id(username), selectableTerms = selectSurroundingTerms(g.current_term), - allTerms = getSummerExperience(username)) + otherEngagement = None) +@minor_bp.route('/cceMinor/editOtherEngagement/', methods=['GET', 'POST']) +@minor_bp.route('/cceMinor/viewOtherEngagement/', methods=['GET']) +@minor_bp.route('/cceMinor/viewSummerExperience/', methods=['GET']) +@minor_bp.route('/cceMinor/editSummerExperience/', methods=['GET', 'POST']) +def editOrViewProposal(proposalID: int): + proposal = CCEMinorProposal.get_by_id(int(proposalID)) + if not (g.current_user.isAdmin or g.current_user.username == proposal.student): + return abort(403) + + if request.method == "GET" and 'view' in request.path: + return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/requestSummerExperience.html", + editable = False, + user = User.get_by_id(proposal.student), + proposal = proposal) + + if request.method == "POST": + if "OtherEngagement" in request.path: + updateOtherEngagementRequest(proposalID, request.form) + else: + updateSummerExperience(proposalID, request.form) + + return redirect(url_for('minor.viewCceMinor', username=proposal.student)) + + return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/requestSummerExperience.html", + editable = True, + selectableTerms = selectSurroundingTerms(g.current_term, summerOnly=False if 'OtherEngagement' else True), + user = User.get_by_id(proposal.student), + proposal = proposal) @minor_bp.route('/cceMinor//summerExperience', methods=['GET', 'POST']) def requestSummerExperience(username): @@ -60,7 +90,7 @@ def requestSummerExperience(username): summerTerms = selectSurroundingTerms(g.current_term, summerOnly=True) return render_template("minor/summerExperience.html", - summerTerms = summerTerms, + selectableTerms = summerTerms, user = User.get_by_id(username), ) diff --git a/app/logic/minor.py b/app/logic/minor.py index c59808749..8ac88af7a 100644 --- a/app/logic/minor.py +++ b/app/logic/minor.py @@ -38,6 +38,18 @@ def createSummerExperience(username, formData): print(f"Error saving summer experience: {e}") raise e +def updateSummerExperience(proposalID, formData): + """ + Given the username of the student and the formData which includes all of + the SummerExperience information, create a new SummerExperience object. + """ + try: + contentAreas = ', '.join(formData.getlist('contentArea')) # Combine multiple content areas + CCEMinorProposal.update(contentAreas=contentAreas, **formData).where(CCEMinorProposal.id == proposalID).execute() + except Exception as e: + print(f"Error saving summer experience: {e}") + raise e + def getCCEMinorProposals(username): proposalList = [] @@ -263,6 +275,13 @@ def createOtherEngagementRequest(username, formData): student = user, **formData ) + +def updateOtherEngagementRequest(proposalID, formData): + """ + Update an existing CCEMinorProposal entry based off of the form data + """ + + CCEMinorProposal.update(**formData).where(CCEMinorProposal.id == proposalID).execute() def saveSummerExperience(username, summerExperience, currentUser): """ diff --git a/app/static/js/cceMinorProposalManagement.js b/app/static/js/cceMinorProposalManagement.js new file mode 100644 index 000000000..cbe05a3c9 --- /dev/null +++ b/app/static/js/cceMinorProposalManagement.js @@ -0,0 +1,15 @@ +$(document).ready(function() { + console.log("hola") + +}) +function changeAction(action){ + console.log(action) + let proposalID = action.id; + let proposalType = $(action).data('type') + let proposalAction = action.value; + // decides what to do based on selection + if (proposalAction == "Edit"){ + location = `/cceMinor/edit${proposalType.replace(/\s+/g, '')}/` + proposalID; + } + } +window.changeAction = changeAction; \ No newline at end of file diff --git a/app/templates/minor/cceMinorProposalManagement.html b/app/templates/minor/cceMinorProposalManagement.html index dc9c6e47d..eedd71157 100644 --- a/app/templates/minor/cceMinorProposalManagement.html +++ b/app/templates/minor/cceMinorProposalManagement.html @@ -24,7 +24,7 @@ {{proposal['status']}} - diff --git a/app/templates/minor/companyOrganizationInformation.html b/app/templates/minor/companyOrganizationInformation.html index c46f9efef..698c0187c 100644 --- a/app/templates/minor/companyOrganizationInformation.html +++ b/app/templates/minor/companyOrganizationInformation.html @@ -6,14 +6,14 @@

Company/Organization Information

- +

- +

@@ -21,10 +21,10 @@

Company/Organization Information

- +
- +
\ No newline at end of file diff --git a/app/templates/minor/profile.html b/app/templates/minor/profile.html index b2af14f5d..d3dc24ca1 100644 --- a/app/templates/minor/profile.html +++ b/app/templates/minor/profile.html @@ -4,6 +4,7 @@ {% block scripts %} {{ super() }} + diff --git a/app/templates/minor/requestOtherEngagement.html b/app/templates/minor/requestOtherEngagement.html index 9ca2bb090..0496ab243 100644 --- a/app/templates/minor/requestOtherEngagement.html +++ b/app/templates/minor/requestOtherEngagement.html @@ -17,6 +17,7 @@ {% endblock %} {% block app_content %} + {% set viewing = (not editable) and (otherExperience != None) %}
@@ -27,16 +28,19 @@

Proposal for Other Community Engaged E Please fill out this form to submit a proposal for another community engaged experience that pertains to at least one of the four following key content areas: power and inequality, community and identity, civic literacy, or civic skills.

- +

- + {% for term in selectableTerms %} - + {% endfor %}
@@ -45,7 +49,7 @@

Proposal for Other Community Engaged E
- +
{% include "minor/companyOrganizationInformation.html" %} @@ -56,7 +60,7 @@

Proposal for Other Community Engaged E
- +
@@ -67,28 +71,30 @@

Experience Information

- +

- +

- +


-
- -
+ {% if not viewing %} +
+ +
+ {% endif %}
{% endblock %} \ No newline at end of file diff --git a/app/templates/minor/summerExperience.html b/app/templates/minor/summerExperience.html index 640a9d84b..bec84dade 100644 --- a/app/templates/minor/summerExperience.html +++ b/app/templates/minor/summerExperience.html @@ -17,6 +17,7 @@ {% endblock %} {% block app_content %} + {% set viewing = not {{editable}} and {{otherExperience}} %}
@@ -33,7 +34,7 @@

Proposal for Community-Engaged Summer Experience

diff --git a/app/templates/minor/supervisorInformation.html b/app/templates/minor/supervisorInformation.html index f774ace1d..d0cad7e32 100644 --- a/app/templates/minor/supervisorInformation.html +++ b/app/templates/minor/supervisorInformation.html @@ -6,7 +6,7 @@

Supervisor Information

- +
@@ -15,11 +15,11 @@

Supervisor Information

- +
- +
\ No newline at end of file From 54ec6788c14ab4f7c3325fd51893527931cc82c9 Mon Sep 17 00:00:00 2001 From: bledsoef Date: Wed, 19 Mar 2025 16:53:16 -0400 Subject: [PATCH 02/59] cleaned up formatting and working on file handling --- app/controllers/minor/routes.py | 3 + app/models/cceMinorProposal.py | 2 - .../minor/companyOrganizationInformation.html | 16 +++- .../minor/requestOtherEngagement.html | 32 +++++-- app/templates/minor/summerExperience.html | 83 +++++++++++++------ .../minor/supervisorInformation.html | 12 ++- 6 files changed, 107 insertions(+), 41 deletions(-) diff --git a/app/controllers/minor/routes.py b/app/controllers/minor/routes.py index 667ede871..e8c05d0fc 100644 --- a/app/controllers/minor/routes.py +++ b/app/controllers/minor/routes.py @@ -57,6 +57,7 @@ def editOrViewProposal(proposalID: int): if request.method == "GET" and 'view' in request.path: return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/requestSummerExperience.html", editable = False, + contentAreas = proposal.contentAreas.split(", ") if proposal.contentAreas else [], user = User.get_by_id(proposal.student), proposal = proposal) @@ -70,6 +71,7 @@ def editOrViewProposal(proposalID: int): return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/requestSummerExperience.html", editable = True, + contentAreas = proposal.contentAreas.split(", ") if proposal.contentAreas else [], selectableTerms = selectSurroundingTerms(g.current_term, summerOnly=False if 'OtherEngagement' else True), user = User.get_by_id(proposal.student), proposal = proposal) @@ -91,6 +93,7 @@ def requestSummerExperience(username): return render_template("minor/summerExperience.html", selectableTerms = summerTerms, + contentAreas = [], user = User.get_by_id(username), ) diff --git a/app/models/cceMinorProposal.py b/app/models/cceMinorProposal.py index 4e2f0877f..d523d7736 100644 --- a/app/models/cceMinorProposal.py +++ b/app/models/cceMinorProposal.py @@ -21,8 +21,6 @@ class CCEMinorProposal(baseModel): supervisorEmail = CharField() totalHours = IntegerField(null=True) totalWeeks = IntegerField(null=True) - description = TextField() - filename = CharField(null=True) createdOn = DateTimeField(default=datetime.datetime.now) createdBy = ForeignKeyField(User) status = CharField(constraints=[Check("status in ('Approved', 'Pending', 'Denied')")]) diff --git a/app/templates/minor/companyOrganizationInformation.html b/app/templates/minor/companyOrganizationInformation.html index 698c0187c..29f4d98f8 100644 --- a/app/templates/minor/companyOrganizationInformation.html +++ b/app/templates/minor/companyOrganizationInformation.html @@ -6,14 +6,18 @@

Company/Organization Information

- +

- +

@@ -21,10 +25,14 @@

Company/Organization Information

- +
- +
\ No newline at end of file diff --git a/app/templates/minor/requestOtherEngagement.html b/app/templates/minor/requestOtherEngagement.html index 0496ab243..637eafd48 100644 --- a/app/templates/minor/requestOtherEngagement.html +++ b/app/templates/minor/requestOtherEngagement.html @@ -38,9 +38,15 @@

Proposal for Other Community Engaged E {% if viewing %} disabled {% endif %}> - + {% for term in selectableTerms %} - + {% endfor %}

@@ -49,7 +55,9 @@

Proposal for Other Community Engaged E
- +
{% include "minor/companyOrganizationInformation.html" %} @@ -60,7 +68,8 @@

Proposal for Other Community Engaged E
- +
@@ -71,28 +80,35 @@

Experience Information

- +

- +

- +


{% if not viewing %}
- +
{% endif %}
diff --git a/app/templates/minor/summerExperience.html b/app/templates/minor/summerExperience.html index bec84dade..f70674a34 100644 --- a/app/templates/minor/summerExperience.html +++ b/app/templates/minor/summerExperience.html @@ -17,7 +17,7 @@ {% endblock %} {% block app_content %} - {% set viewing = not {{editable}} and {{otherExperience}} %} + {% set viewing = not editable and otherExperience %}
@@ -32,10 +32,19 @@

Proposal for Community-Engaged Summer Experience

- + {% for term in selectableTerms %} - + {% endfor %}
@@ -56,61 +65,87 @@

Experience Information

-
+ +

- +
- +
- +
- +
- +
- +
-
+ + +

- +
- +
- +
- +


- +
- +

- + +

- + +


- -
- -
+ {% if not viewing %} +
+ +
+ {% endif %}

diff --git a/app/templates/minor/supervisorInformation.html b/app/templates/minor/supervisorInformation.html index d0cad7e32..01a69e5fd 100644 --- a/app/templates/minor/supervisorInformation.html +++ b/app/templates/minor/supervisorInformation.html @@ -6,7 +6,9 @@

Supervisor Information

- +
@@ -15,11 +17,15 @@

Supervisor Information

- +
- +
\ No newline at end of file From c54d7d0b5be1bffe6651555cd28638b82cd23e75 Mon Sep 17 00:00:00 2001 From: bledsoef Date: Thu, 20 Mar 2025 17:06:04 -0400 Subject: [PATCH 03/59] almost done with PR --- app/controllers/minor/routes.py | 6 ++- app/logic/minor.py | 2 + app/static/js/cceMinorProposalManagement.js | 5 ++- app/static/js/minorProfilePage.js | 8 +++- .../minor/requestOtherEngagement.html | 20 +++++---- app/templates/minor/summerExperience.html | 44 +++++++++++++------ 6 files changed, 58 insertions(+), 27 deletions(-) diff --git a/app/controllers/minor/routes.py b/app/controllers/minor/routes.py index e8c05d0fc..ba6073740 100644 --- a/app/controllers/minor/routes.py +++ b/app/controllers/minor/routes.py @@ -55,10 +55,12 @@ def editOrViewProposal(proposalID: int): return abort(403) if request.method == "GET" and 'view' in request.path: - return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/requestSummerExperience.html", + selectedTerm = Term.get_by_id(proposal.term) + return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/summerExperience.html", editable = False, contentAreas = proposal.contentAreas.split(", ") if proposal.contentAreas else [], user = User.get_by_id(proposal.student), + selectedTerm = selectedTerm, proposal = proposal) if request.method == "POST": @@ -69,7 +71,7 @@ def editOrViewProposal(proposalID: int): return redirect(url_for('minor.viewCceMinor', username=proposal.student)) - return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/requestSummerExperience.html", + return render_template("minor/requestOtherEngagement.html" if 'OtherEngagement' in request.path else "minor/summerExperience.html", editable = True, contentAreas = proposal.contentAreas.split(", ") if proposal.contentAreas else [], selectableTerms = selectSurroundingTerms(g.current_term, summerOnly=False if 'OtherEngagement' else True), diff --git a/app/logic/minor.py b/app/logic/minor.py index 8ac88af7a..f86a72e8f 100644 --- a/app/logic/minor.py +++ b/app/logic/minor.py @@ -24,6 +24,8 @@ def createSummerExperience(username, formData): the SummerExperience information, create a new SummerExperience object. """ try: + # if the Total Hours and Total Weeks fields are disabled they will default to 0 which will actually mean over 300 + # (don't blame us blame CELTS) user = User.get(User.username == username) contentAreas = ', '.join(formData.getlist('contentArea')) # Combine multiple content areas CCEMinorProposal.create( diff --git a/app/static/js/cceMinorProposalManagement.js b/app/static/js/cceMinorProposalManagement.js index cbe05a3c9..5cfa22b69 100644 --- a/app/static/js/cceMinorProposalManagement.js +++ b/app/static/js/cceMinorProposalManagement.js @@ -1,9 +1,7 @@ $(document).ready(function() { - console.log("hola") }) function changeAction(action){ - console.log(action) let proposalID = action.id; let proposalType = $(action).data('type') let proposalAction = action.value; @@ -11,5 +9,8 @@ function changeAction(action){ if (proposalAction == "Edit"){ location = `/cceMinor/edit${proposalType.replace(/\s+/g, '')}/` + proposalID; } + if (proposalAction == "View"){ + location = `/cceMinor/view${proposalType.replace(/\s+/g, '')}/` + proposalID; + } } window.changeAction = changeAction; \ No newline at end of file diff --git a/app/static/js/minorProfilePage.js b/app/static/js/minorProfilePage.js index defa20037..87105914c 100644 --- a/app/static/js/minorProfilePage.js +++ b/app/static/js/minorProfilePage.js @@ -16,6 +16,10 @@ $(document).ready(function() { } }) + $('#exitButton').on('click', function() { + let username = $("#username").val() + window.location.href = `/profile/${username}/cceMinor` + }) // ************** SUSTAINED COMMUNITY ENGAGEMENTS ************** // $('.engagement-row').on("click", function() { showEngagementInformation($(this).data('engagement-data')); @@ -199,8 +203,10 @@ function toggleUnder300HoursTextarea() { var conditionalTextBox = $('#hoursBelow300Container'); if (yesRadio.is(':checked')) { conditionalTextBox.hide() + $('#totalHours').val(300) } else { - conditionalTextBox.show() + conditionalTextBox.show() + $('#totalHours').val('') } } diff --git a/app/templates/minor/requestOtherEngagement.html b/app/templates/minor/requestOtherEngagement.html index 637eafd48..a88950028 100644 --- a/app/templates/minor/requestOtherEngagement.html +++ b/app/templates/minor/requestOtherEngagement.html @@ -42,6 +42,11 @@

Proposal for Other Community Engaged E {% if not proposal %} selected {% endif %}> Select Year + {% if viewing %} + + {% endif %} {% for term in selectableTerms %}