コード例 #1
0
ファイル: add_user.py プロジェクト: DmitriiDenisov/bank-bot
def add_user(user_email: str, user_pass: str) -> Tuple[int, str]:
    """
    Add new user to DB
    :param user_email: str, user's email address
    :param user_pass: str, user hashed password
    :return:
    """
    hashed_pass: str = get_hash(user_pass)
    # ADD to DB new customer
    new_cust: Customer = Customer(first_name='New_user',
                                  second_name='flask_August',
                                  nickname_telegram='@test',
                                  access_type=0,
                                  join_date=datetime.datetime.utcnow())
    # ADD new bal to user
    new_bal: Balance = Balance(customer=new_cust,
                               usd_amt=0,
                               eur_amt=0,
                               aed_amt=0)
    # ADD new password
    new_pass: Password = Password(customer=new_cust,
                                  user_email=user_email,
                                  user_pass=hashed_pass)
    # add_all is similar to git add ...
    session.add_all([new_cust])
    # flush is similar to git commit ...
    session.flush()
    # commit is similar to git push ...
    session.commit()

    return new_cust.id, hashed_pass
コード例 #2
0
 def read(self):
     rows = Repository().read(self.filename)
     customers = [
         Customer(row['name'], row['address'], row['postal'], row['ssn'],
                  row['phone'], row['email'], row['country'], row['id'])
         for row in rows
     ]
     return customers
コード例 #3
0
 def get_Customer(self):
     #if self.__Customer == []:
     with open("./data/customer.txt", "r",encoding = "UTF-8-SIG") as Customer_file:
         for line in Customer_file.readlines():
             name,kennitala,phone = line.split(",")
             new_Customer = Customer(name,kennitala,phone)
             self.__Customer.append(new_Customer)    
     
     return self.__Customer
コード例 #4
0
 def search_customer_by_name(self, last_name="", first_name=""):
     with open("./Data/Customer.csv", "r") as customer_file:
         for line in customer_file.readlines():
             f_name, l_name, address, drivers_license, kennitala, current_rental_number = line.split(
                 ",")
             if l_name == last_name and f_name == first_name:
                 foundCust = Customer(l_name, f_name, address,
                                      drivers_license, kennitala,
                                      current_rental_number)
                 return foundCust
     return None
コード例 #5
0
 def search_customer_by_kennitala(self, kennitala):
     with open("./Data/Customer.csv", "r") as customer_file:
         for line in customer_file.readlines():
             f_name, l_name, address, drivers_license, kt, current_rental_number = line.split(
                 ",")
             if kennitala == kt:
                 foundCust = Customer(l_name, f_name, address,
                                      drivers_license, kt,
                                      current_rental_number)
                 return foundCust
     return None
コード例 #6
0
ファイル: customer.py プロジェクト: ThinkmanWang/NotesServer
def update_customer():
    if request.method == 'GET':
        return obj2json(RetModel(1, dict_err_code[1], {}))

    if (request.form.get('uid', None) is None
            or request.form.get('token', None) is None):
        return obj2json(RetModel(21, dict_err_code[21]))

    if (False == verify_user_token(request.form['uid'],
                                   request.form['token'])):
        return obj2json(RetModel(21, dict_err_code[21], {}))

    if (request.form.get('id', None) is None):
        return obj2json(RetModel(31, dict_err_code[31], {}))

    if (request.form.get('name', None) is None):
        return obj2json(RetModel(32, dict_err_code[32], {}))

    if (request.form.get('address', None) is None):
        return obj2json(RetModel(33, dict_err_code[33], {}))

    if (request.form.get('longitude', None) is None):
        return obj2json(RetModel(34, dict_err_code[34], {}))

    if (request.form.get('latitude', None) is None):
        return obj2json(RetModel(35, dict_err_code[35], {}))

    customer = Customer()
    customer.id = request.form['id']
    customer.uid = request.form['uid']
    customer.name = request.form['name']
    customer.group_name = request.form.get('group_name', '')
    customer.spell = request.form.get('spell', '')
    customer.address = request.form['address']
    customer.longitude = request.form['longitude']
    customer.latitude = request.form['latitude']
    customer.boss = request.form.get('boss', '')
    customer.phone = request.form.get('phone', '')
    customer.email = request.form.get('email', '')
    customer.description = request.form.get('description', '')
    customer.update_date = request.form.get('update_date', int(time.time()))

    szRet = ''
    if (False == if_customer_exists(customer)):
        szRet = obj2json(RetModel(30, dict_err_code[30], {}))
    else:
        if (True == update_customer_info(request.form['uid'], customer)):
            szRet = obj2json(RetModel(0, dict_err_code[0], {}))
        else:
            szRet = obj2json(RetModel(1000, dict_err_code[1000], {}))

    return szRet
コード例 #7
0
def create():
    if request.method == "GET":
        return render_template('new-customer.html')
    elif request.method == "POST":
        form = request.form
        name = form['name']
        yob = form['yob']
        phone = form['phone']

        new_customer = Customer(name=name, yob=yob, phone=phone)
        #update: set before input value, radio button
        new_customer.save()
        return redirect(url_for('admin'))
