fixed cannot create folder bug

added email toggle to main page
This commit is contained in:
murraydr 2023-11-01 14:48:34 -04:00
parent eeb64eb1b4
commit fe188e2414
6 changed files with 19 additions and 16 deletions

View File

@ -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
futureproofing calling float on single element helperfunctions.py 142

View File

@ -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)

View File

@ -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)

View File

@ -1 +1 @@
2023-11-01 12:26:32.997196
2023-11-01 14:47:38.394597

View File

@ -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:

View File

@ -1 +1 @@
Timestamp,Requestor,Section,Dates,Replacement,Reason
Timestamp,Requestor,Section,Dates,Replacement,Reason

1 Timestamp Requestor Section Dates Replacement Reason