Пример #1
0
def getbalances(uid):
    group = user.getgroup(uid)
    q = db().view("entry/balances",
        startkey=[group],
        endkey=[group+u"\ufff0"],
        group=True,
        reduce=True,
        group_level=2
    )
    
    for x in q:
        yield user.getname(x["key"][1]), x["value"]
Пример #2
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,
        }