コード例 #8
0
def create_fake_names(no_to_create=1):
    for _ in range(no_to_create):
        company_name = fake.company()
        email_id = fake.email()
        phone = fake.phone_number()
        mobile = fake.numerify(text="04## ### ###")

        cust = Customer(company_name)
        cust.connection = connection
        cust.emailId = email_id
        cust.mobileNo = phone
        cust.insert_record()

        address = Address()
        address.connection = connection
        address.name = cust.name
        address.email_id = cust.emailId
        address.phone = fake.phone_number()
        address.addressLine1 = fake.numerify(
            text="###") + ' ' + fake.street_name() + ' ' + fake.street_suffix(
            )
        address.suburb = fake.city()
        address.postCode = fake.postcode()
        address.state = fake.state()
        address.insert_record()

        link = DynamicLink(cust.name, address.name + '-' + address.addressType,
                           'Address', 'Customer')
        link.connection = connection
        link.insert_record()

        contact = Contact()
        contact.companyName = cust.name
        contact.connection = connection
        contact.firstName = fake.first_name()
        contact.lastName = fake.last_name()
        contact.phone = fake.phone_number()
        contact.mobile = mobile
        contact.emailID = fake.email()
        contact.insert_record()

        link = DynamicLink(
            cust.name,
            contact.firstName + '-' + contact.lastName + '-' + cust.name,
            'Contact', 'Customer')
        link.connection = connection
        link.insert_record()

    connection.close()
コード例 #9
0
ファイル: Car_UI.py プロジェクト: Verkefni1/CarRental
    def customer_menu(self, current_employee):
        # We need to implement these functions into the repo.
        # Both of these functiosn are required
        action = ""
        options = ["1", "2", "3", "4"]
        print("=== CUSTOMERS ===\n")
        while action not in options:
            print("AVAILABLE OPTIONS:")
            print(
                "1. Register a customer\n2. Look up Customer\n3. Remove customer\n4. Go back\n"
            )
            action = input("Enter: ")
            print("")

            if action == "1":  ## DONE
                print("Registering a customer")
                first_name = input("First name: ")
                last_name = input("Last name: ")
                address = input("Address: ")
                drivers_license = input("Drivers license: ")
                SSN = input("SSN: ")
                new_customer = Customer(last_name, first_name, address,
                                        drivers_license, SSN)
                self.__car_rental_service.add_customer(new_customer)
                print("")
                self.customer_menu(current_employee)

            elif action == "2":  ## NOT DONE
                print("Looking up customer")
                SSN = input("SSN: ")
                print("")
                self.__car_rental_service.search_customer(SSN)
                self.customer_menu(current_employee)

            elif action == "3":  ## NOT DONE
                print("Remove customer")
                SSN = input("SSN: ")
                self.__car_rental_service.remove_customer(SSN)
                self.customer_menu(current_employee)

            elif action == "4":
                print("Going back to main menu")
                self.main_menu(current_employee)

            else:
                print("Invalid input")
                self.customer_menu(current_employee)
コード例 #10
0
 def populate_customer_list(self):
     """ Opens the database (csv) file and reads its contents. 
     If the file doesn't exist it is created with the columns of the file. """
     try:
         with open("./data/customers.csv", "r") as customer_db:
             csv_dict = csv.DictReader(customer_db)
             for line in csv_dict:
                 new_customer = Customer(
                     line["customer_ID"], line["identity_number"],
                     line["first_names"], line["surname"],
                     line["citizenship"], line["passport_ID"],
                     line["credit_card_no"])
                 self.__customers.append(new_customer)
     except FileNotFoundError:
         with open("./data/customers.csv", "a+") as customer_db:
             customer_db.write(
                 "customer_ID,identity_number,first_names,surname,citizenship,passport_ID,credit_card_no\n"
             )
コード例 #11
0
 def action1():
     print("-"*80)
     print("New customer:")
     SSN_input = input('Enter The SSN Of The Person You Want To Sign Up: ')
     SSN = self.__CustomerService.check_SSN(SSN_input)
     # isFound iterates through the file and if there is a match, it will let you know that the customer already exists
     isfound = self.__CustomerService.check_Costumer(SSN)
     if isfound:
         print('\nCustomer Already Exists!')
     else:
         name = input('Enter A Name: ')
         phonenumber_input = input('Enter A Phone Number: ')
         phonenumber = self.__CustomerService.check_Phonenumber(
             phonenumber_input)
         email = input('Enter An Email: ')
         new_Costumer = Customer(SSN, name, phonenumber, email)
         self.__CustomerService.add_customer(new_Costumer)
         print('\nCustomer Signed!')
コード例 #12
0
def init_customer(row):
    customer = Customer()
    customer.id = row['id']
    customer.uid = row['uid']
    customer.name = row['name']
    customer.group_name = row['group_name']
    customer.spell = row['spell']

    customer.address = row['address']
    customer.longitude = row['longitude']
    customer.latitude = row['latitude']
    customer.boss = row['boss']
    customer.phone = row['phone']

    customer.email = row['email']
    customer.description = row['description']
    customer.update_date = row['update_date']
    customer.is_deleted = row['is_deleted']

    return customer
コード例 #13
0
 def checkCredentials(user_id, password):
     user = None
     db = connector.connect(user='******',
                                password='******',
                                host='127.0.0.1',
                                database='python_bank_project')
     cursor = db.cursor()
     args = (user_id, password)
     cursor.execute("Select c.first_name, c.last_name, c.address_id, a.status from customer as c, account as a where c.cust_id = %s and c.password = %s and a.account_no = c.cust_id", args)
     results = cursor.fetchall();
     if len(results) > 0:
         if(results[0][3] == 'C'):
             print("Your Account is Closed. Please contact your bank admin.")
         else:
             user = Customer();
             user.set_first_name(results[0][0])
             user.set_last_name(results[0][1])
             user.set_address(results[0][2])
     db.close()
     return user
