def doEdit(id):
    brand = Brand()
    a = (request.form.get('name'), id)
    ret = brand.edit(a)
    if ret > 0:
        return redirect('/brand')
    return "Failed"
예제 #2
0
def index():
    cat = Category()
    brd = Brand()
    arr = Product()
    a = arr.getProducts()
    b = brd.getBrands()
    c = cat.getCategories()
    return render_template('home/index.html', arr=a, brr=b, crr=c)
def add():
    brand = Brand()
    id = randint(0, 999999)
    name = request.form.get("name")
    ret = brand.add((id, name))
    if ret > 0:
        return jsonify({"id": id, "name": name})
    return "Failed"
def delall():
    a = request.form.getlist('a')
    brand = Brand()
    b = []
    for i in a:
        b.append((i, ))
    ret = brand.deletes(b)
    return redirect('/brand')
예제 #5
0
def detail(id):
    cat = Category()
    brand = Brand()
    pro = Product()
    a = pro.getProductById(id)
    b = brand.getBrands()
    c = cat.getCategories()
    d = pro.getProductsRelation(id)
    return render_template('home/detail.html', u=a, crr=c, brr=b, arr=d)
예제 #6
0
def brand(id):
    cat = Category()
    brand = Brand()
    pro = Product()
    a = pro.getProductsByBrand(id)
    b = brand.getBrands()
    c = cat.getCategories()
    d = brand.getBrandById(id)
    return render_template('home/brand.html', arr=a, crr=c, brr=b, title=d[1])
예제 #7
0
def setup_brands():

    brand1_name = "Dappel"
    brand1_description = "like Mappel but with a D"
    brand1_warranty_details = "Daylight robbery"
    global brand1
    brand1 = Brand(brand1_name, brand1_description, brand1_warranty_details)
    global brand2
    brand2 = Brand("ShangTsung", "Soul-eater", "Combustable")
    brand_repository.save(brand1)
    brand_repository.save(brand2)
예제 #8
0
    def setUp(self):
        name_1 = "Shang-Tsung"
        description_1 = "description of Shang-tsung"
        warranty_details_1 = "Its all out of warranty baby"

        name_2 = "Who-Why"
        description_2 = "description of Who-Why"
        warranty_details_2 = "We hear everything and thats a guarantee!"

        self.brand_1 = Brand(name_1, description_1, warranty_details_1, None)
        self.brand_2 = Brand(name_2, description_2, warranty_details_2, None)
예제 #9
0
def index(p=1):
    cat = Category()
    brand = Brand()
    pro = Product()
    a = pro.getProductsForHome(p, 8)
    b = brand.getBrands()
    c = cat.getCategories()
    total = pro.homeCount()
    n = ceil(total / 8)
    return render_template('home/index.html',
                           arr=a,
                           crr=c,
                           brr=b,
                           title="Mobile Store",
                           n=n)
예제 #10
0
def search(p=1):
    q = request.args.get('q')
    cat = Category()
    brand = Brand()
    pro = Product()
    a = pro.searchProducts(q, p, 4)
    b = brand.getBrands()
    c = cat.getCategories()
    total = pro.searchCount(q)
    n = ceil(total / 4)
    return render_template('home/search.html',
                           arr=a,
                           crr=c,
                           brr=b,
                           title=q,
                           n=n)
예제 #11
0
    def setUp(self):
        product_name = "Universe 51"
        type_name = "Dumbphone"                         # to create product_type
        product_type = ProductType(
            type_name
            )                          # PRODUCT_TYPE
        brand_name = "Dapple"                           # to create brand
        brand_description = "ScroogeMcDuck"             # to create brand
        brand_warranty_details = "AllOutOfWarranty"     # to create brand
        product_brand = Brand(
            brand_name,
            brand_description,
            brand_warranty_details
            )                           # BRAND
        product_description = "Is a phone and a computor"
        product_distributor_price = 100
        product_sale_price = 400
        product_warranty_length = 365

        self.product1 = Product(
            product_name,
            product_type,
            product_brand,
            product_description,
            product_warranty_length,
            product_distributor_price,
            product_sale_price,
        )
예제 #12
0
def apply_brand_edits(id):

    old_brand = brand_repository.select(id)
    old_id = old_brand.id
    modified_brand = Brand(request.form['newBrandName'],request.form['newBrandDescription'],request.form['newBrandWarranty'],old_id)
    brand_repository.update(modified_brand)

    return redirect("/edit/brand-edit")
예제 #13
0
def select(id):
    sql = "SELECT * FROM brands WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]
    if result is not None:
        the_brand = Brand(result['name'], result['description'],
                          result['warranty_details'], result['id'])
    return the_brand
