Export grist balance to the api

This commit is contained in:
Trever Fischer
2012-03-03 17:58:48 -05:00
parent c2bdc1e87a
commit 11788ecb34
2 changed files with 8 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
from piston.handler import AnonymousBaseHandler
from piston.handler import AnonymousBaseHandler, BaseHandler
from profiles.models import MinecraftProfile, Quote
from minecraft.models import MOTD
from django.http import HttpResponse
@@ -28,3 +28,8 @@ class MOTDHandler(AnonymousBaseHandler):
if len(quote) > 0:
motd += "\n"+'"'+quote[0].text+'"'
return {"motd":motd.split('\n')}
class BalanceHandler(BaseHandler):
def read(self, request):
user = request.user
return {"balance":user.get_profile().currencyaccount.balance}

View File

@@ -7,5 +7,6 @@ motdHandler = Resource(handlers.MOTDHandler)
urlpatterns = patterns('api',
url(r'^validate/(?P<username>.*)$', whitelistHandler),
url(r'^motd/(?P<username>.*)$', motdHandler)
url(r'^motd/(?P<username>.*)$', motdHandler),
url(r'^balance$', Resource(handlers.BalanceHandler))
)