コード例 #14
0
def customer_create(user, storeId):
    customer_fields = customer_schema.load(request.json)
    customer = Customer.query.filter_by(email=customer_fields["email"]).first()
    if customer:
        return abort(400, description="Email already in use")

    new_customer = Customer()
    new_customer.firstname = customer_fields["firstname"]
    new_customer.lastname = customer_fields["lastname"]
    new_customer.email = customer_fields["email"]
    new_customer.phone = customer_fields["phone"]
    new_customer.store_id = storeId

    store = Store.query.filter_by(id=storeId, user_id=user.id).first()
    if not store:
        return abort(400, description="Incorrect storeID in URL")

    store.customer.append(new_customer)
    db.session.commit()

    return jsonify(customer_schema.dump(new_customer))
コード例 #15
0
 def new_Or_Old():
     '''Is the Customer new or has he rented from us before'''
     print("-" * 80)
     new_Or_Old = input(
         'Has The Customer Rented From Us Before? (Y = Yes, N = No) '
     ).lower()
     while new_Or_Old != 'y' or 'n':
         if new_Or_Old == 'y':
             print()
             break
         elif new_Or_Old == 'n':
             print("\nSigning A New Customer:")
             print("-" * 80)
             SSN_input = input(
                 'Enter The SSN Of The Person Who Is Putting In An Order: '
             )
             SSN = self.__CustomerService.check_SSN(SSN_input)
             # isFound iterates through the file and if there is not match it will allow the user to try again
             isfound = self.__CustomerService.check_Costumer(SSN)
             if isfound:
                 print('\nCustomer Already Exists!'
                       )  #we dont need to sign him up
             else:
                 name = input('Enter A Name: ')
                 phonenumber_input = input('Enter A Phone Number: ')
                 phonenumber = self.__CustomerService.check_Phonenumber(
                     phonenumber_input)
                 email = input('Enter An Email: ')
                 new_Costumer = Customer(SSN, name, phonenumber, email)
                 self.__CustomerService.add_customer(new_Costumer)
                 print("\nCostumer Signed!\n\n")
                 break
         else:
             print('Invalid Input, Try Again!')
             new_Or_Old = input(
                 'Has The Customer Rented A Car From Us Before? (Y = Yes, N = No) '
             ).lower()
コード例 #16
0
ファイル: Service.py プロジェクト: cpa750/booking-service
 def create_customer(self, customer_id, name, phone_no):
     customer = Customer(self.__db, customer_id, name, phone_no)
     # Returns false if the customer already exists to inform the client.
     # Returns true for a successful creation.
     return not customer.in_db
コード例 #17
0
ファイル: Service.py プロジェクト: cpa750/booking-service
 def checkout(self):
     customer = Customer(self.__db, self.current_customer_id)
     if customer.get_no_of_reservations() > 0:
         return True
     else:
         return False
コード例 #18
0
def seed_db():
    from models.User import User
    from models.Store import Store
    from models.Product import Product
    from models.Customer import Customer
    from models.Order import Order
    from main import bcrypt
    from faker import Faker

    faker = Faker()
    users = []
    stores = []
    products = []
    customers = []

    for i in range(5):
        user = User()
        user.email = f"test{i+1}@test.com"
        user.password = bcrypt.generate_password_hash("123456").decode("utf-8")
        user.isAdmin = False
        db.session.add(user)
        users.append(user)

        db.session.commit()

        store = Store()
        store.storename = faker.bs()
        store.firstname = faker.first_name()
        store.lastname = faker.last_name()
        store.user_id = users[i].id
        db.session.add(store)
        stores.append(store)

        db.session.commit()

        for j in range(5):
            product = Product()
            product.title = faker.numerify(text="Duck ###")
            product.price = faker.random_int(min=5, max=200, step=5)
            product.store_id = stores[i].id
            db.session.add(product)
            products.append(product)

        db.session.commit()

        for j in range(5):
            customer = Customer()
            customer.firstname = faker.first_name()
            customer.lastname = faker.last_name()
            customer.email = faker.ascii_email()
            customer.phone = faker.phone_number()
            customer.store_id = stores[i].id
            db.session.add(customer)
            customers.append(customer)

            db.session.commit()

            for k in range(5):
                order = Order()
                order.order_placed = choice([True, False])
                order.customer_id = choice(customers).id
                db.session.add(order)

                db.session.commit()

                for m in range(3):
                    order.orders_products.append(choice(products))

                    db.session.commit()

        customers = []

    db.session.commit()

    print("Tables seeded")
