def list_yos(supporterid, supportername): # get list of all yos with this supporter id layout = [ [ sg.Text('YOs for supporter: ', font=('Helvetica', 12, 'bold')), sg.Text(supportername,font=('Helvetica', 12, 'bold'))], [ sg.Text('Name',size=(14,1),font=('Helvetica', 10, 'bold')), sg.Text('Surname',size=(14,1),font=('Helvetica', 10, 'bold')), sg.Text('Start date',size=(14,1),font=('Helvetica', 10, 'bold')), sg.Text('Emotion',size=(14,1),font=('Helvetica', 10, 'bold')), sg.Text('Messages', size=(14,1),font=('Helvetica',10,'bold')) ] ] yos = get_data("yos") users = get_data("user") for yo in yos: for user in users: if user['ID'] == yo['USERID']: yo_details = get_YO_details(yo["ID"]) # name, surname, email, logged_in = get_YO_user_info(user['ID']) # start_date = yo['STARTDATE'] # emotion_status = yo['EMOTION'] # message_count message_colour = "red" if yo_details["SOMEURGENT"] else "black" layout.append([ sg.Text(yo_details["NAME"], size=(16,2)), sg.Text(yo_details["SURNAME"], size=(16,2)), sg.Text(yo_details["STARTDATE"], size=(18,2)), sg.Button(button_color=("gray","gray"), image_filename=get_emotion_image(yo_details["EMOTION"]),image_size=(20,20), size=(20,2)), sg.Text(yo_details["MESSAGECOUNT"], justification="center", text_color=message_colour, font=('Helvetica', 12, 'bold'), size=(18,2)), sg.Button('Select', key='yo-' + yo["ID"])]) break layout.append([sg.Button('Close', size=(20,2))]) window = sg.Window('YOs', size=(800,350)).Layout(layout) # wait for a button to be clicked and handle it while True: event,values = window.read() if event.find('yo-') != -1: yoid = event.split('-')[1] show_yo_profile(yoid) if event == 'Close': break window.close()
def get_YO_details(yoid): yos_list = get_data("yos") for yos in yos_list: if yos["ID"] == str(yoid): name, surname, email, logged_in = get_YO_user_info(yos["USERID"]) message_count, some_urgent = get_unread_message_info(yos["ID"], yos["SUPPORTERID"]) YO_details = {'ID': yos["ID"], 'USERID': yos["USERID"], 'SUPPORTERID': yos["SUPPORTERID"], 'EMOTION': yos["EMOTION"], 'STARTDATE': yos["STARTDATE"],'NAME': name, 'SURNAME': surname, 'EMAIL': email, 'LOGGEDIN': logged_in, 'MESSAGECOUNT': message_count, 'SOMEURGENT': some_urgent} return YO_details
def get_unread_message_info(yoid, supporterid): message_list = get_data("message") message_count = 0 some_urgent = False for message in message_list: if message["YOID"] == yoid and message["SUPPORTERID"] == supporterid: if message["READ"] == "unread": message_count += 1 if message["URGENT"] == "urgent": some_urgent = True return message_count, some_urgent
def get_YO_user_info(userid): #Joe and Isaac #get user with an ID of userid name = "" surname = "" email = "" logged_in = False user_list = get_data("user") for user in user_list: if user["ID"] == str(userid): name = user["NAME"] surname = user["SURNAME"] email = user["EMAIL"] if user["LOGGEDIN"] == "Y": logged_in = True return name, surname, email, logged_in
def display_tasks(yo_details): # get list of all tasks for this yo task_list = get_data('task') layout = [ [ sg.Text('List of tasks for '), sg.Text(yo_details["NAME"]), sg.Text(yo_details["SURNAME"]) ], [ sg.Text('ID', size=(3, 2)), sg.Text('TASK NAME', size=(15, 2)), sg.Text('DESCRIPTION', size=(38, 2)), sg.Text('TARGETDATE', size=(13, 2)), sg.Text('ACHIEVED', size=(10, 2)), sg.Text('VERIFIED', size=(10, 2)) ], ] for task in task_list: if task['YOID'] == yo_details["ID"]: row = [ sg.Text(task['ID'], size=(3, 2)), sg.Text(task['TASKNAME'], size=(15, 2)), sg.Text(task['DESCRIPTION'], size=(38, 2)), sg.Text(task['TARGETDATE'], size=(13, 2)), sg.Text(task['ACHIEVED'], size=(10, 2)), sg.Text(task['VERIFIED'], size=(10, 2)) ] layout.append(row) layout.append([sg.Button('Close', size=(15, 2))]) window = sg.Window('Tasks', size=(800, 400)).Layout(layout) while True: event, values = window.read() if event == 'Close': break window.close()