def getAllCurrentProjects(): # we only want to get projects for the current year currentCycle = getCurrentParameters() if currentCycle is not None: year = currentCycle.year return getAllCurrentProjectsByYear(year)
def getProject (username): #get project for this user in the current cycle currentCycle = getCurrentParameters() if currentCycle is not None: year = currentCycle.year else: year = None return getProjectByYear(username, year)
def removeFiles(username): """ This function removes the folder that belong to a user. It should be used when the project is withdrawn Args: username (str): The username of the faculty whose folder should be deleted """ currentParameter = getCurrentParameters() folder_path = os.path.join(base_path, cfg["filepaths"]["projectFiles"], str(currentParameter.year), username) shutil.rmtree(folder_path)
def create_message(subject, recipients, body): ''' Parameters: username_email(s) - Emails of the recipients body - The body of the email ''' parameters = getCurrentParameters() adminEmail = parameters.staffsupport_id.username + "@berea.edu" msg = Message(subject, sender=app.config['MAIL_DEFAULT_SENDER'], recipients=[recipients], cc=[adminEmail]) #create a message instance msg.html = body return msg
def getNarrative(username): if username != authUser(request.environ): return {"response": cfg["response"]["badUsername"]} applicationCycle = getCurrentParameters().year knownFiles = os.listdir() for filenames in knownFiles: if "narrative" in filenames: response = {"response": "OK", "narrative": filenames} return jsonify(response) else: response = { "response": cfg["response"]["noResults"], "details": "No results found for project Narrative." } return jsonify(response)
def projects_getNarrative (username, path): if username != authUser(request.environ): return { "response": cfg["response"]["badUsername"] } applicationCycle = getCurrentParameters() dirPath = cfg["filepaths"]["directory"] dirPath = dirPath.replace("%%username%%", username) dirPath = dirPath.replace("%%applicationCycle%%", applicationCycle.year) knownFiles = os.listdir(dirPath) for filenames in knownFiles: if path in filenames: response = {"response": "OK", "uploadType": filenames} print "Path exists" return jsonify(response) response = { "response": cfg["response"]["noResults"], "details": "No results found for project file." } return jsonify(response)