示例#1
0
    def post(self):
	try:
	    vs = self.body_json()
	    source, bid, listing, rating, text = \
		    vs['source'], vs['bid'], vs['listing'], int(vs['rating']), vs['text'][0:400]
	    user = users.get_current_user()
	    bid = Bid.get(bid)
	    listing = Listing.get(listing)
	    fb = Feedback.get_by_source(bid, listing, user_steam_id(user))
	    if rating > 100 or rating < -100:
		raise TypeError('Invalid feedback rating')
	    if source == 'lister':
		## lister is adding feedback for bidder; target is bid owner
		target = bid.owner
	    elif source == 'bidder':
		## bidder is adding feedback for lister; target is listing owner
		target = listing.owner
	    else:
		raise TypeError('Invalid feedback source')
	    source = user_steam_id(user)
            if fb:
		#raise TypeError('Feedback exists')
                fb.rating = rating
                fb.comment = text
                fb.put()
            else:
                fb = Feedback.build(bid, listing, source, target, rating, text)
	except (Exception, ), exc:
	    self.error(500)
	    raise
	    exc = exc.message if hasattr(exc, 'message') else str(exc)
	    result = {'msg':'error', 'description':exc}
    def post(self):
        """ Called by the task queue API when a this task is ready to
	    run.  The tasks are created by the Listing model.
	"""
        listing = Listing.get(self.request.get("listing_key"))
        summary = {"listing": {"id": listing.key().id()}}
        send(body=json_dumps(summary))
示例#3
0
    def post(self):
	next = None
	bookmark = self.request.get('subscription_key')

	q = Subscription.all().order('__key__').filter('status =', Subscription.verified)
	if bookmark:
	    q.filter('__key__ >', db.Key(bookmark))
	subscription = q.get()

	## 0. done if there are no more subscriptions
	if not subscription:
	    return

	## 1. otherwise, process this subscription via its settings:
	listing_key = self.request.get('listing_key')
	listing = Listing.get(listing_key)
	settings = subscription.settings
	if settings.email and settings.notify_listing_defs:
	    items = [i.defindex for i in listing.items()]
	    for defindex in items:
		if defindex in settings.notify_listing_defs:
		    ## no name, that would mean yet another datastore read...
		    send(settings.email, listing.url())
		    break

	## 2.  add another item to the queue:
	queue_tool.notify_listing(subscription_key=subscription.key(),
				  listing_key=listing_key)
示例#4
0
    def post(self):
	try:
	    key = self.request.get('key')
	    warn('expire listing: %s', key)
	    listing = Listing.get(key)
	    if listing:
		listing.expire('Expired by system.')
	except (Exception, ), exc:
	    error('expire listing exception: %s', exc)
	    self.response.out.write('ERROR')
示例#5
0
	def inner_search():
	    listings, qs = [], self.qs
	    for di in qs.get('di', [])[0:self.max_defs]:
		try:
		    di = int(di)
		except (ValueError, ):
		    continue
		q = ListingItem.all(keys_only=True).filter('status = ', 'active')
		q.filter('defindex =', di)
		listings += Listing.get(i.parent() for i in q.fetch(self.limit))
	    listings = dict((lst.key(), lst) for lst in listings).values() ## remove dupes
	    listings.sort(key=lambda o:o.expires) ## TODO:  verify this is desired
	    if encoded:
		listings = [lst.encode_builtin() for lst in listings]
	    return listings, '', False