def get_bookings_for_bookable(entity_id): bookable = BookableModel.get_by_id(entity_id) bookings = bookable.get_bookings_that_end_after(datetime.today()) bookings = [{ 'start': date.to_str(e.start), 'end': date.to_str(e.end), 'quantity': e.quantity } for e in bookings] return json.dumps(bookings)
def to_dict_field(self, key): val = getattr(self, key) tp = type(val) if val is not None and isinstance( getattr(self.__class__, key), db.ReferenceProperty ): val = val.key().id() elif date_helper.is_date_type(tp): val = date_helper.to_str(val) else: val = unicode(val) return val
def get_avg_for_range(prices, start, end): if prices['special']\ and len(prices['special']) > 0\ and start < end: prices_per_days = [] # will contain prices for each day for date in date_helper.date_range(start, end): # for every date, retrieve price values vals = get_price_values_for_date(prices, date) logging.info('\twith vals: ' + str(vals)) logging.info('for date: ' + str(date_helper.to_str(date))) prices_per_days += [vals] return get_avg_prices_for_days(prices_per_days) return prices['values']