more documentation to come

This commit is contained in:
seba 2011-10-06 15:30:02 +02:00
parent 6ee2e91338
commit 7850b322c5
2 changed files with 24 additions and 1 deletions

View File

@ -6,6 +6,7 @@ from decimal import Decimal
# Create your models here. # Create your models here.
class BuyableType(models.Model): class BuyableType(models.Model):
""" Type/Category for a buyable object """
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
def __unicode__(self): def __unicode__(self):
@ -13,6 +14,7 @@ class BuyableType(models.Model):
class Buyable(models.Model): class Buyable(models.Model):
""" Represents a buyable item. """
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=8, decimal_places=2) price = models.DecimalField(max_digits=8, decimal_places=2)
image = models.ImageField(upload_to='img/buyable/') image = models.ImageField(upload_to='img/buyable/')
@ -23,6 +25,7 @@ class Buyable(models.Model):
def hasDeposit(self): def hasDeposit(self):
""" Returns True if the item has deposit. """
return self.deposit > Decimal(0) return self.deposit > Decimal(0)
def createPurchase(self, isDeposit=False): def createPurchase(self, isDeposit=False):
@ -44,6 +47,11 @@ class Buyable(models.Model):
return item return item
class Order(models.Model): class Order(models.Model):
""" Represents an order by the user.
"""
An Order object is referenced by all :class:`Purchases <Purchase>`
user = models.ForeignKey(User) user = models.ForeignKey(User)
price = models.DecimalField(max_digits=8, decimal_places=2) price = models.DecimalField(max_digits=8, decimal_places=2)
dateTime = models.DateTimeField() dateTime = models.DateTimeField()
@ -85,6 +93,7 @@ class Order(models.Model):
class Purchase(models.Model): class Purchase(models.Model):
""" Represents a :class:``"""
order = models.ForeignKey(Order) order = models.ForeignKey(Order)
price = models.DecimalField(max_digits=8, decimal_places=2) price = models.DecimalField(max_digits=8, decimal_places=2)
isDeposit = models.BooleanField() isDeposit = models.BooleanField()

View File

@ -4,15 +4,29 @@ API
- how to access the read/write/put/create functions - how to access the read/write/put/create functions
- what this api does and what not - what this api does and what not
K4ever has a REST-like API. This means every URL represents an object which has
four functions: `read`, `create`, `update` and `delete`. These functions are mapped
to the `HTTP`-Methods `GET`, `POST`, `PUT` and `DELETE`. Most of the functionality
uses only `GET` and `POST`, so everything is accessible via `wget`.
The API enables you to list available items, buy them and transtact money to your
accout. It also has a *plugin*-concept. Plugins can be allowed by other user
Authentication can be done either per HTTP Basic Auth or for AJAX-Requests per
cookie. The
k4evers API k4evers API
Authentication Plugins
-------------- --------------
- how does authentication work - how does authentication work
- what is the plugin authentication - what is the plugin authentication
- when does a plugin need an user? - when does a plugin need an user?
- how to change user names - how to change user names
URLs URLs
---- ----
For more information about a specific method you can click on the url/method to get For more information about a specific method you can click on the url/method to get