示例#1
0
def getUserData(*, userID='', c):
    if userID:
        userOb = c.execute('SELECT * FROM users WHERE id = ?',
                           [userID]).fetchone()
        entityOb = c.execute('SELECT * FROM entities WHERE id = ?',
                             [userID]).fetchone()
        user = readRows('users', {'id': userID})[0]
        entity = readRows('entities', {'id': userID})[0]
        return (user, entity)
    return ('', '')
示例#2
0
def canUserModifyRelationship(userID, relationshipID, c):
    if userID and relationshipID:
        thing = readRows('relationships', {
            'owner': userID,
            'id': relationshipID
        })
        return thing[0] if thing else False
    else:
        return None
示例#3
0
def canUserModifyEntity(userID, entityID, c):
    if userID and entityID:
        thing = readRows('relationships', {
            'owner': userID,
            'property': entityID
        })
        return thing[0] if thing else False
    else:
        return None
示例#4
0
def read(apikey,
         id='*',
         category=None,
         name=None,
         description=None,
         count=10,
         page=1,
         method='and'):
    args = locals()
    result = readRows(__tablename, args)
    return buildResponse(result)
示例#5
0
def read(apikey,
         id='*',
         description=None,
         owner=None,
         _property=None,
         count=None,
         page=None,
         method='and'):
    args = locals()
    result = readRows(__tablename, args)
    return buildResponse(result)
示例#6
0
def claimEntity(userID, entityID, c):
    """Claims an entity for the provided userID, provided its not already claimed"""
    existantRelationships = readRows('relationships', {'property': entityID})
    ownership = [x for x in existantRelationships if indicatesOwnership(x)]
    if ownership:
        return False
    else:
        return addRows('relationships', [{
            'owner': userID,
            'user': userID,
            'property': entityID
        }])