示例#1
0
    def event_data():
        print("Please enter the following informations!")
        date_of_event = Switch.general_data_inputer(["Date of the event", "Date of the event (YYYY.MM.DD)"])
        start_time = Switch.general_data_inputer(["Start time", "Start time (hh:mm)"])
        end_time = Switch.general_data_inputer(["End time", "End time (hh:mm)", start_time])
        zip_code = Switch.general_data_inputer(["Zip code", "Zip code"])
        city = Switch.general_data_inputer(["City", "City"])
        address = Switch.general_data_inputer(["Address", "Address"])
        available_beds = Switch.general_data_inputer(["Available beds", "Available beds"])
        planned_donor_number = Switch.general_data_inputer(["Planned donor number", "Planned donor number"])
        event_duration_time = EventCalculations.duration_in_time(start_time, end_time)
        colon_in_duration_time = str(event_duration_time).find(":")
        final_donor_number = EventCalculations.maximum_donor_number(available_beds, start_time, end_time)
        success_rate = EventCalculations.success_rate(planned_donor_number, final_donor_number)
        success_text = EventCalculations.success_text(success_rate)

        os.system('cls')

        print("\n" + "-" * 32 + "\n")
        print("Details of the planned event:\n")
        print("Date of the event:", date_of_event)
        print("Start time:", start_time)
        print("End time:", end_time)
        print("Event duration time: %s hour(s) %s minute(s)" % (str(event_duration_time)[:colon_in_duration_time],
                str(event_duration_time)[colon_in_duration_time+1:colon_in_duration_time+3]))
        print("Zip code:", zip_code)
        print("City:", city)
        print("Address:", address)
        print("Available beds:", available_beds)
        print("Planned donor number:", planned_donor_number)
        print("Maximum donor number:", final_donor_number)
        print("Percent of success:", success_rate, "%")
        print("Efficiency:", success_text)
        print("\n" + "-" * 32)

        if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
            save = SaveMenu.save_menu(2, 21)
        else:
            save = SaveMenuOldFashioned.save_menu(2, "Do you want to save?")
            print()
        if save:
            every_file_data = [str(date_of_event).replace("-", "."), str(start_time)[:len(str(start_time))-3],\
                               str(end_time)[:len(str(end_time))-3], zip_code, city, address, available_beds, \
                               planned_donor_number, final_donor_number]
            header = "id,date_of_event,start_time,end_time,zip_code,city,address,number_of_available_beds," + \
                     "planned_donor_number,final_donor_number\n"
            FileOperator.save_new_data(every_file_data, header, 'Data/donations.csv')
            print("Save was successful!")
            time.sleep(2)
示例#2
0
 def test_mod(test_data):
     test_variable = Switch.general_data_inputer(test_data)
     return test_variable
示例#3
0
 def test_zip_code2(self):
     self.assertNotEqual(
         "1234", Switch.general_data_inputer(["Zip code", "234", "Test"]))
示例#4
0
 def test_date_of_the_event(self):
     self.assertIsInstance(
         Switch.general_data_inputer(
             ["Date of the event", "2045.02.10", "Test"]), date)
示例#5
0
 def test_city2(self):
     self.assertEqual(
         "Szerencs",
         Switch.general_data_inputer(["City", "szerencs", "Test"]))
示例#6
0
 def test_city(self):
     self.assertEqual(
         "Miskolc", Switch.general_data_inputer(["City", "Miskolc",
                                                 "Test"]))
