Beispiel #1
0
    def post(self):
	try:
	    user = users.get_current_user()
	    settings = self.body_json()
	    PlayerSettings.put_merged(user, settings)
	except (Exception, ), exc:
	    self.error(500)
	    error('save settings: %s', exc)
	    exc = exc.message if hasattr(exc, 'message') else str(exc)
	    result = {'msg':'error', 'description':exc}
Beispiel #2
0
    def post(self):
	try:
	    key = self.request.get('bid')
	    warn('notify win: %s', key)
	    bid = Bid.get(key)
	    profile = bid.owner_profile()
	    settings = PlayerSettings.get_by_id64(bid.owner).encode_builtin(complete=True)
	    if settings['email'] and settings['notify-wins']:
		name = getattr(profile, 'personaname', bid.owner)
		send(name, settings['email'], bid.owner, bid.listing.url())
	except (Exception, ), exc:
	    warn('notify win exception: %s', exc)
	    self.response.out.write('WARN')
Beispiel #3
0
    def build(cls, owner, status='initial'):
	## lazy to avoid circular imports:
	from tf2auctions.models.profile import PlayerProfile
	from tf2auctions.models.settings import PlayerSettings

	profile = PlayerProfile.build(owner)
	settings = PlayerSettings.build(owner)
	obj = cls.get_or_insert(owner, profile=profile, settings=settings, status=status)
	if not obj.is_saved():
	    obj.put()
	else:
	    obj.status = status
	    obj.put()
	return obj
Beispiel #4
0
    def post(self):
	try:
	    key = self.request.get('bid')
	    update = self.request.get('update')
	    #warn('notify bid: %s, %s', key, update)
	    bid = Bid.get(key)
	    listing = bid.listing
	    profile = listing.owner_profile()
	    settings = PlayerSettings.get_by_id64(listing.owner).encode_builtin(complete=True)
	    if settings['email'] and settings['notify-bids']:
		name = getattr(profile, 'personaname', listing.owner)
		send(name, settings['email'], listing.owner, listing.url())

	except (Exception, ), exc:
	    warn('notify bid exception: %s', exc)
	    self.response.out.write('WARN')
Beispiel #5
0
    def encode_builtin(self, settings=False, complete=False, subscription=True):
	""" Encode this instance using only built-in types. """
	id64 = self.id64()
	res = {
	    'id64' : id64,
	    'rating' : self.get_rating(),
	    'custom_name' : self.custom_name,
	}
	for key in self.dynamic_properties():
	    res[key] = getattr(self, key)
	if settings:
	    psettings = PlayerSettings.get_by_id64(id64)
	    psettings = psettings.encode_builtin(complete) if psettings else {}
	else:
	    psettings = {}
	res['settings'] = psettings
	if subscription:
	    psub = Subscription.get_by_id64(id64)
	    psub = psub.encode_builtin() if psub else {}
	else:
	    psub = {}
	res['subscription'] = psub
	res['message_count'] = PlayerMessage.count_for_user(id64)
	return res