def add_furniture(): """Adds 5 furniture documents to the furniture collection""" print("Attempting to seed the furniture collection.....") print() chair_path = Path("chair.png") couch = FurnitureItem( "Comfy couch", "Well loved, but still in pretty good condition", 60.00, 40, "*****@*****.**", "Couch", "beige", [50, 20, 10], ) couch.set_image_filepath(chair_path) Database.add_item(couch) print("couch has been successfully added") table = FurnitureItem( "Dining room table", "Wooden dining room table. Has a few scuffs, but not bad!", 30.00, 15, "*****@*****.**", "Table", "wood", [40, 20, 40], ) table.set_image_filepath(chair_path) Database.add_item(table) print("table has been successfully added") bed = FurnitureItem( "Bed Frame", "Just selling the bed frame, you'll have \ to get your own mattress", 55.00, 50, "*****@*****.**", "Bed", "white", [10, 20, 10], ) bed.set_image_filepath(chair_path) Database.add_item(bed) print("bed has been successfully added") desk = FurnitureItem( "Ikea desk, no longer need it", "In great condition, this is truly a steal", 60.00, 35, "*****@*****.**", "Ikea Desk", "navy", [20, 20, 30], ) desk.set_image_filepath(chair_path) Database.add_item(desk) print("desk has been successfully added") shelf = FurnitureItem( "Book shelf, never used", "Brand new", 110.00, 25, "*****@*****.**", "Book Shelf", "black", [10, 20, 100], ) shelf.set_image_filepath(chair_path) Database.add_item(shelf) print("shelf has been successfully added") print() print("Done seeding the furniture collection!") print("----------------------------------------------")
def add_clothing(): """Adds 5 clothing documents to the clothing collection""" print("Attempting to seed the clothing collection.....") print() shirt_path = Path("shirt.png") shirt = ClothingItem( "Lightly worn Hollister shirt", "Really cute, lightweight, and comfortable shirt! In good condition and selling \ for less than the original price.", 15.00, 0.16, "*****@*****.**", "shirt", ClothingSize.MEDIUM, ClothingGender.FEMALE, "olive green", ) shirt.set_image_filepath(shirt_path) Database.add_item(shirt) print("Shirt has been successfully added") jeans = ClothingItem( "A pair of cute Levi's", "Classic wash jeans, well taken care of. They just don't fit me anymore hahah!", 30.00, 0.20, "*****@*****.**", "jeans", ClothingSize.LARGE, ClothingGender.FEMALE, "classic blue wash", ) jeans.set_image_filepath(shirt_path) Database.add_item(jeans) print("Jeans have been successfully added") blazer = ClothingItem( "A professional blazer", "Its interview season! You probably need something to wear, so why not this cute \ blazer? Don't worry, its in great condition!", 20.50, 0.10, "*****@*****.**", "blazer", ClothingSize.SMALL, ClothingGender.UNISEX, "black", ) blazer.set_image_filepath(shirt_path) Database.add_item(blazer) print("Blazer has been successfully added") sweater = ClothingItem( "Fluffy sweater", "So snuggly and warm, my grandma knitted it", 13.00, 0.13, "*****@*****.**", "sweater", ClothingSize.MEDIUM, ClothingGender.UNISEX, "Orange", ) sweater.set_image_filepath(shirt_path) Database.add_item(sweater) print("Sweater has been successfully added") jacket = ClothingItem( "Leather jacket, vintage", "Really cool vintage leather jacket. A bit worn but that's the point", 150.00, 3.00, "*****@*****.**", "leather jacket", ClothingSize.LARGE, ClothingGender.MALE, "black", ) jacket.set_image_filepath(shirt_path) Database.add_item(jacket) print("Leather jacket has been successfully added") print() print("Done seeding the clothing collection!") print("----------------------------------------------")
def add_sports_gear(): """Adds 5 sports gear documents to the sports collection""" print("Attempting to seed the sports collection.....") print() football_path = Path("football.png") skiis = SportsGearItem( "Used skiis", "In great condition, also a great price!", 40.00, 1.05, "*****@*****.**", "Skiis", ClothingSize.MEDIUM, ClothingGender.UNISEX, ) skiis.set_image_filepath(football_path) Database.add_item(skiis) print("skiis have been successfully added") helmet = SportsGearItem( "Bicycle helmet", "I have a small head, like a child.", 15.00, 0.20, "*****@*****.**", "Helmet", ClothingSize.SMALL, ClothingGender.UNISEX, ) helmet.set_image_filepath(football_path) Database.add_item(helmet) print("helmet has been successfully added") snowboard = SportsGearItem( "Snowboard, no longer need it", "My mom bought me a new one for my birthday, so I no longer need this. Great condition.", 50.00, 0.10, "*****@*****.**", "Snowboard", ClothingSize.SMALL, ClothingGender.UNISEX, ) snowboard.set_image_filepath(football_path) Database.add_item(snowboard) print("snowboard has been successfully added") tennis_racket = SportsGearItem( "Tennis Racket, signed by Serena Williams", "Its signed!!!", 1500.00, 0.67, "*****@*****.**", "Tennis Racket", ClothingSize.MEDIUM, ClothingGender.UNISEX, ) tennis_racket.set_image_filepath(football_path) Database.add_item(tennis_racket) print("tennis racket has been successfully added") roller_skates = SportsGearItem( "Roller skates, great condition", "Super cute and sparkly!", 45.00, 2.00, "*****@*****.**", "Roller Skates", ClothingSize.LARGE, ClothingGender.UNISEX, ) roller_skates.set_image_filepath(football_path) Database.add_item(roller_skates) print("roller skates have been successfully added") print() print("Done seeding the sports collection!") print("----------------------------------------------")
def add_electronics(): """Adds 5 electronic documents to the electronic collection""" print("Attempting to seed the electronic collection.....") print() electronic_path = Path("electronic.png") ps1 = ElectronicItem( "Archaic PS1, come get herrrrr", "Classic, worth a lot of moolah, don't miss out!", 10000.00, 10, "*****@*****.**", "PlayStation", "First one ever", [10, 20, 10], ) ps1.set_image_filepath(electronic_path) Database.add_item(ps1) print("ps1 has been successfully added") ps2 = ElectronicItem( "Calling all vintage video game console collectors! Selling PS2!!!", "An oldie but a goodie.", 50.00, 10, "*****@*****.**", "PlayStation", "2nd", [10, 20, 10], ) ps2.set_image_filepath(electronic_path) Database.add_item(ps2) print("ps2 have been successfully added") ps3 = ElectronicItem( "PS3", "Still works like a charm!", 100.00, 10, "*****@*****.**", "PlayStation", "3rd", [10, 20, 10], ) ps3.set_image_filepath(electronic_path) Database.add_item(ps3) print("ps3 has been successfully added") ps4 = ElectronicItem( "PS4", "Selling for cheaper than you can get it at the stores!", 200.00, 10, "*****@*****.**", "PlayStation", "4th", [10, 20, 10], ) ps4.set_image_filepath(electronic_path) Database.add_item(ps4) print("ps4 has been successfully added") ps5 = ElectronicItem( "PS5! YES YOU READ THAT CORRECTLY!", "You know what this is bois", 100000.00, 10, "*****@*****.**", "PlayStation", "5th", [10, 20, 10], ) ps5.set_image_filepath(electronic_path) Database.add_item(ps5) print("ps5 has been successfully added") print() print("Done seeding the electronic collection!") print("----------------------------------------------")
def add_books(): """Adds 5 book documents to the book collection""" print("Attempting to seed the book collection.....") print() book_path = Path("book.png") book1 = BookItem( "Harry Potter pack for sale", "All 7 books! Come and get 'em!", 50.00, 8, "*****@*****.**", "Harry Potter - The Collection", 3, "-", ) book1.set_image_filepath(book_path) Database.add_item(book1) print("book1 has been successfully added") book2 = BookItem( "Econ textbook, never used", "Idk why I bought this to begin with. Never used it.", 75.00, 4, "*****@*****.**", "Introduction to Engineering Economics", 7, "ECON-235", ) book2.set_image_filepath(book_path) Database.add_item(book2) print("book2 has been successfully added") book3 = BookItem( "Comp Sci book for Prof Lowe's class", "Good condition, you're gonna need this for his class...", 35.00, 5.6, "*****@*****.**", "Data Structures in Java", 12, "CS-550", ) book3.set_image_filepath(book_path) Database.add_item(book3) print("book3 has been successfully added") book4 = BookItem( "Chemistry textbook, freshman I'm looking at you!", "For freshman year chem, selling for much cheaper than other students.", 30.00, 6, "*****@*****.**", "Introduction to Chemistry, a Hollistic Aproach", 2, "CH-115", ) book4.set_image_filepath(book_path) Database.add_item(book4) print("book4 has been successfully added") book5 = BookItem( "Calculus textbook", "A little worn out, but still usable.", 28.00, 16, "*****@*****.**", "Calculus made Simple, a Student Friendly Guide", 3, "MA-111", ) book5.set_image_filepath(book_path) Database.add_item(book5) print("book5 has been successfully added") print() print("Done seeding the book collection!") print("----------------------------------------------")
def get_sell(): if request.method == "POST": # grab form data in order they appear in sell.html category = request.form["category_drop_val"] post_title = request.form["post_title_val"] price = request.form["price_val"] title = request.form["title_val"] edition = request.form["ed_val"] if request.form["length_val"] != "": dimensions = [ int(request.form["length_val"]), int(request.form["width_val"]), int(request.form["height_val"]), ] weight = request.form["weight_val"] color = request.form["color_val"] # type is a key word type_val = request.form["type_val"] course_num = request.form["course_num_val"] size = request.form["size_val"] gender = request.form["gender_val"] model = request.form["model_val"] description = request.form["comments_val"] seller = request.form["seller_val"] # photo upload image_file = request.files["file"] filename = secure_filename(image_file.filename) image_filepath = uploadsdir.joinpath(filename) image_file.save(str(image_filepath)) # error handling if Decimal(price.strip()) < 0: price = "0" if title == "": title = "Title was not provided" if edition == "": edition = "Edition was not provided" if weight == "": weight = "0" if course_num == "": course_num = "Course Number was not provided" if color == "": color = "Color was not provided" if type_val == "": type_val = "Type was not provided" if request.form["length_val"] == "": dimensions = [ 0, 0, 0, ] if model == "": model = "Model was not provided" # create item and add item to database if category == "books": item = BookItem( post_title, description, Decimal(price.strip()), float(weight.strip()), seller, title, edition, course_num, ) item.set_image_filepath(filename) Database.add_item(item) flash("Success! Item has been posted!") elif category == "furniture": item = FurnitureItem( post_title, description, Decimal(price.strip()), float(weight.strip()), seller, type_val, color, dimensions, ) item.set_image_filepath(filename) Database.add_item(item) flash("Success! Item has been posted!") elif category == "clothes": item = ClothingItem( post_title, description, Decimal(price.strip()), float(weight.strip()), seller, type_val, int(size), int(gender), color, ) item.set_image_filepath(filename) Database.add_item(item) flash("Success! Item has been posted!") elif category == "sports": item = SportsGearItem( post_title, description, Decimal(price.strip()), float(weight.strip()), seller, type_val, int(size), int(gender), ) item.set_image_filepath(filename) Database.add_item(item) flash("Success! Item has been posted!") elif category == "electronics": item = ElectronicItem( post_title, description, Decimal(price.strip()), float(weight.strip()), seller, type_val, model, dimensions, ) item.set_image_filepath(filename) Database.add_item(item) flash("Success! Item has been posted!") return render_template("/sell.html", cart=cart)