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

Email Ashley SLC submitted courses Issue#831 #850

Draft
wants to merge 16 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
06ac593
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/cel…
Karina-Agliullova Nov 10, 2022
23e2d08
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/cel…
Karina-Agliullova Nov 11, 2022
de46622
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/cel…
Karina-Agliullova Jan 14, 2023
e9ba74a
Added status for function
Karina-Agliullova Jan 18, 2023
b80abfd
added conditional in html file
thawpt Jan 18, 2023
c665f67
Merge branch 'slc-proposal-edit-permissions' of github.com:BCStudentS…
Karina-Agliullova Jan 20, 2023
aad325d
Added permissions for admins and faculty to edit slc proposals
Karina-Agliullova Jan 20, 2023
04387e7
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/cel…
Karina-Agliullova Jan 30, 2023
25674ea
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/cel…
Karina-Agliullova Feb 6, 2023
f5888fa
Merge branch 'development' of github.com:BCStudentSoftwareDevTeam/cel…
Karina-Agliullova Feb 10, 2023
3f0e06e
Started constructing a function for emailing Ashley
Karina-Agliullova Feb 13, 2023
1b7f1da
Added function to send email to Ashley
Karina-Agliullova Feb 17, 2023
7580bf3
Removed the smptlib and flask cors because it breaks everything
Karina-Agliullova Feb 20, 2023
2894c9c
Added a function for emailing Ashley
Karina-Agliullova Feb 20, 2023
72a3710
Modified the function, but it still needs more modification
Karina-Agliullova Feb 21, 2023
9c16cea
Modified the function
Karina-Agliullova Feb 24, 2023
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
47 changes: 25 additions & 22 deletions app/controllers/serviceLearning/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from app.controllers.main.routes import getRedirectTarget, setRedirectTarget
from app.controllers.serviceLearning import serviceLearning_bp


@serviceLearning_bp.route('/serviceLearning/courseManagement', methods = ['GET'])
@serviceLearning_bp.route('/serviceLearning/courseManagement/<username>', methods = ['GET'])
def serviceCourseManagement(username=None):
Expand All @@ -30,6 +29,7 @@ def serviceCourseManagement(username=None):
user = User.get(User.username==username) if username else g.current_user
courseDict = getServiceLearningCoursesData(user)
termList = selectSurroundingTerms(g.current_term, prevTerms=0)
status = CourseStatus.select
return render_template('serviceLearning/slcManagement.html',
user=user,
courseDict=courseDict,
Expand All @@ -45,27 +45,30 @@ def slcEditProposal(courseID):
Route for editing proposals, it will fill the form with the data found in the database
given a courseID.
"""
course = Course.get_by_id(courseID)
questionData = (CourseQuestion.select().where(CourseQuestion.course == course))
questionanswers = [question.questionContent for question in questionData]
courseInstructor = CourseInstructor.select().where(CourseInstructor.course == courseID)

isAllSectionsServiceLearning = ""
isPermanentlyDesignated = ""

if course.isAllSectionsServiceLearning:
isAllSectionsServiceLearning = True
if course.isPermanentlyDesignated:
isPermanentlyDesignated = True
terms = selectSurroundingTerms(g.current_term, 0)
return render_template('serviceLearning/slcNewProposal.html',
course = course,
questionanswers = questionanswers,
terms = terms,
courseInstructor = courseInstructor,
isAllSectionsServiceLearning = isAllSectionsServiceLearning,
isPermanentlyDesignated = isPermanentlyDesignated,
redirectTarget=getRedirectTarget())
if g.current_user.isCeltsAdmin or g.current_user.isFaculty:
course = Course.get_by_id(courseID)
questionData = (CourseQuestion.select().where(CourseQuestion.course == course))
questionanswers = [question.questionContent for question in questionData]
courseInstructor = CourseInstructor.select().where(CourseInstructor.course == courseID)

isAllSectionsServiceLearning = ""
isPermanentlyDesignated = ""
course.status = CourseStatus.APPROVED


if course.isAllSectionsServiceLearning:
isAllSectionsServiceLearning = True
if course.isPermanentlyDesignated:
isPermanentlyDesignated = True
terms = selectSurroundingTerms(g.current_term, 0)
return render_template('serviceLearning/slcNewProposal.html',
course = course,
questionanswers = questionanswers,
terms = terms,
courseInstructor = courseInstructor,
isAllSectionsServiceLearning = isAllSectionsServiceLearning,
isPermanentlyDesignated = isPermanentlyDesignated,
redirectTarget=getRedirectTarget())

@serviceLearning_bp.route('/serviceLearning/createCourse', methods=['POST'])
def slcCreateCourse():
Expand Down
22 changes: 22 additions & 0 deletions app/logic/emailHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from peewee import DoesNotExist, JOIN
from flask_mail import Mail, Message
import os
import email.message

from app import app
from app.models.programEvent import ProgramEvent
Expand Down Expand Up @@ -251,3 +252,24 @@ def retrieve_last_email(event_id):
return last_email
except DoesNotExist:
return None


def email_when_submitted(recipient, subject, body):
defaultEmailInfo = {"senderName":"Ashley Cochrane", "replyTo":self.reply_to}
template_id, subject, body = self.build_email()

with self.mail.connect() as conn:
for recipient in self.recipients:
full_name = "Ashley Cochrane"
email_body = self.replace_name_placeholder(full_name, body)

conn.send(Message(
body = "This is the message"
subject = "Hello Ashley",
recipients = [[email protected]],
email_body,
reply_to = defaultEmailInfo["replyTo"],
sender = (defaultEmailInfo["senderName"], defaultEmailInfo["replyTo"])
))
self.store_sent_email(subject, template_id)
return True
14 changes: 8 additions & 6 deletions app/templates/serviceLearning/slcManagement.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ <h1 class="text-center mb-2">{{user.firstName}} {{user.lastName}}'s SLC Proposal
<td>{{courseDict[course]['term'].description}}</td>
<td>{{courseDict[course]['status']}}</td>
<td>
<select class="form-select courseData" id="{{courseDict[course]['id']}}" onchange='changeAction(this)'>
<option value="---" disabled selected>Select Action</option>
<option value="Renew">Renew</option>
<option value="View">View</option>
<option value="Withdraw">Withdraw</option>
<option value="Edit">Edit</option>
<select class="form-select courseData" id="{{courseDict[course]['id']}}" onchange='changeAction(this)'>
<option value="---" disabled selected>Select Action</option>
<option value="Renew">Renew</option>
<option value="View">View</option>
<option value="Withdraw">Withdraw</option>
<option value="Edit">Edit</option>


</select>
</td>
</tr>
Expand Down