def productDetail(product_id, slug=None): app.logger.info("Product Detail Page: " + product_id) productMasterDetails = getProductMasterInfo(product_id) if not slug: slug = productMasterDetails['surl'] return redirect('/pdp/' + product_id + '/' + slug) if slug != productMasterDetails['surl']: slug = productMasterDetails['surl'] return redirect('/pdp/' + product_id + '/' + slug) category = productMasterDetails['category'] categoryDetails = mongoCategoryDetails.find_one({'type': category}) allKeyWordsIcon = categoryDetails['allKeyWordsIcon'] pdp_fileds = categoryDetails['pdp_fileds'] productDetails = getProductDetail(product_id) title = "Bazaarfunda: Check the user experience of " + productMasterDetails[ 'product_name'][:30] + ".. and compare Prices" return render_template("product_detail.html", productMasterDetails=productMasterDetails, productDetails=productDetails, allKeyWordsIcon=allKeyWordsIcon, pdp_fileds=pdp_fileds, cartDetails=g.cartDetails, category=category, all_cat_details=g.all_cat_details, title=title, allCategories=g.allCategories, recoCategory=g.recoCategory)
def compare(): cartDetails = g.cartDetails category = None categoryDetails = None app.logger.info('comparing') app.logger.info([cart['master']['product_id'] for cart in cartDetails]) for items in cartDetails: if items['master']: category = items['master']['category'] break if category: categoryDetails = mongoCategoryDetails.find_one({'type': category}) if len(cartDetails) != 0: title = "Bazaarfunda: Compare " for items in cartDetails: title = title + items['master']['product_name'] + " " else: title = "Bazaarfunda: Add Products to compare" return render_template("compare.html", cartDetails=g.cartDetails, categoryDetails=categoryDetails, category=category, all_cat_details=g.all_cat_details, title=title, recoCategory=g.recoCategory, allCategories=g.allCategories)
def catTypeSubmit(): if request.method == 'PUT': respData = request.get_json(silent=True) # respData =json.loads(request.json) for data in respData: category = data catJSON = respData[category] print catJSON catJSON = json.loads(catJSON) try: catJSON['type'] print "type present" try: listingJSON = mongoCategoryDetails.find_one({ '_id': catJSON['_id'], 'type': catJSON['type'] }) mongoCategoryDetails.save(catJSON) return "Saved new document" except: mongoCategoryDetails.save(insert) return "new document" except: mongoCategoryDetails.delete_one({'_id': catJSON['_id']}) return "Type not present, so delete this entry of category" return "Submitted Successfully"
def productDetail(product_id, slug=None): app.logger.info("Product Detail Page: " + product_id) productMasterDetails = getProductMasterInfo(product_id) if not slug: slug = productMasterDetails['surl'] return redirect('/pdp/' + product_id + '/'+slug) if slug != productMasterDetails['surl']: slug = productMasterDetails['surl'] return redirect('/pdp/' + product_id + '/'+slug) category = productMasterDetails['category'] categoryDetails = mongoCategoryDetails.find_one({'type':category}) allKeyWordsIcon = categoryDetails['allKeyWordsIcon'] pdp_fileds = categoryDetails['pdp_fileds'] productDetails = getProductDetail(product_id) title = "Bazaarfunda: Check the user experience of " + productMasterDetails['product_name'][:30] + ".. and compare Prices" return render_template("product_detail.html", productMasterDetails = productMasterDetails, productDetails=productDetails, allKeyWordsIcon=allKeyWordsIcon, pdp_fileds=pdp_fileds, cartDetails=g.cartDetails, category=category, all_cat_details = g.all_cat_details, title = title, allCategories=g.allCategories, recoCategory=g.recoCategory)
def catType(): try: category= getArgAsList(request, 'category')[0] except: category = 'new' listing = mongoCategoryDetails.find() categoryList = [li['type'] for li in listing] catTypeCursor = mongoCategoryDetails.find() catType = [cat for cat in catTypeCursor] if category != 'new': listingJSON = mongoCategoryDetails.find_one({'type':category}) else: listingJSON = "" listingJSON = json.dumps(listingJSON) return render_template('admin/catType.html', catType=catType, categoryList=categoryList, listingJSON=listingJSON,category=category)
def compare(): cartDetails=g.cartDetails category = None categoryDetails = None app.logger.info('comparing') app.logger.info([cart['master']['product_id'] for cart in cartDetails]) for items in cartDetails: if items['master']: category = items['master']['category'] break if category: categoryDetails = mongoCategoryDetails.find_one({'type':category}) if len(cartDetails) != 0: title = "Bazaarfunda: Compare " for items in cartDetails: title = title + items['master']['product_name'] + " " else: title = "Bazaarfunda: Add Products to compare" return render_template("compare.html", cartDetails=g.cartDetails, categoryDetails=categoryDetails, category=category, all_cat_details = g.all_cat_details, title = title, recoCategory=g.recoCategory, allCategories=g.allCategories)
def catType(): try: category = getArgAsList(request, 'category')[0] except: category = 'new' listing = mongoCategoryDetails.find() categoryList = [li['type'] for li in listing] catTypeCursor = mongoCategoryDetails.find() catType = [cat for cat in catTypeCursor] if category != 'new': listingJSON = mongoCategoryDetails.find_one({'type': category}) else: listingJSON = "" listingJSON = json.dumps(listingJSON) return render_template('admin/catType.html', catType=catType, categoryList=categoryList, listingJSON=listingJSON, category=category)
def catTypeSubmit(): if request.method == 'PUT': respData = request.get_json(silent=True) # respData =json.loads(request.json) for data in respData: category = data catJSON = respData[category] print catJSON catJSON = json.loads(catJSON) try: catJSON['type'] print "type present" try: listingJSON = mongoCategoryDetails.find_one({'_id':catJSON['_id'], 'type': catJSON['type']}) mongoCategoryDetails.save(catJSON) return "Saved new document" except: mongoCategoryDetails.save(insert) return "new document" except: mongoCategoryDetails.delete_one({'_id':catJSON['_id']}) return "Type not present, so delete this entry of category" return "Submitted Successfully"