From fe188e24148f6bf7e6586eec146c86096e78a923 Mon Sep 17 00:00:00 2001 From: murraydr Date: Wed, 1 Nov 2023 14:48:34 -0400 Subject: [PATCH] fixed cannot create folder bug added email toggle to main page --- bugsAndFeatureRequests.txt | 6 +----- driver.py | 6 +++++- helperFunctions.py | 4 ++-- lastUpdatedToken.txt | 2 +- substitutionApprovalWindow.py | 15 +++++++++------ substitutionRequestForm.csv | 2 +- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/bugsAndFeatureRequests.txt b/bugsAndFeatureRequests.txt index d81790c..9505bf8 100644 --- a/bugsAndFeatureRequests.txt +++ b/bugsAndFeatureRequests.txt @@ -1,7 +1,3 @@ Put any discovered bugs or requests for new features here in this document so they aren't forgotten and I can fix/implement them when I'm in the office on Wednesdays. -futureproofing calling float on single element helperfunctions.py 142 - -add email toggle to main requests - -cannot create stringOutputs folder \ No newline at end of file +futureproofing calling float on single element helperfunctions.py 142 \ No newline at end of file diff --git a/driver.py b/driver.py index 249ac59..5f320cb 100644 --- a/driver.py +++ b/driver.py @@ -4,7 +4,7 @@ import pandas as pd import substitutionApprovalWindow as SWin import helperFunctions as HF import scheduledPayrollWindow as PWin - +import os #TODO make development branch for code testing withotu altering "real" databases #TODO remove blankArchivedSubRequests.csv by instead using the method used on substitutionRequestForm.csv in reset.py @@ -37,6 +37,10 @@ subRequestsFilename="substitutionRequestForm.csv" subRequestsArchiveFilename="archivedSubRequests.csv" RegHoursFilename="regularHoursPayrollForm.csv" +#create the folder for stringOutputs if it doesn't already exist +if not os.path.exists("stringOutputs"): + os.makedirs("stringOutputs" ) + #load databases HF.getForms(subRequestsFilename) diff --git a/helperFunctions.py b/helperFunctions.py index 55eddf9..ad6e3b2 100644 --- a/helperFunctions.py +++ b/helperFunctions.py @@ -294,7 +294,7 @@ def createStrings(): f.write('\n'.join([x for x in vals if not (x in seen or seen.add(x))])) #Create the content of form-letter emails to be sent based on the request details and the chosen approval status -def generateEmails(requestList): +def generateEmails(requestList,actuallySendEmails=False): emails=[] for req in requestList: @@ -416,7 +416,7 @@ def generateEmails(requestList): emails.append([recipient,subject,message]) #Send emails (or print to terminal if debugging and actuallySend == False) - sendEmails(emails,actuallySend=True) + sendEmails(emails,actuallySend=actuallySendEmails) diff --git a/lastUpdatedToken.txt b/lastUpdatedToken.txt index 9b74cdb..810e282 100644 --- a/lastUpdatedToken.txt +++ b/lastUpdatedToken.txt @@ -1 +1 @@ -2023-11-01 12:26:32.997196 \ No newline at end of file +2023-11-01 14:47:38.394597 \ No newline at end of file diff --git a/substitutionApprovalWindow.py b/substitutionApprovalWindow.py index f47271b..9d1037d 100644 --- a/substitutionApprovalWindow.py +++ b/substitutionApprovalWindow.py @@ -108,7 +108,8 @@ def subAppWin(staffDatabaseFilename,secDFilename,subRequestsFilename,subRequests layout.append([sg.Text('-'*(sum(columnWidths)+27))]) #Adding buttons - layout.append([sg.Button('Ok'), sg.Button('Cancel'), sg.Button('See Sub History'), sg.Button('Make Manual Changes'), sg.Button('Section Viewer')]) + emailCheckCol=[[sg.Text("Send Emails?")],[sg.Checkbox('',key='-EMAILCHECK-',size=(1,1))]] + layout.append([sg.Button('Ok'), sg.Button('Cancel'), sg.Button('See Sub History'), sg.Button('Make Manual Changes'), sg.Button('Section Viewer'),sg.Column(emailCheckCol,element_justification='center')]) layout=[[sg.Column(layout,scrollable=True,expand_y=True,expand_x=True)]] # Create the Window @@ -122,10 +123,10 @@ def subAppWin(staffDatabaseFilename,secDFilename,subRequestsFilename,subRequests event, values = window.read() #values.values() is an array of the input from all window elements, we use strides to get a "column" of checkboxes instead of a "row" of checkboxes - approveValues=list(values.values())[::5] - acceptValues=list(values.values())[1::5] - rejectValues=list(values.values())[2::5] - cancelValues=list(values.values())[3::5] + approveValues=list(values.values())[:-1:5] + acceptValues=list(values.values())[1:-1:5] + rejectValues=list(values.values())[2:-1:5] + cancelValues=list(values.values())[3:-1:5] #Number of approved changes nApp = sum([1 for d in approveValues if True == d]) @@ -146,6 +147,8 @@ def subAppWin(staffDatabaseFilename,secDFilename,subRequestsFilename,subRequests if event == 'Ok': + actuallySendEmails=values['-EMAILCHECK-'] + valid=True dialogShown = False #Do not show multiple error dialogues even if there are multiple problems (to avoid spamming popup boxes) @@ -254,7 +257,7 @@ def subAppWin(staffDatabaseFilename,secDFilename,subRequestsFilename,subRequests #If the program crashes during email sending (such as with invalid login) it will deliberately NOT reach the code where it writes to databases #KEEP THIS LINE BEFORE THE WRITING STEPS - HF.generateEmails(resolvedSubrequests) + HF.generateEmails(resolvedSubrequests,actuallySendEmails) #Write to the respective databases with open(subRequestsFilename,'w', newline='') as f: diff --git a/substitutionRequestForm.csv b/substitutionRequestForm.csv index f85a7dc..c302847 100644 --- a/substitutionRequestForm.csv +++ b/substitutionRequestForm.csv @@ -1 +1 @@ -Timestamp,Requestor,Section,Dates,Replacement,Reason +Timestamp,Requestor,Section,Dates,Replacement,Reason