示例#7
0
    def donor_register_app():
        print("Please enter the following informations!")

        name = Switch.general_data_inputer(
            ["Donor's name", "Enter your full name"])
        birth_date = Switch.general_data_inputer(
            ["Birth date", "Birth date (YYYY.MM.DD)"])
        weight = Switch.general_data_inputer(["Weight", "Weight"])
        gender = Switch.general_data_inputer(["Gender", "Gender"])
        uniqeid = Switch.general_data_inputer(
            ["Unique ID", "Unique identifier number"])
        expuniqeid = Switch.general_data_inputer(
            ["Expiration of ID", "Expiration date of your ID"])
        blood_type = Switch.general_data_inputer(
            ["Blood type", "Blood type (A, B, AB, 0 with +/-)"])
        last_donation = Switch.general_data_inputer([
            "Last donation date",
            "Last donation date (type 'never' if never before)"
        ])
        sick = Switch.general_data_inputer(
            ["Sickness", "Were you sick in the last month?"])
        phone_number = Switch.general_data_inputer(
            ["Mobile number", "Mobile number"])
        email = Switch.general_data_inputer(["Email", "E-mail address"])
        age_of_donor = Validations.count_age_of_donor(birth_date[0])
        hemoglobin = Validations.validate_hmg()
        suitable = Validations.donor_suitable(
            [birth_date, weight, last_donation, sick, hemoglobin])

        os.system('cls')

        print("\n" + "-" * 32 + "\n")
        print("Donor's data:\n")
        print("Name:", name)
        print("Birth date: %s - %d years old" % (birth_date[0], age_of_donor))
        print("Weight:", weight[0], "kg")
        print("Gender:", gender)
        print("Type of donor's ID: %s\nNumber of donor's ID: %s" %
              (uniqeid[0], uniqeid[1]))
        print("Expiration of donor's ID: %s" % expuniqeid[0])
        print("Last donation date: %s" % last_donation[0])
        print("Were donor sick last month:", sick[0])
        print("Phone number:", phone_number)
        print("Email:", email)
        print("Hemoglobin level:", hemoglobin[0], "\n")
        print(suitable[1])
        print("\n" + "-" * 32)

        if os.path.isfile(
                "C:/Users/" + user_name +
                "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"
        ):
            save = SaveMenu.save_menu(2, 24)
        else:
            save = SaveMenuOldFashioned.save_menu(2, "Do you want to save?")
            print()
        if save:
            every_file_data = [
                str(name),
                str(weight[0]),
                str(gender),
                str(birth_date[0]),
                str(last_donation[0]),
                str(sick[0]),
                str(uniqeid[1]),
                str(expuniqeid[0]),
                str(blood_type),
                str(hemoglobin[0]),
                str(email),
                str(phone_number),
                str(suitable[0])
            ]
            header = "name,weight,gender,date_of_birth,last_donation,last_month_sickness,unique_identifier," + \
                     "expiration_of_id,blood_type,hemoglobin,email,mobil,is_suitable"
            FileOperator.save_new_data(every_file_data, header,
                                       'Data/donors.csv')
            print("Save was successful!")
            time.sleep(2)
