Exemple #1
0
    def encode_builtin(self):
	return {
	    'created': js_datetime(self.created),
	    'message': self.message,
	    'key' : str(self.key()),
	    'source': self.source, # don't bother with a profile lookup
	    'target': self.target, # don't bother with a profile lookup
	}
Exemple #2
0
    def encode_builtin(self, bids=False, items=True, feedback=True, currency_type_map=dict(currency_types())):
	""" Encode this instance using only built-in types.

	"""
	key = self.key()
	bids = self.bids() if bids else ()
	wins = [b for b in bids if b.status == 'awarded']
        bfb = Feedback.get_by_listing(self) if feedback else ()
	user = users.get_current_user()
	private = False
	if bids and user and user_steam_id(user) == self.owner:
	    private = True
        try:
            currency_type = currency_type_map[self.bid_currency_type]
        except (KeyError, ):
            currency_type = None
	return {
	    'id' : key.id(),
	    'key': str(key),
	    'owner' : PlayerProfile.get_by_user(self.owner).encode_builtin(subscription=False),
	    'created' : js_datetime(self.created),
	    'expires' : js_datetime(self.expires),
	    'description' : self.description,
	    'bid_count' : self.bid_count,
	    'min_bid' : self.min_bid,
	    'items' : [i.encode_builtin() for i in self.items()] if items else (),
	    'status' : self.status,
	    'status_reason' : self.status_reason,
	    'bids' : [b.encode_builtin(listing=False, private=private) for b in bids],
	    'feedback' : [fb.encode_builtin() for fb in bfb],
	    'featured' : self.featured,
	    'bid_currency_use' : self.bid_currency_use,
	    'bid_currency_start' : self.bid_currency_start,
	    'bid_currency_type' : currency_type,
            'bid_currency_top' : self.bid_currency_top,
	}
Exemple #3
0
    def encode_builtin(self, listing=True, private=False):
	lfb = Feedback.get_by_source(self, self.listing, self.listing.owner)
	if not private:
	    user = users.get_current_user()
	    if user and user_steam_id(user) == self.owner:
		private = True
	return {
	    'owner' : self.owner_profile().encode_builtin(),
	    'created' : js_datetime(self.created),
	    'message_public' : self.message_public,
	    'message_private' : self.message_private if private else None,
	    'status' : self.status,
	    'items' : [i.encode_builtin() for i in self.items()],
	    'listing' : self.listing.encode_builtin(bids=False, items=False) if listing else None,
	    'key' : str(self.key()),
	    'feedback': lfb.encode_builtin() if lfb else None,
            'currency_val' : self.currency_val
	    }
Exemple #4
0
    def encode_builtin(self):
        bid = listing = None
        try:
            bid = str(self.bid.key())
        except:
            pass
        try:
            listing = str(self.listing.key())
        except:
            pass
	return {
	    'bid' : bid,
	    'comment' : self.comment,
	    'created' : js_datetime(self.created),
	    'listing' : listing,
	    'rating' : self.rating,
	    'source' : self.source,
	    'target' : self.target,
	}