From 8d39ac2a3faf036b0d6c926ef9b844427342a7ef Mon Sep 17 00:00:00 2001 From: seba Date: Fri, 30 Sep 2011 01:24:41 +0200 Subject: [PATCH] Started Plugin infrastructure --- k4ever/api2/handlers.py | 9 +++++---- k4ever/api2/urls.py | 22 ++++++++++------------ k4ever/main/models.py | 9 +++++++++ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/k4ever/api2/handlers.py b/k4ever/api2/handlers.py index 1113168..0bc63d3 100644 --- a/k4ever/api2/handlers.py +++ b/k4ever/api2/handlers.py @@ -40,6 +40,8 @@ class BuyableItemHandler(BaseHandler): return error def create(self, request, itemId=None): + if not request.content_type: + request.data = request.POST if not itemId: return rc.BAD_REQUEST item = None @@ -48,10 +50,9 @@ class BuyableItemHandler(BaseHandler): except Buyable.DoesNotExist: return rc.NOT_FOUND - # parse post data - data = request.POST - deposit = getInt(data, 'deposit', 0) - amount = getInt(data, 'amount', 1) + # parse post data + deposit = getInt(request.data, 'deposit', 0) + amount = getInt(request.data, 'amount', 1) if amount < 1: return rc.BAD_REQUEST if item.hasDeposit() and deposit > 0: diff --git a/k4ever/api2/urls.py b/k4ever/api2/urls.py index 404f9df..52ea539 100644 --- a/k4ever/api2/urls.py +++ b/k4ever/api2/urls.py @@ -10,8 +10,6 @@ class CsrfExemptResource( Resource ): super( CsrfExemptResource, self ).__init__( handler, authentication ) self.csrf_exempt = getattr( self.handler, 'csrf_exempt', True ) - - auth = HttpBasicAuthentication(realm="Freitagsrundenkassensystemapi") ad = {'authentication': auth} @@ -28,17 +26,17 @@ configRes = CsrfExemptResource(handler=ConfigHandler, **ad) urlpatterns = patterns('', - url(r'buyable/item/$', buyableItemRes), - url(r'buyable/item/(?P\d+)/$', buyableItemRes), - url(r'buyable/types/$', buyableTypeRes), + url(r'buyable/item/?$', buyableItemRes), + url(r'buyable/item/(?P\d+)/?$', buyableItemRes), + url(r'buyable/types/?$', buyableTypeRes), - url(r'account/transactions/transact/$', transactionTransactRes), - url(r'account/transfers/transfer/$', transactionTransactRes), - url(r'account/transactions/types/$', transactionTypeRes), - url(r'account/transfers/types/$', transactionTypeRes), - url(r'account/balance/$', accountBalanceRes), + url(r'account/transactions/transact/?$', transactionTransactRes), + url(r'account/transfers/transfer/?$', transactionTransactRes), + url(r'account/transactions/types/?$', transactionTypeRes), + url(r'account/transfers/types/?$', transactionTypeRes), + url(r'account/balance/?$', accountBalanceRes), - url(r'auth/blob/$', authBlobRes), - url(r'config/$', configRes), + url(r'auth/blob/?$', authBlobRes), + url(r'config/?$', configRes), ) diff --git a/k4ever/main/models.py b/k4ever/main/models.py index 9b9fe34..47af53a 100644 --- a/k4ever/main/models.py +++ b/k4ever/main/models.py @@ -18,3 +18,12 @@ def createUserProfile(sender, instance, created, **kwargs): post_save.connect(createUserProfile, sender=User) +class PluginPermission(models.Model): + user = models.ForeignKey(User) + plugin = models.ForeignKey('Plugin') + authBlob = models.TextField() + +class Plugin(models.Model): + pluginUser = models.ForeignKey(User) + uniqueAuthblob = models.BooleanField() +