コード例 #19
0
    def main_menu(self):
        if self.access != "user" and self.access != "admin":
            self.access = login()
        action = ""
        while (action != "q"):
            os.system("cls")
            print(9 * "-", " Main Menu ", 9 * "-")
            print(" You can do the following:\n")

            print(indent, "1 | Cars")
            print(indent, "2 | Orders")
            print(indent, "3 | Customers")
            print(indent, "q | Quit")
            print()

            action = input(" Input number/letter: ").lower()

            if action == "1":
                # Goes to Cars menu

                os.system("cls")
                print(10 * "-", " Cars Menu ", 10 * "-")
                print(" You can do the following:\n")
                print(indent, "1 | See Available cars")
                print(indent, "2 | See Unavailable cars")
                print(indent, "3 | See List of all cars")
                print(indent, "4 | See Details of a car")
                print(indent, "5 | See Prices")
                if self.access == "admin":
                    print(indent, "6 | Register new car")
                    print(indent, "7 | Change price list")
                action = self.print_options()

                #action = input(" Input number/letter: ").lower()

                if action == "1":
                    # See available cars
                    os.system("cls")
                    action = ""
                    self.__car_service.available_cars()

                    print()
                    promt = input(" Press enter to go to main menu ")

                    action = "m"

                elif action == "2":
                    # See unavailable cars
                    os.system("cls")
                    action = ""
                    self.__car_service.unavailable_cars()
                    print()
                    promt = input(" Press enter to go to main menu ")

                    action = "m"

                elif action == "3":
                    # List of all cars
                    os.system("cls")
                    action = ""
                    self.__car_service.get_cars_list()
                    print()
                    promt = input(" Press enter to go to main menu ")

                    action = "m"

                elif action == "4":
                    # See Details of a car
                    while (action != "q"):
                        lp_number = input("Licence plate number: ").upper()
                        while not len(lp_number) == 5:
                            lp_number = input(
                                "Please enter a valid license plate number: ")
                        a = self.__car_service.details_of_car(lp_number)
                        print()

                        if a == True:
                            action = self.print_options()
                            self.additional_options(action)
                        if a == False:
                            continue

                elif action == "5":
                    # See price list
                    os.system("cls")
                    action = ""
                    while (action != "q"):
                        print(9 * "-", "Price Menu", 9 * "-")
                        print(" You can do the following:\n")
                        print(indent, "1 | See price list")
                        print(indent, "2 | Calculate prices")
                        action = self.print_options()

                        if action == "1":
                            self.__price_service.get_price_list()
                            print()
                            print("Press enter to go back")
                            action = input(" ")

                        if action == "2":
                            print(10 * "-", "Calculate prices", 10 * "-")
                            print("Choose class: \n")
                            print(indent, "A | Class A")
                            print(indent, "B | Class B")
                            print(indent, "C | Class C")
                            print("")

                            class_filter = input(" Input letter:  ").upper()
                            while class_filter not in ["A", "B", "C"]:
                                class_filter = input(
                                    " Please enter a valid class (a, b, or c): "
                                )
                            days = input(" Input number of days: ")
                            while not days.isdigit():
                                days = input(
                                    " Please enter valid number of days: ")
                            days_int = int(days)

                            self.__price_service.calculate_price(
                                class_filter, days_int)
                            #os.system("cls")
                            print()
                            print("Press enter to go back")
                            action = input(" ")

                        self.additional_options(action)
                elif action == "6" and self.access == "admin":
                    # Register new car
                    os.system("cls")
                    lp_number = input(" Licence plate number: ").upper()
                    while not len(lp_number) == 5:
                        lp_number = input(
                            "Invalid Licence plate number. License plate format examples: ABC12, AB123.\n Please enter a valid licence plate number: "
                        )
                    category = input(" Category: ").upper()
                    while category not in ["A", "B", "C"]:
                        category = input(
                            "Invalid input. Valid categories are 'A', 'B', and 'C'.\n Please enter a valid category: "
                        ).upper()
                    brand = input(" Brand: ").capitalize()
                    while not brand.isalpha():
                        brand = input(
                            "Invalid brand name.\n Please enter a valid brand name: "
                        ).capitalize()
                    model = input(" Model: ")
                    colour = input(" Colour: ").capitalize()
                    while colour not in [
                            "Yellow", "Red", "Green", "Blue", "Black", "White",
                            "Gray"
                    ]:
                        colour = input(
                            "Invalid color. Valid colours are yellow, red, green, blue, white, and gray.\n Please enter a valid colour:  "
                        ).capitalize()
                    year = input(" Year: ")
                    while not len(year) == 4:
                        year = input(
                            "Invalid year.\n Please enter a valid year.")
                    kilometers = input(" Kilometers: ")
                    while not kilometers.isdigit():
                        kilometers = input(
                            "Invalid input. Please enter only digits.\n Kilometers: "
                        )
                    status = input(" Status: ").capitalize()
                    while status not in ["Available", "Unavailable"]:
                        status = input(
                            "Invalid status. Valid inputs are 'Available' and 'Unavailable'.\n Status: "
                        )
                    new_car = Car(lp_number, category, brand, model, colour,
                                  year, kilometers, status)

                    self.__car_service.add_car(new_car)
                    print("")
                    print(" You have registered a new car!")
                    print("")
                    self.print_options()
                    print("")
                    if action == "m".lower():
                        self.main_menu()

                elif action == "7" and self.access == "admin":
                    #Change price list
                    action = ""
                    os.system("cls")
                    class_filter = input("Class: ")
                    key = "Price"
                    self.__price_service.change_price(key, class_filter)
                    action = self.print_options()
                    self.additional_options(action)

                self.additional_options(action)

            elif action == "2":
                # Goes to Orders menu

                while (action != "q"):
                    os.system("cls")
                    print(8 * "-", " Orders Menu ", 9 * "-")
                    print(" You can do the following:\n")

                    print(
                        indent, "1 | Rent cars"
                    )  # ætti að koma valmöguleik að register new customers OR choose customers
                    print(indent, "2 | Calculate Cost of rent")
                    print(indent, "3 | Return cars")
                    print(indent, "4 | Cancel Reservation")
                    print(indent, "5 | See list of all orders")
                    print(indent, "6 | Find an order")
                    action = self.print_options()

                    if action == "1":
                        #Rent cars and ther under
                        number = 0
                        price = 0
                        lp_number = " "
                        actual_return_date = ""
                        customer_id = input("Input customer id: ")
                        category = input("Input category: ").upper()
                        pickup_date = input("Input pickup date (dd.mm.yyyy): ")
                        return_date = input("Input return date (dd.mm.yyyy): ")
                        insurance = input(
                            "Do you want extra insurance? Y/N? :").upper()
                        new_order = Order(number, customer_id, lp_number,
                                          category, pickup_date, return_date,
                                          price, insurance, actual_return_date)
                        self.__order_service.rent_car(new_order)

                        action = self.print_options()

                        self.additional_options(action)

                        #Hér þarf að taka til hendinni og laga virknina.
                        #Skref 1 er að stimpla inn kennitölu, ef hún er ekki á skrá þá þarf að skrá viðskiptavin

                        # action = ""
                        # while(action != "q"):
                        #     os.system("cls")
                        #     print("You can do the following:\n")

                        #     print("1 | Register new customers")
                        #     print("2 | Choose customers")
                        #     print("m | Go to Main menu")
                        #     print()

                        #     action = input("Input number/letter: ").lower()

                        #     print(" You can do the following:\n")

                        #     print(indent,"1 | Register new customers")
                        #     print(indent,"2 | Choose customers")
                        #     self.print_options()
                        #     print()

                        #     action = input(" Input number/letter: ").lower()

                        #     if action == "1":
                        #         self.__order_service.return_car()

                        #         # Register new customer
                        #         os.system("cls")
                        #         id_number = input(" Customer ID: ")
                        #         while len(id_number) != 10:
                        #             id_number = input(" Invalid Customer ID. Customer ID is either Icelandic SSN or Passport number of length 10.\n Please enter a valid Customer ID:  ")
                        #         first_name = input(" First name: ")
                        #         while not first_name.isalpha():
                        #             first_name = input(" Invalid first name.\n Please enter a valid first name: ")
                        #         last_name = input(" Last name: ")
                        #         while not last_name.isalpha():
                        #             last_name = input(" Invalid last name.\n Please enter a valid last name: ")
                        #         age = input(" Age: ")
                        #         while not age.isdigit():
                        #             age = input(" Invalid input, only digits allowed.\n Age: ")
                        #         country = input(" Country: ")
                        #         while not country.isalpha():
                        #             country = input(" Invalid input. \n Please enter a valid country: ")
                        #         email = input(" E-mail: ")
                        #         while ("@" and ".")not in email:
                        #             email = input(" Invalid E-mail address.\n Please enter a valid E-mail address:  ")
                        #             if len(email) <= 6:
                        #                 email = input(" Invalid E-mail address.\n Please enter a valid E-mail address: ")
                        #         phone = input(" Phone number: ")
                        #         while not phone.isdigit() and len(phone) <= 9:
                        #             phone = input(" Invalid phone number. Phone number should only be digits on and must contain country code.\n Please enter a valid Phone number: ")
                        #         dl_number = input(" Drivers license number: ")
                        #         while len(dl_number) <= 8:
                        #             dl_number = input("Invalid drivers license number, must me at least 9 letters/digits long.\n Please enter a valid drivers license number: ")
                        #         cc_number = input(" Credit card number: ")
                        #         while not cc_number.isdigit():
                        #             cc_number = input("Invalid creditcard number.\n Please enter a valid creditcard number: ")
                        #         new_customer = Customer(id_number, first_name, last_name, age, country, email, phone, dl_number, cc_number)
                        #         #new_customer = customer(id_number, first_name)
                        #         self.__customer_service.add_customer(new_customer)

                        #         #######print(new_customer)

                        #     if action == "2":
                        #         #Choos customers
                        #         pass

                        #     self.additional_options(action)

                        #     # #Rent a car
                        #     # self.__order_service.rent_car()

                    elif action == "2":
                        #Calculate Cost of rent
                        print(8 * "-", "Calculate prices", 8 * "-")
                        print("Choose class: \n")
                        print(indent, "A | Class A")
                        print(indent, "B | Class B")
                        print(indent, "C | Class C")
                        print("")

                        class_filter = input(" Input letter:  ").upper()
                        days = input(" Input number of days: ")
                        days_int = int(days)
                        self.__price_service.calculate_price(
                            class_filter, days_int)
                        print()

                        action = self.print_options()
                        self.additional_options(action)

                    elif action == "3":
                        #Return Cars
                        order_number = input('Enter Order Number: ')
                        self.__order_service.return_car(order_number)

                        action = self.print_options()

                        self.additional_options(action)
                        pass

                    # elif action == "4":
                    # #Change Reservation

                    #     order_filter = input("Enter Order Number: ")
                    #     while not order_filter.isdigit():
                    #         order_filter = input("Please enter valid order number: ")

                    #     print("You can change:\n")
                    #     print(indent,"1 | Pick-up Date")
                    #     print(indent,"2 | Return Date")
                    #     print(indent,"c | Cancel")
                    #     print(indent,"q | Quit")

                    #     action = input("What do you want to change?: ")
                    #     while action not in ["1", "2"]:
                    #         action = input("Invalid input. Enter 1 or 2: ")

                    #     key_filter = "Number"

                    #     if action == "1":
                    #         key = "Pick-up Date"
                    #     elif action == "2":
                    #         key = "Return Date"
                    #     if (action != "") and ((action != "m") or (action != "c")):
                    #         self.__order_service.change_order(key, key_filter, order_filter)

                    #     self.print_options()

                    #     action = input("Input letter: ")
                    #     self.additional_options(action)

                    elif action == "4":
                        #Cancel Reservation
                        order_number = input("Enter Order Number: ")
                        self.__order_service.cancel_order(order_number)

                    elif action == "5":
                        #See list of all orders
                        os.system("cls")
                        action = ""
                        self.__order_service.get_orders()
                        print()
                        action = input(" Press enter to go back ")

                        if action == "b":
                            self.main_menu()
                            self.additional_options(action)

                    elif action == "6":
                        #Details of order
                        os.system("cls")
                        order_number = input("Order number: ")
                        while not order_number.isdigit():
                            order_number = input(
                                "Please enter a valid order number: ")
                        self.__order_service.find_order(order_number)
                        print()
                        action = self.print_options()
                        self.additional_options(action)

                    self.additional_options(action)

            elif action == "3":
                # Goes to Customers menu

                while (action != "q"):
                    os.system("cls")
                    print(7 * "-", " Customers Menu ", 7 * "-")
                    print(" You can do the following:\n")

                    print(indent, "1 | Register new customer")
                    print(indent, "2 | Find customer")
                    print(indent, "3 | List all customers")
                    print(indent, "4 | Change customer information")
                    if self.access == "admin":
                        print(indent, "5 | Remove customer from system")
                    print(indent, "m | Go to Main menu")
                    print(indent, "q | Quit")
                    print()

                    action = input(" Input number/letter: ").lower()

                    if action == "1":
                        # Register new customer
                        os.system("cls")
                        id_number = input(" Customer ID: ")
                        while len(id_number) != 10:
                            id_number = input(
                                " Invalid Customer ID. Customer ID is either Icelandic SSN or Passport number of length 10.\n Please enter a valid Customer ID:  "
                            )
                        first_name = input(" First name: ")
                        while not first_name.isalpha():
                            first_name = input(
                                " Invalid first name.\n Please enter a valid first name: "
                            )
                        last_name = input(" Last name: ")
                        while not last_name.isalpha():
                            last_name = input(
                                " Invalid last name.\n Please enter a valid last name: "
                            )
                        age = input(" Age: ")
                        while not age.isdigit():
                            age = input(
                                " Invalid input, only digits allowed.\n Age: ")
                        country = input(" Country: ")
                        while not country.isalpha():
                            country = input(
                                " Invalid input. \n Please enter a valid country: "
                            )
                        email = input(" E-mail: ")
                        while ("@" and ".") not in email:
                            email = input(
                                " Invalid E-mail address.\n Please enter a valid E-mail address:  "
                            )
                            if len(email) <= 6:
                                email = input(
                                    " Invalid E-mail address.\n Please enter a valid E-mail address: "
                                )
                        phone = input(" Phone number: ")
                        while not phone.isdigit() and len(phone) <= 9:
                            phone = input(
                                " Invalid phone number. Phone number should only be digits on and must contain country code.\n Please enter a valid Phone number: "
                            )
                        dl_number = input(" Drivers license number: ")
                        while len(dl_number) <= 8:
                            dl_number = input(
                                "Invalid drivers license number, must me at least 9 letters/digits long.\n Please enter a valid drivers license number: "
                            )
                        cc_number = input(" Credit card number: ")
                        while not cc_number.isdigit():
                            cc_number = input(
                                "Invalid creditcard number.\n Please enter a valid creditcard number: "
                            )
                        new_customer = Customer(id_number, first_name,
                                                last_name, age, country, email,
                                                phone, dl_number, cc_number)

                        self.__customer_service.add_customer(new_customer)
                        break

                    elif action == "2":
                        # Find customer
                        action = ""
                        while (action != "q"):
                            os.system("cls")

                            customer_id = input("Customer ID: ")
                            while not len(customer_id) == 10:
                                customer_id = input(
                                    "Please enter a valid customer ID: ")
                            a = self.__customer_service.find_customer(
                                customer_id)
                            if a == True:
                                break
                            if a == False:
                                continue

                            print()
                            action = self.print_options()

                            self.additional_options(action)

                    elif action == "3":
                        # List all customers
                        os.system("cls")
                        self.__customer_service.get_customers()
                        print()
                        self.print_options()
                        action = input(" Input letter: ").lower()
                        self.additional_options(action)

                    elif action == "4":
                        # Change customer information

                        action = ""
                        while (action != "q"):
                            os.system("cls")
                            customer_filter = input("Customer ID: ")
                            action = ""

                            key_filter = "Customer ID"

                            print(" You can change the following:\n ")

                            print(indent, "1 | First name")
                            print(indent, "2 | Last name")
                            print(indent, "3 | Date of birth")
                            print(indent, "4 | Country")
                            print(indent, "5 | E-mail address")
                            print(indent, "6 | Phone number")
                            print(indent, "7 | Drivers License number")
                            print(indent, "8 | Credit card number")
                            print(indent, "c | Cancel")
                            print(indent, "q | Quit")
                            action = input(" Input number/letter: ").lower()

                            if action == "1":
                                key = "First Name"
                            elif action == "2":
                                key = "Last Name"
                            elif action == "3":
                                key = "Age"
                            elif action == "4":
                                key = "Country"
                            elif action == "5":
                                key = "Email"
                            elif action == "6":
                                key = "Phone"
                            elif action == "7":
                                key = "Drivers License Number"
                            elif action == "8":
                                key = "Credit Card Number"
                            elif action == "c":
                                break

                            if (action != "") and ((action != "m") or
                                                   (action != "c")):
                                self.__customer_service.change_customer_info(
                                    key, key_filter, customer_filter)
                            self.print_options()

                            action = input("Input letter:")
                            self.additional_options(action)

                    elif action == "5" and self.access == "admin":
                        #Remove Customer from system
                        action = ""
                        while (action != "q"):
                            os.system("cls")

                            print(
                                " You are about to remove a customer from the system.\n"
                            )

                            customer_filter = input(" Enter customers ID:  ")

                            if customer_filter != []:
                                key_filter = "Customer ID"
                                a = self.__customer_service.remove_customer(
                                    key_filter, customer_filter)

                            if a == True:
                                break
                            if a == False:
                                continue

                            # back er ekki alveg að virka, en það virkar ef það hefur break...

                            self.print_options()
                            action = input(" Input letter: ").lower
                            self.additional_options(action)

                    elif action == "":
                        action = 1
                    elif action == "b":
                        self.main_menu()
                    elif action != 1:
                        self.additional_options(action)

            if action == "q":
                return SystemExit