예제 #14
0
def select_all():
    sql = "SELECT * FROM brands"
    results = run_sql(sql)
    all_brands = []
    for row in results:
        brand = Brand(row['name'], row['description'], row['warranty_details'],
                      row['id'])
        all_brands.append(brand)
    return all_brands
예제 #15
0
파일: brand.py 프로젝트: phuclc/dienthoai
def index():
    # Slice of to pagination

    # List of filter by get args:
    # Example: /admin/brand/?page=1&name_icontains=apple
    data = request.args.to_dict()

    # Type of filter
    engine_filter = {"name__icontains": str}

    # Prepare filter
    criteria = {}
    for k in data:
        if k in engine_filter:
            criteria[k] = engine_filter[k](data[k])

    pagination = Paginate("admin.brand.index", count=len(Brand.objects(**criteria)), per_page=10)
    page = pagination.get_page()
    brands = Brand.objects(**criteria)[(page - 1) * 10 : page * 10]
    return render.template("admin/brand/index.html", brands=brands, pagination=pagination)
예제 #16
0
    def post(self):
        brandJson = request.json['brand']

        brand = Brand(brandJson['name'], brandJson['active'])

        new_brand = {'name': brand.name, 'active': brand.active}

        self.brandDocument.insert_one({
            'name': brand.name,
            'active': brand.active
        })

        return new_brand, 201
예제 #17
0
def cac_hang_dien_thoai():
    brand = Brand.objects()
    brand_name_list = brandname()
    return render_template('hang-dien-thoai.html',
                           brand_name_list=brand_name_list,
                           brand=brand)
예제 #18
0
def adding_new_brand():
    new_brand = Brand(request.form['newBrandName'],request.form['newBrandDescription'],request.form['newBrandWarranty'])
    brand_repository.save(new_brand)
    
    return redirect("/edit/brand-edit")
def brandchart():
    brand = Brand()
    return render_template("chart/brandchart.html", a=brand.statisticBrand())
예제 #20
0
def add():
    cat = Category()
    br = Brand()
    return render_template('/product/add.html', brr = br.getBrands(), crr = cat.getCategories())
예제 #21
0
 def test_delete_exist_user_should_be_done(self):
     brand = BrandFactory.create()
     resp = self.post('/admin/brand/' + str(brand.uid) + '/delete',{})
     expect(len(Brand.objects(uid=brand.uid))).to_equal(0)
def index():
    brand = Brand()
    brr = brand.getBrands()
    return render_template('brand/index.html', brr=brr)
예제 #23
0
def edit(id):
    cat = Category()
    brand = Brand()
    pro = Product()
    return render_template('/product/edit.html', crr = cat.getCategories(), brr = brand.getBrands(), u = pro.getProductById(id))
def delete(id):
    brand = Brand()
    ret = brand.delete(id)
    if ret > 0:
        return redirect("/brand")
    return "Failed"
def edit(id):
    brand = Brand()
    i = brand.getBrandById(id)
    return render_template('brand/edit.html', i=i)
from urllib.request import urlopen
import mlab
from models.brand import Brand

mlab.connect()

brand = Brand(
    brand_name='Xiaomi',
    description='',
    logo=
    'https://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Xiaomi_logo.svg/180px-Xiaomi_logo.svg.png',
)
brand.save()
예제 #27
0
#     print({"id":str(item["_id"]), "brand": item["brand"]})

generalInfoObj = GeneralInfo("avatar link", "description model x",
                             ["image1", "image 2"], ["videos 1"], "logo link",
                             "bronx 975")

itemMakeModel = ItemSpecification("make model", "harley")
itemCapacity = ItemSpecification("capacity", "50 litre")
itemSeatHeigh = ItemSpecification("Seat Height", "850mm")
listItemSpecification = [
    itemMakeModel.__dict__, itemCapacity.__dict__, itemSeatHeigh.__dict__
]
itemMaxSpeed = ItemSpecification("max speed", "299km/h")
itemMaxtorque = ItemSpecification("max torque", "500Nm")
listItemSpecsDucati = [itemMaxSpeed.__dict__, itemMaxtorque.__dict__]

motorModelObj = MotorModel("harly-davision",
                           "description harley",
                           "main_image model",
                           specifications=listItemSpecification)
motorModelOtherObj = MotorModel("Ducati",
                                "vip rich max",
                                "Link main image ducati here", ["image 0"],
                                specifications=listItemSpecsDucati)
listModels = [motorModelObj.__dict__, motorModelOtherObj.__dict__]
brandObject = Brand(generalInfoObj.__dict__, listModels)
# documentToInsert = Util.parseObject2Dict(brandObject)

manufacturerCollection.insert_one({"brand": brandObject.__dict__})
print("=========> Done")
예제 #28
0
 def _get_brand_object(brand_name: str) -> Brand:
     return Brand().get_or_create(name=brand_name)[0]