Started Plugin infrastructure

This commit is contained in:
seba 2011-09-30 01:24:41 +02:00
parent dc585b47be
commit 8d39ac2a3f
3 changed files with 24 additions and 16 deletions

View File

@ -40,6 +40,8 @@ class BuyableItemHandler(BaseHandler):
return error return error
def create(self, request, itemId=None): def create(self, request, itemId=None):
if not request.content_type:
request.data = request.POST
if not itemId: if not itemId:
return rc.BAD_REQUEST return rc.BAD_REQUEST
item = None item = None
@ -49,9 +51,8 @@ class BuyableItemHandler(BaseHandler):
return rc.NOT_FOUND return rc.NOT_FOUND
# parse post data # parse post data
data = request.POST deposit = getInt(request.data, 'deposit', 0)
deposit = getInt(data, 'deposit', 0) amount = getInt(request.data, 'amount', 1)
amount = getInt(data, 'amount', 1)
if amount < 1: if amount < 1:
return rc.BAD_REQUEST return rc.BAD_REQUEST
if item.hasDeposit() and deposit > 0: if item.hasDeposit() and deposit > 0:

View File

@ -10,8 +10,6 @@ class CsrfExemptResource( Resource ):
super( CsrfExemptResource, self ).__init__( handler, authentication ) super( CsrfExemptResource, self ).__init__( handler, authentication )
self.csrf_exempt = getattr( self.handler, 'csrf_exempt', True ) self.csrf_exempt = getattr( self.handler, 'csrf_exempt', True )
auth = HttpBasicAuthentication(realm="Freitagsrundenkassensystemapi") auth = HttpBasicAuthentication(realm="Freitagsrundenkassensystemapi")
ad = {'authentication': auth} ad = {'authentication': auth}
@ -28,17 +26,17 @@ configRes = CsrfExemptResource(handler=ConfigHandler, **ad)
urlpatterns = patterns('', urlpatterns = patterns('',
url(r'buyable/item/$', buyableItemRes), url(r'buyable/item/?$', buyableItemRes),
url(r'buyable/item/(?P<itemId>\d+)/$', buyableItemRes), url(r'buyable/item/(?P<itemId>\d+)/?$', buyableItemRes),
url(r'buyable/types/$', buyableTypeRes), url(r'buyable/types/?$', buyableTypeRes),
url(r'account/transactions/transact/$', transactionTransactRes), url(r'account/transactions/transact/?$', transactionTransactRes),
url(r'account/transfers/transfer/$', transactionTransactRes), url(r'account/transfers/transfer/?$', transactionTransactRes),
url(r'account/transactions/types/$', transactionTypeRes), url(r'account/transactions/types/?$', transactionTypeRes),
url(r'account/transfers/types/$', transactionTypeRes), url(r'account/transfers/types/?$', transactionTypeRes),
url(r'account/balance/$', accountBalanceRes), url(r'account/balance/?$', accountBalanceRes),
url(r'auth/blob/$', authBlobRes), url(r'auth/blob/?$', authBlobRes),
url(r'config/$', configRes), url(r'config/?$', configRes),
) )

View File

@ -18,3 +18,12 @@ def createUserProfile(sender, instance, created, **kwargs):
post_save.connect(createUserProfile, sender=User) 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()