Ejemplo n.º 1
0
def get_article_dict(article, include_content=False):
    props = ['key.id', ('_entity.user.id', 'user_id'), 'user_name',
             ('_entity.icon.name', 'icon'), 'created', 'last_modified',
             'edits', 'views', 'slug', 'title', 'description']
    if include_content:
        props += ['content', 'html']
    return utils.get_dict(article, props)
Ejemplo n.º 2
0
def get_article_dict(article, include_content=False):
    props = ['key.id', ('_entity.user.id', 'user_id'), 'user_name',
             ('_entity.icon.name', 'icon'), 'created', 'last_modified',
             'edits', 'views', 'slug', 'title', 'description', 'published',
             ('_entity.published_by.id', 'published_by'), 'published_date']
    if include_content:
        props += ['content', 'html']
    return utils.get_dict(article, props)
Ejemplo n.º 3
0
def get_revision_dict(revision, include_content=False):
    props = [('key.name', 'number'), ('parent_key.id', 'article_id'),
             ('_entity.previous.name', 'previous'),
             ('_entity.next.name', 'next'), ('_entity.user.id', 'user_id'),
             'user_name', ('_entity.icon.name', 'icon'), 'created', 'title',
             'description', 'message']
    if include_content:
        props += ['content', 'html']
    return utils.get_dict(revision, props)
Ejemplo n.º 4
0
def get_user_dict(user, include_private_values=False):
    props = ['key.id', 'display_name', 'created', 'status']
    if include_private_values:
        props += ['email']
    user_dict = utils.get_dict(user, props)

    for action in user.actions:
        user_dict['can_%s' % action.replace('-', '_')] = user.can(action)

    return user_dict
Ejemplo n.º 5
0
def get_user_dict(user, include_private_values=False):
    props = ['key.id', 'display_name', 'canonical_name', 'created', 'status',
             ('email_as_md5', 'email_md5')]
    if include_private_values:
        props += ['email']
    user_dict = utils.get_dict(user, props)

    for action in user.actions:
        user_dict['can_%s' % action.replace('-', '_')] = user.can(action)

    return user_dict
Ejemplo n.º 6
0
def get_comment_dict(comment):
    return utils.get_dict(comment, (
        'key.id', ('_entity.user.id', 'user_id'), 'user_name',
        'user_canonical_name', 'user_email_md5', 'created', 'content'))
Ejemplo n.º 7
0
def get_blob_dict(blob, include_data=False):
    props = [('key.name', 'id'), ('_entity.user.id', 'user_id'), 'user_name',
             'created', 'content_type', 'size', 'name']
    if include_data:
        props += [('data_as_base64', 'data')]
    return utils.get_dict(blob, props)