コード例 #1
0
def getgroup(uid):
    group = user.getgroup(uid)
    q = db().view("entry/groups",
        startkey=[group+u"\ufff0"],
        endkey=[group],
        include_docs=True,
        descending=True
    )

    for x in q:
        doc = x["doc"]
        username = user.getname(doc["uid"])
        deletedby = doc.get("deletedby")
        deletedby = deletedby and user.getname(deletedby)
        user.getname(doc["uid"])
        debtors = doc["debtors"]
        debtors = dict((user.getname(x),y) for x,y in debtors)
        
        creditor = user.getname(doc["creditor"])

        yield {
            "id": doc["_id"],
            "amount": doc["amount"],
            "creditor": creditor,
            "date": dateutils.fromtuple(doc["date"]),
            "description": doc["description"],
            "debtors": debtors,
            "username": username,
            "deletedby": deletedby,
        }
コード例 #2
0
ファイル: document.py プロジェクト: RusKursusGruppen/beercalc
    def create(data, filepath=None):
        version = data["version"]

        if version >= 1 and version <= 2:
            inventory = Inventory.create(data["inventory"])
            accounts = Accounts.create(data["accounts"])
            usage = Usage.create(data["usage"], inventory, accounts)
            comment = data["comment"]
            cash_in_hand = Account.create(data["cash_in_hand"])
            date = data["date"]
            if date is not None:
                date = dateutils.fromtuple(date)

            if version >= 2:
                id_ = data["id"]
                title = data["title"]
            else:
                id_ = uuid4().hex
                title = None
        else:
            raise VersionError("Unknown document version: " % (repr(version),))

        return Document(
            usage = usage,
            accounts = accounts,
            inventory = inventory,
            date = date,
            comment = comment,
            filepath = filepath,
            version = version,
            cash_in_hand = cash_in_hand,
            title = title,
            id_ = id_
        )
コード例 #3
0
 def create(data):
     return Purchase(
         name = data["name"],
         price = data["price"],
         quantity = data["quantity"],
         date=dateutils.fromtuple(data["date"]),
         id = data["id"]
     )
コード例 #4
0
    def load_session(self):
        doc = self.get_doc(self.id)

        if doc is None:
            raise InvalidCookieException()

        # Expire time on session
        if (dateutils.now() - dateutils.fromtuple(doc["date"])).total_seconds() > self.expires:
            raise InvalidCookieException()
        
        doc["date"] = dateutils.totuple(self.date)
        self.doc = doc
コード例 #5
0
    def load_session(self):
        doc = self.get_doc(self.id)

        if doc is None:
            raise InvalidCookieException()

        # Expire time on session
        if (dateutils.now() - dateutils.fromtuple(
                doc["date"])).total_seconds() > self.expires:
            raise InvalidCookieException()

        doc["date"] = dateutils.totuple(self.date)
        self.doc = doc
コード例 #6
0
ファイル: account.py プロジェクト: RusKursusGruppen/beercalc
 def create(data):
     return Transaction(data["id"], data["description"], dateutils.fromtuple(data["date"]), data["amount"])