示例#8
0
    def change_process_donor(original, changed, file_line_number):
        header = ["Donor's name","Weight","Gender","Birth date","Last donation date","Sickness","Unique ID",
                  "Expiration of ID","Blood type","Hemoglobin","Email","Mobile number","Donor is suitable"]
        which_result = 0
        result_number = len(original)
        if result_number > 1:
            print("There are " + str(result_number) + " results:")
        else:
            print("The result:")
        print("-" * 52)
        for i in range(result_number):
            ChangeClass.print_preprocessor_donor(original,0,header,i,-1)

        if result_number > 1:
            print("Which result would you like to change?")
            which_result = int(input("Please give the result serial number (or 0 if none):"))
            if which_result == 0:
                return False
            else:
                os.system('cls')
                print("-" * 52)
                which_result -= 1
                ChangeClass.print_preprocessor_donor(original, 0, header, which_result, -1)

        menu_number = 3
        first_suitable_check = True
        while True:
            print("What would you like to change about this donor's data?\n")
            select = ChangeOptionsMenu.change_options(2, "  ", menu_number)
            print()

            if select == 1:
                changed[which_result].name = Switch.general_data_inputer([header[0],"Enter your full name",
                                changed[which_result].name,"Change"])
                changed[which_result].weight = Switch.general_data_inputer([header[1],header[1],
                                changed[which_result].weight,"Change"])
                changed[which_result].gender = Switch.general_data_inputer([header[2],header[2],
                                changed[which_result].gender,"Change"])
                changed[which_result].birth_date = Switch.general_data_inputer([header[3],"Birth date (YYYY.MM.DD)",
                                changed[which_result].birth_date,"Change"])
                changed[which_result].last_donation = Switch.general_data_inputer([header[4],
                                "Last donation date (type 'never' if never before)",
                                changed[which_result].last_donation,"Change"])
                changed[which_result].sick = Switch.general_data_inputer([header[5],"Were you sick in the last month?",
                                changed[which_result].sick,"Change"])
                changed[which_result].uniqeid = Switch.general_data_inputer([header[6],"Unique identifier number",
                                changed[which_result].uniqeid,"Change"])
                changed[which_result].expuniqeid = Switch.general_data_inputer([header[7],"Expiration date of your ID",
                                changed[which_result].expuniqeid,"Change"])
                changed[which_result].blood_type = Switch.general_data_inputer([header[8],
                                "Blood type (A, B, AB, 0 with +/-)",changed[which_result].blood_type,"Change"])
                changed[which_result].hemoglobin = Switch.general_data_inputer([header[9],"Hemoglobin level",
                                changed[which_result].hemoglobin,"Change"])
                changed[which_result].email = Switch.general_data_inputer([header[10],"E-mail address",
                                changed[which_result].email,"Change"])
                changed[which_result].phone_number = Switch.general_data_inputer([header[11],header[11],
                                changed[which_result].phone_number,"Change"])
                changed[which_result].suitable = Validations.donor_suitable([changed[which_result].birth_date,
                                changed[which_result].weight,changed[which_result].last_donation,
                                changed[which_result].sick,changed[which_result].hemoglobin])
                ChangeClass.print_preprocessor_donor(original,changed,header,which_result,-1)

            elif select == 2:
                os.system('cls')
                ChangeClass.print_preprocessor_donor(original,changed,header,which_result,[0,11])
                if ChangeClass.change_select_arrow == 0:
                    changed[which_result].name = Switch.general_data_inputer([header[0],"Enter your full name",
                                changed[which_result].name,"Change"])
                elif ChangeClass.change_select_arrow == 1:
                    changed[which_result].weight = Switch.general_data_inputer([header[1],header[1],
                                changed[which_result].weight,"Change"])
                elif ChangeClass.change_select_arrow == 2:
                    changed[which_result].gender = Switch.general_data_inputer([header[2],header[2],
                                changed[which_result].gender,"Change"])
                elif ChangeClass.change_select_arrow == 3:
                    changed[which_result].birth_date = Switch.general_data_inputer([header[3],"Birth date (YYYY.MM.DD)",
                                changed[which_result].birth_date,"Change"])
                elif ChangeClass.change_select_arrow == 4:
                    changed[which_result].last_donation = Switch.general_data_inputer([header[4],
                                "Last donation date (type 'never' if never before)",changed[which_result].last_donation,
                                "Change"])
                elif ChangeClass.change_select_arrow == 5:
                    changed[which_result].sick = Switch.general_data_inputer([header[5],"Were you sick in the last month?",
                                changed[which_result].sick,"Change"])
                elif ChangeClass.change_select_arrow == 6:
                    changed[which_result].uniqeid = Switch.general_data_inputer([header[6],"Unique identifier number",
                                changed[which_result].uniqeid,"Change"])
                elif ChangeClass.change_select_arrow == 7:
                    changed[which_result].expuniqeid = Switch.general_data_inputer([header[7],"Expiration date of your ID",
                                changed[which_result].expuniqeid,"Change"])
                elif ChangeClass.change_select_arrow == 8:
                    changed[which_result].blood_type = Switch.general_data_inputer([header[8],
                                "Blood type (A, B, AB, 0 with +/-)",changed[which_result].blood_type,"Change"])
                elif ChangeClass.change_select_arrow == 9:
                    changed[which_result].hemoglobin = Switch.general_data_inputer([header[9],"Hemoglobin level",
                                changed[which_result].hemoglobin,"Change"])
                elif ChangeClass.change_select_arrow == 10:
                    changed[which_result].email = Switch.general_data_inputer([header[10],"E-mail address",
                                changed[which_result].email,"Change"])
                elif ChangeClass.change_select_arrow == 11:
                    changed[which_result].phone_number = Switch.general_data_inputer([header[11],header[11],
                                changed[which_result].phone_number,"Change"])

                if first_suitable_check:
                    changed[which_result].weight = Switch.general_data_inputer([header[1],header[1],
                                changed[which_result].weight,"Test"])
                    changed[which_result].birth_date = Switch.general_data_inputer([header[3],"Birth date (YYYY.MM.DD)",
                                changed[which_result].birth_date,"Test"])
                    changed[which_result].last_donation = Switch.general_data_inputer([header[4],
                                "Last donation date (type 'never' if never before)",changed[which_result].last_donation,
                                "Test"])
                    changed[which_result].sick = Switch.general_data_inputer([header[5],"Were you sick in the last month?",
                                changed[which_result].sick,"Test"])
                    changed[which_result].expuniqeid = Switch.general_data_inputer([header[7],"Expiration date of your ID",
                                changed[which_result].expuniqeid,"Test"])
                    changed[which_result].hemoglobin = Switch.general_data_inputer([header[9],"Hemoglobin level",
                                changed[which_result].hemoglobin,"Test"])
                    first_suitable_check = False
                changed[which_result].suitable = Validations.donor_suitable([changed[which_result].birth_date,
                                changed[which_result].weight,changed[which_result].last_donation,
                                changed[which_result].sick,changed[which_result].hemoglobin])
                ChangeClass.print_preprocessor_donor(original,changed,header,which_result,-1)
                print(changed[which_result].suitable[1])

            elif select == 3:
                if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
                    save = SaveMenu.yes_no_menu_relative_position(2, "Do you really want to save?")
                else:
                    save = SaveMenuOldFashioned.save_menu(2, "Do you really want to save?")
                print()
                if save:
                    try:
                        FileOperator.save_changes("Data/donors.csv", file_line_number, changed[which_result])
                        if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
                            print(Fore.GREEN + "Save was successful!" + Style.RESET_ALL)
                        else:
                            print("Save was successful!")
                        time.sleep(2)
                        break
                    except ValueError:
                        if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
                            print(Fore.RED + "Unfortunately, save was unsuccessful!" + Style.RESET_ALL)
                        else:
                            print("Unfortunately, save was unsuccessful!")
                    time.sleep(2)
                os.system('cls')
                ChangeClass.print_preprocessor_donor(original,changed,header,which_result,-1)
            elif select == 4:
                break
            menu_number = ChangeClass.is_there_any_changes(original, changed, header, which_result, "Donor")
