Esempio n. 1
0
__author__ = 'dowling'
from model.db import connection
from mongokit import Document
from model.user import User
import datetime


class Event(Document):
    use_dot_notation = True
    use_autorefs = True
    structure = {
        'user': User,
        'timestamp': datetime.datetime,
        'transactions': {
            unicode: int
        },
    }


connection.register([Event])
Esempio n. 2
0
__author__ = 'dowling'

from mongokit import Document
from model.db import connection


class User(Document):
    structure = {
        'username': unicode,
        'device': unicode
    }
    use_autorefs = True
    use_dot_notation = True

connection.register([User])
Esempio n. 3
0
        if quantity < 0:  # take out
            if old_quantity is None:
                old_quantity = 0
                ln.warn("Attempting to take item %s out of fridge, but previous value was %s" % (item, old_quantity))

        else:  # put in
            if old_quantity is None:
                old_quantity = 0


                ln.warn("Adding new item %s (quantity %s)" % (item, old_quantity))
            ln.debug("Putting %s of %s into fridge" % (quantity, item))
        print old_quantity
        self.content[item] = old_quantity + quantity

connection.register([Fridge])

fridge_collection = db.fridges
#fridge = fridge_collection.Fridge()
#fridge.save()
#fridge.reload()

def get_fridge():
    fs = list(fridge_collection.Fridge.find())
    for f in fs:
        if f.content:
            return f
    if not fs:
        f = fridge_collection.Fridge()
        f.save()
        f.reload()