def review_sort(business_id, field=u'date', order=u'-1'): global review_pagination _business = business.select(business_id) _review = review.sort(business_id, u"*", field, int(order)) _review = {no: val for no, val in enumerate(_review)} review_pagination = Pagination(u'review', review_perpage, len(_review), \ review_pages) return render_template(u'review_board.html', business=_business, \ review=_review, pagination=review_pagination)
def insert(self, business_id, hours): from datamodel.business import business if len(business.select(business_id)) < 1: business.insert(business_id, {}) for key, val in hours.items(): self.query_sql = \ u'INSERT INTO `hours`(`business_id`, `hours`) ' \ + 'VALUES("%s", "%s")' % (business_id, key + "|" + val) super().execute()
def view_merchant(business_id): return render_template( u'merchant.html', attribute=attribute.select(business_id), business=business.select(business_id), category=category.select(business_id), hours=hours.select(business_id), photo=photo.select(business_id), )
def insert(self, business_id, category): from datamodel.business import business if len(business.select(business_id)) < 1: business.insert(business_id, {}) for key, val in category.items(): self.query_sql = \ u'INSERT INTO `category`(`business_id`, `category`) ' \ + 'VALUES("%s", "%s")' \ % (business_id, val) super().execute()
def information(business_id): _attribute_ = attribute.select(business_id) _business = business.select(business_id) _category = category.select(business_id) _checkin = checkin.select(business_id) _hours = hours.select(business_id) _review = review.select(business_id, u'*') pagination = Pagination(u'review', 4, len(_review), 5) return render_template(u'information.html', business=_business, \ category=_category, hours=_hours, review=_review, pagination=pagination)
def insert(self, business_id, attribute): from datamodel.business import business if len(business.select(business_id)) < 1: business.insert(business_id, {}) for key, val in attribute.items(): self.query_sql = \ u'INSERT INTO `attribute`(`business_id`, `name`, `value`) ' \ + 'VALUES("%s", %s, %s)' \ % (business_id, self.quote_sql(key), self.val2sql(val)) super().execute()
def insert(self, business_id, photo): from datamodel.business import business if len(business.select(business_id)) < 1: business.insert(business_id, {}) for key, val in photo.items(): k = [u'id'] v = [self.quote_sql(key)] for attr in self.dm_attr: if attr in val and attr != u'id': k.append(attr) v.append(self.quote_sql(val[attr])) self.query_sql = u'INSERT INTO `photo`(%s) ' % (u','.join(k)) \ + 'VALUES(%s)' % (u','.join(v)) super().execute()
def insert(self, business_id, user_id, tip): from datamodel.business import business if len(business.select(business_id)) < 1: business.insert(business_id, {}) from datamodel.user import user if len(user.select(user_id)) < 1: user.insert(user_id, {}) for key, val in tip.items(): k = [] v = [] for attr in self.dm_attr: k.append(attr) v.append(self.quote_sql(val[attr])) self.query_sql = u'INSERT INTO `tip`(%s) ' % (u','.join(k)) \ + 'VALUES(%s)' % (u','.join(v)) super().execute()