def create_manufacturer(): name = request.form["name"] description = request.form["description"] category = request.form["category"] new_manufacturer = Manufacturer(name, description, category) new_manufacturer.activate() manufacturer_repository.save(new_manufacturer) return redirect("/manufacturers")
def update_manufacturer(id): name = request.form["name"] description = request.form["description"] category = request.form["category"] active = request.form["active"] # pdb.set_trace() new_manufacturer = Manufacturer(name, description, category, active) if request.form["active"] == False: new_manufacturer.make_inactive() new_manufacturer.id = id manufacturer_repository.update(new_manufacturer) return redirect("/manufacturers")
def select_by_name(name): sql = "SELECT * FROM manufacturers WHERE name = %s" values = [name] result = run_sql(sql, values) manufacturer = Manufacturer(result[0][1], result[0][2], result[0][3], result[0][4], result[0][0]) return manufacturer
def select(id): sql = "SELECT * FROM manufacturers WHERE id = %s" values = [id] result = run_sql(sql, values) manufacturer = Manufacturer(result[0][1], result[0][2], result[0][3], result[0][4], result[0][0]) return manufacturer
def update_manufacturer(id): name = request.form['name'] location = request.form['location'] product_type = request.form['product_type'] manufacturer = Manufacturer(name, location, product_type, id) manufacturer_repository.update(manufacturer) return redirect('/manufacturers')
def select(id): sql = "SELECT * FROM manufacturers WHERE id = %s" values = [id] result = run_sql(sql, values)[0] manufacturer = Manufacturer(result["name"], result["country"], result["id"]) return manufacturer
def update_manufacturer(id): name = request.form["name"] address = request.form["address"] deactivated = request.form["deactivated"] manufacturer = Manufacturer(name, address, deactivated, id) manufacturer_repository.update(manufacturer) return redirect("/manufacturers")
def update_manufacturer(id): name = request.form['name'] phone = request.form['phone'] website = request.form['website'] email = request.form['email'] manufacturer = Manufacturer(name, phone, website, email, id) manufacturer_repository.update(manufacturer) return redirect('/manufacturers')
def select_all(): manufacturers = [] sql = "SELECT * FROM manufacturers" results = run_sql(sql) for result in results: manufacturer = Manufacturer(result["name"], result["country"], result["id"]) manufacturers.append(manufacturer) return manufacturers
def setUp(self): self.manufacturer = Manufacturer( "Gorbruz' Gutspillaz", "Simple and Brutal. From an Orc's forge to your mate's face!", "Melee weapons") self.item = Item( "+1 Mace of Squishing", "A handy 1h weapon, enchanted for that extra *CRUNCH*", "Blunt 1h", 2, 5, self.manufacturer)
def select_all(): manufacturers = [] sql = "SELECT * FROM manufacturers" results = run_sql(sql) for row in results: manufacturer = Manufacturer(row['name'], row['contact'], row['id']) manufacturers.append(manufacturer) return manufacturers
def select(id): manufacturer = None sql = "SELECT * FROM manufacturers WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: manufacturer = Manufacturer(result['name'], result['location'], result['product_type'], result['id']) return manufacturer
def select(id): manufacturer = None sql = "SELECT * FROM manufacturers WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: manufacturer = Manufacturer(result['name'], result['address'], result['deactivated'], result['id']) return manufacturer
def select_all(): manufacturer = [] sql = "SELECT * FROM manufacturers" results = run_sql(sql) print(results) for row in results: manufacturer.append( Manufacturer(row[1], row[2], row[3], row[4], row[0])) return manufacturer
def select_all(): manufacturer = [] sql = "SELECT * FROM manufacturers" results = run_sql(sql) for row in results: new_manufacturer = Manufacturer(row['first_name'], row['last_name'], row['id']) manufacturer.append(new_manufacturer) return manufacturer
def select(id): print(id) manufacturer = None sql = "SELECT * FROM manufacturers WHERE id = %s" values = [id] result = run_sql(sql, values)[0] print("Manufacturer:", result) if result is not None: manufacturer = Manufacturer(result[1], result[2], result[3], result[4], result[0]) return manufacturer
def select_all(): manufacturers = [] sql = "SELECT * FROM manufacturers" results = run_sql(sql) for result in results: manufacturer = Manufacturer(result["name"], result["description"], result["category"], result["active"], result["id"]) manufacturers.append(manufacturer) return manufacturers
class TestManufacturer(unittest.TestCase): def setUp(self): self.manufacturer = Manufacturer( "Gorbruz' Gutspillaz", "Simple and Brutal. From an Orc's forge to your mate's face!", "Melee weapons") def test_manufacturer_has_name(self): self.assertEqual("Gorbruz' Gutspillaz", self.manufacturer.name) def test_manufacturer_has_description(self): self.assertEqual( "Simple and Brutal. From an Orc's forge to your mate's face!", self.manufacturer.description) def test_manufacturer_has_category(self): self.assertEqual("Melee weapons", self.manufacturer.category) def test_manufacturer_is_active(self): self.assertEqual(True, self.manufacturer.active) def test_manufacturer_is_not_active(self): self.manufacturer.make_inactive() self.assertEqual(False, self.manufacturer.active) def test_manufacturer_reactivate(self): self.manufacturer.make_inactive() self.assertEqual(False, self.manufacturer.active) self.manufacturer.reactivate() self.assertEqual(True, self.manufacturer.active)
def get_by_category(selected_filter): manufacturers = [] sql = "SELECT * FROM manufacturers WHERE category = %s" values = [selected_filter] results = run_sql(sql, values) for result in results: manufacturer = Manufacturer(result["name"], result["description"], result["category"], result["active"], result["id"]) manufacturers.append(manufacturer) return manufacturers
def setUp(self): self.manufacturer = Manufacturer( "Gorbruz' Gutspillaz", "Simple and Brutal. From an Orc's forge to your mate's face!", "Melee weapons")
def setUp(self): self.product = Product("Iphone SE", "5.5 inches", "Rose Gold", 299, 399, 50, "Apple") self.manufacturer = Manufacturer("Apple", "USA")
def setUp(self): self.manufacturer_1 = Manufacturer( "Cadbury's", "PO Box 12, Bournville, Birmingham B30 2LU", True) self.product1 = Product("Dairy Milk", "bar of milk chocolate", 5, 0.2, 1, "chocolate bars", self.manufacturer_1)
def create_manufacturer(): name = request.form["name"] country = request.form["country"] new_manufacturer = Manufacturer(name, country) manufacturer_repository.save(new_manufacturer) return redirect("/manufacturers")
def update_manufacturer(id): name = request.form["name"] country = request.form["country"] new_manufacturer = Manufacturer(name, country, id) manufacturer_repository.update(new_manufacturer) return redirect("/manufacturers")
def setUp(self): self.manufactuer = Manufacturer("Chanel", "012345678")
def setup(self): self.manufacturer_1 = Manufacturer('Pioneer', '8380 4944', 'www.pioneer.com', '*****@*****.**') self.manufacturer_2 = Manufacturer('Juno', '6680 3344', 'www.juno.com', '*****@*****.**')
def setUp(self): self.manufacturer1 = Manufacturer( "Cadbury's", "PO Box 12, Bournville, Birmingham B30 2LU", True) self.manufacturer2 = Manufacturer("Rowntree's", "123, York Avenue, York, Y01 1AB", False)
import pdb from models.item import Item from models.manufacturer import Manufacturer import repositories.item_repository as item_repository import repositories.manufacturer_repository as manufacturer_repository item_repository.delete_all() manufacturer_repository.delete_all() man_1 = Manufacturer("Lonely Mountain's Lost Halls", "Treasures raised from the roots of Lonely Mountain", "Gemstones") manufacturer_repository.save(man_1) man_2 = Manufacturer( "Iron Hills Forge", "The finest Dwarven armours, sealed with Dain Ironfoot's personal mark of approval", "Armour") manufacturer_repository.save(man_2) man_3 = Manufacturer("Murkwood's Ironbark Armoury", "The finest Elven steel and woodland weaponry", "Weapons") manufacturer_repository.save(man_3) man_4 = Manufacturer( "Nasty Bitza Kit", "Stabbas, choppas, cuttas! Nocked togevva by da Goblins ov Misty Mountain.", "Weapons") manufacturer_repository.save(man_4)
def update_manufacturer(id): name = request.form['name'] contact = request.form['contact'] manufacturer = Manufacturer(name, contact, id) manufacturer_repository.update(manufacturer) return redirect('/manufacturers')
def create_manufacturer(): name = request.form['name'] contact = request.form['contact'] manufacturer = Manufacturer(name, contact) manufacturer_repository.save(manufacturer) return redirect('/manufacturers')