コード例 #1
0
def api_delete_pageview(page_id):
    check_admin()
    pageview = Pageviews.get(page_id)
    if pageview is None:
        raise APIResourceNotFoundError('Pageview')
    pageview.delete()
    return dict(id=page_id)
コード例 #2
0
def pageviews(page_id):
    pageview = Pageviews.get(page_id)
    if pageview is None:
        raise notfound()
    pageview.html_content = markdown2.markdown(pageview.page_value)
    #comments = Comment.find_by('where blog_id=? order by created_at desc limit 1000', blog_id)
    return dict(pageview=pageview, user=ctx.request.user)
コード例 #3
0
def api_create_pageview():
    check_admin()
    i = ctx.request.input(page_name='', element='', byway='', page_value='')
    page_name = i.page_name.strip()
    element = i.element.strip()
    byway = i.byway.strip()
    page_value = i.page_value.strip()
    if not page_name:
        raise APIValueError('page_name', 'name cannot be empty.')
    if not element:
        raise APIValueError('element', 'summary cannot be empty.')
    if not byway:
        raise APIValueError('byway', 'content cannot be empty.')
    if not page_value:
        raise APIValueError('page_value', 'content cannot be empty.')
    user = ctx.request.user
    pageview = Pageviews(user_id=user.id, user_name=user.name, page_name=page_name, element=element, byway=byway, page_value=page_value)
    pageview.insert()
    return pageview
コード例 #4
0
def api_update_pageview(page_id):
    check_admin()
    i = ctx.request.input(page_name='', element='', byway='', page_value='')
    page_name = i.page_name.strip()
    element = i.element.strip()
    byway = i.byway.strip()
    page_value = i.page_value.strip()
    if not page_name:
        raise APIValueError('page_name', 'name cannot be empty.')
    if not element:
        raise APIValueError('element', 'summary cannot be empty.')
    if not byway:
        raise APIValueError('byway', 'content cannot be empty.')
    if not page_value:
        raise APIValueError('page_value', 'content cannot be empty.')
    pageview = Pageviews.get(page_id)
    if pageview is None:
        raise APIResourceNotFoundError('Page')
    pageview.page_name = page_name
    pageview.element = element
    pageview.byway = byway
    pageview.page_value = page_value
    pageview.update()
    return pageview
コード例 #5
0
def api_get_pageview(page_id):
    pageview = Pageviews.get(page_id)
    if pageview:
        return pageview
    raise APIResourceNotFoundError('Pageview')
コード例 #6
0
def manage_pagevies_edit(page_id):
    pageview = Pageviews.get(page_id)
    if pageview is None:
        raise notfound()
    return dict(id=pageview.id, page_name=pageview.page_name, element=pageview.element, byway=pageview.byway, page_value=pageview.page_value, action='/api/pageviews/%s' % page_id, redirect='/manage/pageviews', user=ctx.request.user)
コード例 #7
0
def _get_pageviews_by_page():
    total = Pageviews.count_all()
    page = Page(total, _get_page_index())
    pageviews = Pageviews.find_by('order by created_at desc limit ?,?', page.offset, page.limit)
    return pageviews, page