コード例 #20
0
ファイル: main.py プロジェクト: Binovizer/Python-Beginning
        if (account_type == 1):
            account_type_str = "Saving"
            balance = validateAmount("Enter Opening Balance Please: ")
            new_account = SavingAccount(balance)
        elif (account_type == 2):
            account_type_str = "Current"
            balance = validateAmount("Enter Opening Balance Please: ")
            while (balance < CurrentAccount.min_balance):
                print("Sorry! Min Opening Balance Should be " +
                      str(CurrentAccount.min_balance))
                balance = validateAmount("Enter Opening Balance Please: ")
            new_account = CurrentAccount(balance)
        else:
            print("Invalid Choice")

        new_user = Customer(fname, lname, address)
        print("Please Enter Your Password")
        password = validatePassword(input("Password: "******"Password: "******"Re-Password: "******"Re-Password: "******"Please enter the same password.")
            password = validatePassword(input("Password: "******"Password: "******"Re-Password: "******"Re-Password: "******"Your Customer ID is : ", new_user.get_cust_id())
        print("Please Keep it Safe.")
        Util.save(new_account, new_user.get_cust_id(), account_type_str)
コード例 #21
0
ファイル: SalesmanUi.py プロジェクト: Birnak/Assignment8
    def main_menu(self):
        update_progress(-1)
        time.sleep(.4)
        update_progress(1)
        time.sleep(.3)
        cls('')
        time.sleep(.2)
        action = ""
        while (action != "h"):
            print(
                "╔════════════════════════════════════════════════════════════════════════════════════╗"
            )
            print(
                "║                                                          ",
                "%d" % now.day + "/" + "%d" % now.month + "/" +
                "%d" % now.year + " | " + now.strftime("%H:%M:%S"), "    ║")
            print(
                "║--------------------------------------Aðgerðir:-------------------------------------║"
            )
            print(
                "║1. Leigja út bíl (skrá pöntun)                                                      ║"
            )
            print(
                "║2. Skila bíl í lok leigutíma                                                        ║"
            )
            print(
                "║--------------------------------------Skýrslur:-------------------------------------║"
            )
            print(
                "║4. Flétta upp pöntun                                                                ║"
            )
            print(
                "║6. Birta yfirlit yfir viðskiptamenn                                                 ║"
            )
            print(
                "║7. Birta lista yfir lausa bíla                                                      ║"
            )
            print(
                "║8. Birta lista yfir lausa bíla eftir flokkum                                        ║"
            )
            print(
                "║9. Birta lista yfir  bíla í útleigu                                                 ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "╠════════════════════════════════════════════════════════════════════════════════════╣"
            )
            print(
                "║--------------------------------Uppsetning / viðhald :------------------------------║"
            )
            print(
                "║90. Stofna notanda að kerfinu                                                       ║"
            )
            print(
                "║91. Stofna viðskiptamann                                                            ║"
            )
            print(
                "║92. Stofna bíl                                                                      ║"
            )
            print(
                "╠════════════════════════════════════════════════════════════════════════════════════╣"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║Sláðu inn 'h' til að hætta                                                          ║"
            )
            print(
                "╚════════════════════════════════════════════════════════════════════════════════════╝"
            )
            action = input("Veldu valmöguleika: ").lower()
            if action == "1":
                d = {}
                cls('start')  # now, to clear the screen
                d["ORDER_ID"] = input("Sláðu inn pöntunarnúmer: ")
                d["CUSTOMER_ID"] = input("Nr viðskiptamanns: ")
                d["LICENCE_PLATE_NUMBER"] = input("Bílnúmer: ")
                d["CAR_LOCATION"] = input("Staðsetning bíls í upphafi ")
                d["ORDER_DATE"] = input("Pöntun dags: ")

                d["START_DATE"] = input("Start date: ")
                """
                ret_loc = input('Skilastaðsetning bíls: ')
                ret_date = input("Skiladags bíls: ")
                pay_meth = input("Greiðslumáti: ")
                card_no  = input("  Kortanúmer (ef við á): ")
                ins_bas = input("Grunntrygging: ")
                ins_xtra = input("Aukatrygging: ")
                com_ = input("Athugasemdir: ") """

                #new_o = Ord(order_n,customer_n,license_plate_n,start_loc,order_d,start_d,ret_loc,ret_date,pay_meth,card_no,ins_bas,ins_xtra,com_)
                new_o = Ord(d)
                self.__Ord_service.add_Ord(new_o)

                cls('end')
            elif action == "6":
                cls('')
                customer = self.__Customer_service.get_Customer()
                print(customer)
                cls('end')
            elif action == "7":
                cls('')  # now, to clear the screen
                vehicles = self.__Vehicle_service.get_Available_Vehicles()

                #for row in vehicles:
                #   print(row)
                cls('end')
            elif action == "8":
                cls('')  # now, to clear the screen
                vec_class = input(
                    'Hvaða flokk viltu skoða?  (ath: sýna hér lista yfir mögulega flokka...) '
                )

                vehicles = self.__Vehicle_service.get_Available_Vehicles_by_Class(
                    vec_class)  # does this work?

                cls('end')
            elif action == "9":
                cls('')  # now, to clear the screen
                vehicles = self.__Vehicle_service.get_Occupied_Vehicles()
                cls('end')
            elif action == "89":
                cls('')
                newuser = input("Sláðu inn notendanafn: ")
                pwd = input("Sláðu inn lykilorð: ")
                ssn = input("Sláðu inn kennitölu: ")
                name = input('Fullt nafn: ')
                addr = input('Heimilisfang: ')
                phone = input("Símanúmer: ")
                e_mail = input("Tölvupóstfang: ")
                active = 'YES'
                comments = input('Athugasemd: ')
                new_employee = System_Maintenance(newuser, pwd, ssn, name,
                                                  addr, phone, e_mail, active,
                                                  comments)
                self.__System_MaintenanceService.add_System_Maintenance(
                    new_employee)
                cls('end')

#new_veh = Vehicle(license_plate, manuf,subt,v_class, prod_year,curr_loc,return_loc,return_date,com) #0D, simply represents that this car isn't rented out (yet)
#                self.__Vehicle_service.add_Vehicle(new_veh)

            elif action == "90":
                cls('')
                newuser = input("Sláðu inn notendanafn ")
                pwd = input("Sláðu inn lykilorð ")
                """ file = open("./data/access.txt","a+")
                file.write(newuser)
                file.write(" ")
                file.write(pwd)
                file.write("\n")
                file.close() """

                cls('end')
            elif action == "91":
                cls('')
                name = input("Nafn: ")
                kennitala = input("Kennitala: ")
                phone = input("Símanúmer: ")
                new_Customer = Customer(name, kennitala, phone)
                self.__Customer_service.add_Customer(new_Customer)
                cls('end')
            elif action == '92':
                cls('')
                license_plate = input("Bílnúmer: ")
                manuf = input("Framleiðandi: ")
                subt = input("Undirtegund (týpa) ")
                v_class = input("Flokkur: ")
                prod_year = input("Árgerð: ")
                curr_loc = input("Staðsetning: ")
                return_loc = ''  #doesn't apply to cars - until they are rented out
                return_date = '0D'
                com = input("Athugasemdir: ")

                #self, license_plate, manufacturer, subtype, vec_class, production_year,current_location,return_location,'',comments
                new_veh = Vehicle(
                    license_plate, manuf, subt, v_class, prod_year, curr_loc,
                    return_loc, return_date, com
                )  #0D, simply represents that this car isn't rented out (yet)
                self.__Vehicle_service.add_Vehicle(new_veh)

                cls('end')
            elif action == 'h':
                time.sleep(.2)
                print('Bíðið - kerfi slekkur á sér og gengur frá')
                # update_progress() : Displays or updates a console progress bar
                ## Accepts a float between 0 and 1. Any int will be converted to a float.
                ## A value under 0 represents a 'halt'.
                ## A value at 1 or bigger represents 100%
                update_progress(-1)
                time.sleep(.3)
                update_progress(1)
                time.sleep(.2)
                print('Sjáumst aftur!')
                time.sleep(.2)
                cls("")
            else:
                cls('')
                print('Óleyfilegt gildi slegið inn, reyndu aftur.')
コード例 #22
0
ファイル: Service.py プロジェクト: cpa750/booking-service
 def set_customer(self, customer_id):
     customer = Customer(self.__db, customer_id)
     if customer.in_db:
         self.current_customer_id = customer.customer_id
from models.Customer import Customer
import mlab
from faker import Faker
from random import randint, choice

mlab.connect()

faker = Faker()

# name = faker.name()
# print(name)
for i in range(100):
    print("Saving customer", i + 1, ".......")
    new_customer = Customer(name=faker.name(),
                            yob=randint(1940, 2000),
                            gender=randint(0, 1),
                            phone=faker.phone_number(),
                            address=faker.address(),
                            email=faker.email(),
                            job=faker.job(),
                            contacted=choice([True, False]))

    new_customer.save()
コード例 #24
0
    def create(self):
        counter = 0

        name = ""
        address = ""
        postal = ""
        ssn = ""
        phone = ""
        email = ""
        country = ""

        while True:
            self.printer.header("Create customer")
            print(
                f"Name:\t\t\t\t{name}\nAddress:\t\t\t{address}\nPostal code:\t\t\t{postal}\nPhone:\t\t\t\t{phone}\nSocial security number:\t\t{ssn}\nEmail:\t\t\t\t{email}\nCountry:\t\t\t{country}\n"
            )
            self.printer.new_line()
            self.printer.print_fail("Press q to go back")
            self.printer.new_line()
            self.notification()
            next_input = True
            data = None
            try:
                if counter == 0:
                    data = self.input.get_input("name", ["required"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        name = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 1:
                    data = self.input.get_input("address", ["required"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        address = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 2:
                    data = self.input.get_input("postal code", ["required"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        postal = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 3:
                    data = self.input.get_input("phone", ["required", "phone"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        phone = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 4:
                    data = self.input.get_input("social security number",
                                                ["required", "ssn"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        ssn = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 5:
                    data = self.input.get_input("email", ["required", "email"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        email = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter == 6:
                    data = self.input.get_input("country", ["required"],
                                                warning_msg=self.warning_msg)
                    if data[0]:
                        country = data[1]
                    else:
                        next_input = False
                        self.warning_msg = data[1]
                elif counter > 6:
                    new_customer = Customer(name, address, postal, ssn, phone,
                                            email, country)
                    confirmation = input(
                        "Are you sure you want to create this customer? (\33[;32mY\33[;0m/\33[;31mN\33[;0m): "
                    ).lower()
                    if confirmation == 'y':
                        return self.logic.create_customer(new_customer)
                    return False
                if next_input:
                    counter += 1
            except ValueError:
                break