def get(self): item_list = self.get_items_from_cart() store_sum = {} if item_list: for items, cost in item_list: logging.error(len(items)) if items: quantity = int(round(cost / items[0].price)) for item in items: if item.store not in store_sum: store_sum[item.store] = 0 store_sum[item.store] += int(round(item.price * quantity)) min_sum = -1 for store, m_sum in store_sum.items(): if min_sum == -1: min_sum = m_sum else: min_sum = min(min_sum, m_sum) store_list = list(caching.get_stores()) categories = list(caching.get_categories()) subcategories = list(caching.get_subcategories()) self.render('show_cart.html', {'subcategories':subcategories, 'categories':categories, 'item_list':item_list, 'store_sum':store_sum, 'store_list':store_list, 'min_sum':min_sum, 'is_home':1})
def get(self): item_name = self.request.get('name') item = caching.get_one_item(item_name) first_item = None dates = {} if not item or len(item) == 0: item = None else: first_item = item[0] for i in item: dates[i._id] = i.added_date.strftime('%d-%m-%y %H:%M:%S') logging.error(item) categories = list(caching.get_categories()) subcategories = list(caching.get_subcategories()) item_cart = self.session.get('items') store_list = list(caching.get_stores()) self.render("item_viewer.html", { 'item_name': item_name, 'items': item, 'item': first_item, 'categories': categories, 'subcategories': subcategories, 'store_list': store_list, 'item_cart': item_cart, 'dates': dates, 'is_home': 1 })
def get(self, category_id, subcategory_id, current_page): user_name = "None" if self.user_info: my_user = self.user user_name = my_user.auth_ids[0] current_store = self.request.get('store') if current_store is None or current_store == "": if memcache.get('current_store' + user_name): current_store = memcache.get('current_store' + user_name) else: if user_name != "None": current_store = caching.get_store_with_id( caching.get_user(user_name, update=True).store_id) else: current_store = caching.get_store_with_id(0) memcache.set('current_store' + user_name, current_store) else: current_store = caching.get_store_with_id(int(current_store)) memcache.set('current_store' + user_name, current_store) items = caching.get_items_with_subcategory(subcategory_id) total_items_size = len(items) start_from = int(current_page) * items_per_page items = items[start_from:min(len(items), start_from + items_per_page)] categories = list(caching.get_categories()) subcategories = list(caching.get_subcategories()) item_cart = self.session.get('items') item_list = self.get_items_from_cart() store_sum = {} if item_list: for items_, cost in item_list: logging.error(len(items_)) if items_: quantity = int(round(cost / items_[0].price)) for item in items_: if item.store not in store_sum: store_sum[item.store] = 0 store_sum[item.store] += int( round(item.price * quantity)) store_list = list(caching.get_stores()) store_total = self.session.get('store_total') dates = {} for i in items: dates[i._id] = i.added_date.strftime('%d-%m-%y %H:%M:%S') self.render( "main.html", { 'current_page': int(current_page), 'subcategories': subcategories, 'pagination_count': pagination_count, 'items_per_page': items_per_page, 'current_store': current_store, 'total_items_size': total_items_size, 'items': items, 'dates': dates, 'items_size': len(items) - 1, 'categories': categories, 'item_cart': item_cart, 'cat_num': int(category_id), 'subcat_num': int(subcategory_id), 'store_total': store_total, 'store_sum': store_sum, 'store_list': store_list, 'item_list': item_list, 'shop_list_data': self.session.get('shop_list_data'), })