From 0077950f2ad11923e45ffa2f16cb8eecb66d5104 Mon Sep 17 00:00:00 2001 From: darkicewolf50 Date: Sat, 7 Dec 2024 13:00:13 -0700 Subject: [PATCH] feat(NoSheet): started creating default sheet, todo add default data --- NoSheet.py | 114 ++++++++++++++++++++++++++++++++++++++++------------- ReadDB.py | 6 +++ WriteDB.py | 5 +++ emp.yml | 25 ------------ temp.yml | 36 +++++++++++++++++ 5 files changed, 133 insertions(+), 53 deletions(-) delete mode 100644 emp.yml create mode 100644 temp.yml diff --git a/NoSheet.py b/NoSheet.py index 3d216f1..3e0aa49 100644 --- a/NoSheet.py +++ b/NoSheet.py @@ -1,35 +1,93 @@ import openpyxl import yaml import json +import datetime +from openpyxl.styles import Font, Border, Side -yamlraw = """ - Interview TimeTable: - - Date: Null - - Meeting Duration: 30 min - - Start Time Slot: Null - - Interviewee Name: Null - - Interviewee Email: Null - - Category (if not general): Null - - Interviewer(s) Name(s): Null - - Status: Dropdown (Options in datahelp) - Recruitment Responses: - - Frist Name (What we should call them): Null - - Last Name: Null - - Ucalgary Email: Null - - What Subsystem/SubTeam are you interested in?: Null - - Major: Null - - Academic Year: Null - - Why are you interested in joining UCalgary BAJA?: Null - - Where did you hear about us?: Null - - Are you available for team meetings/work days? Saturdays 10 am - 4 pm: Null #add condiftional formatting for no to make whole line red - Data Help: - - Status Dropdown: - - Unknown - - Done - - No Show - - Cancelled/Moved + +def NoSheet(): + # sheet with an example properites + yamlraw = """ +Recruitment Responses: + - Frist Name (What we should call them): Steve + - Last Name: the Bug + - Ucalgary Email: steve.the.bug@ucalgary.ca + - What Subsystem/SubTeam are you interested in?: | + Chassis + Ergonomics + Suspension + Steering + Powertrain + Final Drive + Any Mechanical + Business - Content Creation + Business - Business Relations + Software + - Major: General (1st Year) + - Academic Year: 1st + - Why are you interested in joining UCalgary BAJA?: Example Interest + - Where did you hear about us?: Testing + - Are you available for team meetings/work days? Saturdays 10 am - 4 pm: Yes #add condiftional formatting for no to make whole line red +Interview TimeTable: + - Date: 9/16/2024 + - Meeting Duration: 30 min + - Start Time Slot: 10:00:00 AM + - Slot: 1 + - Interviewee Name (What to call them): Steve + - Interviewee Email: steve.the.bug@ucalgary.ca + - Category (if not general): Test + - Interviewer(s) Name(s): Example + - Status: Dropdown (Options in datahelp) #default is Unkown +Data Helper: + - Status Dropdown: + - Unknown + - Done + - No Show + - Cancelled/Moved """ -yamlsheet = yaml.safe_load(yamlraw) + yamlsheet = yaml.safe_load(yamlraw) -print(json.dumps(yamlsheet, indent=4)) \ No newline at end of file + print(json.dumps(yamlsheet, indent=4)) + + year_donation = int(str(datetime.datetime.now().year)[2:]) + 1 # gets the last two digits of the current year then adds 1 for the current season + file_name = f"OR{year_donation}-L-Interview Data.xlsx" # name based off the 2025 naming system + + sheet_names = [name for name in yamlsheet.keys()] + + # border style + border = Border( + left=Side(style='medium'), + right=Side(style='medium'), + top=Side(style='medium'), + bottom=Side(style='medium') + ) + + # create workbook in memory + work_book = openpyxl.Workbook() + + if len(sheet_names) > 0: + # remove default sheet + default_sheet = work_book.active + work_book.remove(default_sheet) + + for sheet_name, title_list in yamlsheet.items(): + # add standard sheets + sheet = work_book.create_sheet(sheet_name) + + titles = [list(title.keys())[0] for title in title_list] + + for col_num, title in enumerate(titles, start=1): + cell = sheet.cell(row=1, column=col_num) + cell.value = title + + cell.font = Font(bold=True) + cell.border = border + + + + # save to storage + work_book.save(file_name) + +if __name__ == "__main__": + NoSheet() \ No newline at end of file diff --git a/ReadDB.py b/ReadDB.py index 31d227b..68cef6e 100644 --- a/ReadDB.py +++ b/ReadDB.py @@ -7,6 +7,12 @@ import time excel_file_path = "./OR-L-Interview Data.xlsx" lock_file_path = "./OR-L-Interview Data.xlsx.lock" +""" +TODO change to dynamic file name + year_donation = int(str(datetime.datetime.now().year)[2:]) + 1 # gets the last two digits of the current year then adds 1 for the current season + file_name = f"OR{year_donation}-L-Interview Data.xlsx" # name based off the 2025 naming system +""" + def ReadDatabase(): """ Reads the database for which slots are available diff --git a/WriteDB.py b/WriteDB.py index 9c64757..3750a24 100644 --- a/WriteDB.py +++ b/WriteDB.py @@ -8,6 +8,11 @@ from filelock import FileLock file_path = "./interview_database.xlsx" lock_path = "./interview_database.xlsx.lock" # Lock file for synchronization +""" +TODO chnage to dynamic file name + year_donation = int(str(datetime.datetime.now().year)[2:]) + 1 # gets the last two digits of the current year then adds 1 for the current season + file_name = f"OR{year_donation}-L-Interview Data.xlsx" # name based off the 2025 naming system +""" def ReadDatabase(): """ Reads the Database to retrieve available interview slots. diff --git a/emp.yml b/emp.yml deleted file mode 100644 index 2a49ad1..0000000 --- a/emp.yml +++ /dev/null @@ -1,25 +0,0 @@ -Interview TimeTable: - - Date: Null - - Meeting Duration: 30 min - - Start Time Slot: Null - - Interviewee Name: Null - - Interviewee Email: Null - - Category (if not general): Null - - Interviewer(s) Name(s): Null - - Status: Dropdown (Options in datahelp) -Recruitment Responses: - - Frist Name (What we should call them): Null - - Last Name: Null - - Ucalgary Email: Null - - What Subsystem/SubTeam are you interested in?: Null - - Major: Null - - Academic Year: Null - - Why are you interested in joining UCalgary BAJA?: Null - - Where did you hear about us?: Null - - Are you available for team meetings/work days? Saturdays 10 am - 4 pm: Null #add condiftional formatting for no to make whole line red -Data Help: - - Status Dropdown: - - Unknown - - Done - - No Show - - Cancelled/Moved diff --git a/temp.yml b/temp.yml new file mode 100644 index 0000000..3b156cf --- /dev/null +++ b/temp.yml @@ -0,0 +1,36 @@ +Recruitment Responses: + - Frist Name (What we should call them): Steve + - Last Name: the Bug + - Ucalgary Email: steve.the.bug@ucalgary.ca + - What Subsystem/SubTeam are you interested in?: | + Chassis + Ergonomics + Suspension + Steering + Powertrain + Final Drive + Any Mechanical + Business - Content Creation + Business - Business Relations + Software + - Major: General (1st Year) + - Academic Year: 1st + - Why are you interested in joining UCalgary BAJA?: Example Interest + - Where did you hear about us?: Testing + - Are you available for team meetings/work days? Saturdays 10 am - 4 pm: Yes #add condiftional formatting for no to make whole line red +Interview TimeTable: + - Date: 9/16/2024 + - Meeting Duration: 30 min + - Start Time Slot: 10:00:00 AM + - Slot: 1 + - Interviewee Name (What to call them): Steve + - Interviewee Email: steve.the.bug@ucalgary.ca + - Category (if not general): Test + - Interviewer(s) Name(s): Example + - Status: Dropdown (Options in datahelp) #default is Unkown +Data Helper: + - Status Dropdown: + - Unknown + - Done + - No Show + - Cancelled/Moved