示例#9
0
    def change_process_event(original, changed, file_line_number):
        header = ["Date of the event","Start time","End time","Zip code","City","Address","Available beds",
                  "Planned donor number","Final donor number"]
        which_result = 0
        result_number = len(original)
        os.system('cls')
        if result_number > 1:
            print("There are " + str(result_number) + " results:")
        else:
            print("The result:")
        print("-" * 52)
        for i in range(result_number):
            ChangeClass.print_preprocessor_event(original, 0, header, i, -1)

        if result_number > 1:
            print("Which result would you like to change?")
            which_result = int(input("Please give the result serial number (or 0 if none):"))
            if which_result == 0:
                return False
            else:
                os.system('cls')
                print("-" * 52)
                which_result -= 1
                ChangeClass.print_preprocessor_event(original, 0, header, which_result, -1)

        menu_number = 3
        while True:
            print("Would you like to change any of the data of this event?")
            select = ChangeOptionsMenu.change_options(2, "  ", menu_number)
            print()

            if select == 1:
                changed[which_result].date_of_event = Switch.general_data_inputer([header[0],
                                "Date of the event (YYYY.MM.DD)", changed[which_result].date_of_event, "Change"])
                changed[which_result].start_time = Switch.general_data_inputer([header[1],"Start time (hh:mm)",
                                changed[which_result].start_time,"Change"])
                changed[which_result].end_time = Switch.general_data_inputer([header[2],"End time (hh:mm)",
                                changed[which_result].start_time,changed[which_result].end_time, "Change"])
                changed[which_result].zip_code = Switch.general_data_inputer([header[3],
                                header[3],changed[which_result].zip_code,"Change"])
                changed[which_result].city = Switch.general_data_inputer([header[4],
                                header[4],changed[which_result].city,"Change"])
                changed[which_result].address = Switch.general_data_inputer([header[5],
                                header[5],changed[which_result].address,"Change"])
                changed[which_result].available_beds = Switch.general_data_inputer([header[6],
                                header[6],changed[which_result].available_beds,"Change"])
                changed[which_result].planned_donor_number = Switch.general_data_inputer([header[7],
                                header[7],changed[which_result].planned_donor_number,"Change"])
                changed[which_result].final_donor_number = str(EventCalculations.maximum_donor_number(
                                changed[which_result].available_beds,changed[which_result].start_time,
                                changed[which_result].end_time))
                ChangeClass.print_preprocessor_event(original, changed, header, which_result, -1)
            elif select == 2:
                os.system('cls')
                ChangeClass.print_preprocessor_event(original, changed, header, which_result, [0,7])
                if ChangeClass.change_select_arrow == 0:
                    changed[which_result].date_of_event = Switch.general_data_inputer([header[0],
                                "Date of the event (YYYY.MM.DD)",changed[which_result].date_of_event,"Change"])
                elif ChangeClass.change_select_arrow == 1:
                    changed[which_result].start_time = Switch.general_data_inputer([header[1],"Start time (hh:mm)",
                                changed[which_result].start_time,"Change"])
                elif ChangeClass.change_select_arrow == 2:
                    changed[which_result].end_time = Switch.general_data_inputer([header[2],"End time (hh:mm)",
                                changed[which_result].start_time,changed[which_result].end_time,"Change"])
                elif ChangeClass.change_select_arrow == 3:
                    changed[which_result].zip_code = Switch.general_data_inputer([header[3],
                                header[3],changed[which_result].zip_code,"Change"])
                elif ChangeClass.change_select_arrow == 4:
                    changed[which_result].city = Switch.general_data_inputer([header[4],
                                header[4],changed[which_result].city,"Change"])
                elif ChangeClass.change_select_arrow == 5:
                    changed[which_result].address = Switch.general_data_inputer([header[5],
                                header[5],changed[which_result].address,"Change"])
                elif ChangeClass.change_select_arrow == 6:
                    changed[which_result].available_beds = Switch.general_data_inputer([header[6],
                                header[6],changed[which_result].available_beds,"Change"])
                elif ChangeClass.change_select_arrow == 7:
                    changed[which_result].planned_donor_number = Switch.general_data_inputer([header[7],
                                header[7],changed[which_result].planned_donor_number,"Change"])
                changed[which_result].final_donor_number = str(EventCalculations.maximum_donor_number(
                    changed[which_result].available_beds,changed[which_result].start_time,changed[which_result].end_time))
                ChangeClass.print_preprocessor_event(original,changed,header,which_result,-1)
            elif select == 3:
                if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
                    save = SaveMenu.yes_no_menu_relative_position(2, "Do you really want to save?")
                else:
                    save = SaveMenuOldFashioned.save_menu(2, "Do you really want to save?")
                print()
                if save:
                    try:
                        FileOperator.save_changes("Data/donations.csv", file_line_number, changed[which_result])
                        if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
                            print(Fore.GREEN + "Save was successful!" + Style.RESET_ALL)
                        else:
                            print("Save was successful!")
                        time.sleep(2)
                        break
                    except ValueError as var:
                        print(var)
                        if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
                            print(Fore.RED + "Unfortunately, save was unsuccessful!" + Style.RESET_ALL)
                        else:
                            print("Unfortunately, save was unsuccessful!")
                    time.sleep(2)
                os.system('cls')
                ChangeClass.print_preprocessor_event(original,changed,header,which_result,-1)
            elif select == 4:
                break
            menu_number = ChangeClass.is_there_any_changes(original, changed, header, which_result, "Event")