Esempio n. 1
0
def processing_panel(request, page, url_user):
    """
    Show to the user what media is still in conversion/processing...
    and what failed, and why!
    """
    user = LocalUser.query.filter_by(
        username=request.matchdict['user']).first()
    # TODO: XXX: Should this be a decorator?
    #
    # Make sure we have permission to access this user's panel.  Only
    # admins and this user herself should be able to do so.
    if not (user.id == request.user.id
            or request.user.has_privilege(u'admin')):
        # No?  Simply redirect to this user's homepage.
        return redirect(request,
                        'mediagoblin.user_pages.user_home',
                        user=user.username)
    # Get media entries which are in-processing
    entries = (MediaEntry.query.filter_by(actor=user.id).order_by(
        MediaEntry.created.desc()))

    try:
        state = request.matchdict['state']
        # no exception was thrown, filter entries by state
        entries = entries.filter_by(state=state)
    except KeyError:
        # show all entries
        pass

    pagination = Pagination(page, entries)
    pagination.per_page = 30
    entries_on_a_page = pagination()

    # Render to response
    return render_to_response(request,
                              'mediagoblin/user_pages/processing_panel.html', {
                                  'user': user,
                                  'entries': entries_on_a_page,
                                  'pagination': pagination
                              })
Esempio n. 2
0
def blog_post_listing(request, page, url_user=None):
    """
    Page, listing all the blog posts of a particular blog.
    """
    blog_slug = request.matchdict['blog_slug']
    blog = get_blog_by_slug(request, blog_slug, author=url_user.id)
    if not blog:
        return render_404(request)

    all_blog_posts = blog.get_all_blog_posts(u'processed').order_by(MediaEntry.created.desc())
    pagination = Pagination(page, all_blog_posts)
    pagination.per_page = 8
    blog_posts_on_a_page = pagination()

    return render_to_response(
        request,
        'mediagoblin/blog/blog_post_listing.html',
        {'blog_posts': blog_posts_on_a_page,
         'pagination': pagination,
         'blog_owner': url_user,
         'blog':blog
        })
Esempio n. 3
0
def blog_dashboard(request, page, url_user=None):
    """
    Dashboard for a blog, only accessible to
    the owner of the blog.
    """
    blog_slug = request.matchdict.get('blog_slug', None)
    blogs = request.db.Blog.query.filter_by(author=url_user.id)
    config = pluginapi.get_config('mediagoblin.media_types.blog')
    max_blog_count = config['max_blog_count']
    if request.user and (request.user.id == url_user.id or request.user.has_privilege(u'admin')):
        if blog_slug:
            blog = get_blog_by_slug(request, blog_slug)
            if not blog:
                return render_404(request)
            else:
                blog_posts_list = blog.get_all_blog_posts().order_by(MediaEntry.created.desc())
                pagination = Pagination(page, blog_posts_list)
                pagination.per_page = 15
                blog_posts_on_a_page = pagination()
                if may_edit_blogpost(request, blog):
                    return render_to_response(
                        request,
                        'mediagoblin/blog/blog_admin_dashboard.html',
                        {'blog_posts_list': blog_posts_on_a_page,
                        'blog_slug':blog_slug,
                        'blog':blog,
                        'user':url_user,
                        'pagination':pagination
                        })
    if not request.user or request.user.id != url_user.id or not blog_slug:
        blogs = blogs.all()
        return render_to_response(
        request,
        'mediagoblin/blog/list_of_blogs.html',
        {
        'blogs':blogs,
        'user':url_user,
        'max_blog_count':max_blog_count
        })
Esempio n. 4
0
def blog_post_listing(request, page, url_user=None):
    """
    Page, listing all the blog posts of a particular blog.
    """
    blog_slug = request.matchdict['blog_slug']
    blog = get_blog_by_slug(request, blog_slug, author=url_user.id)
    if not blog:
        return render_404(request)

    all_blog_posts = blog.get_all_blog_posts(u'processed').order_by(
        MediaEntry.created.desc())
    pagination = Pagination(page, all_blog_posts)
    pagination.per_page = 8
    blog_posts_on_a_page = pagination()

    return render_to_response(
        request, 'mediagoblin/blog/blog_post_listing.html', {
            'blog_posts': blog_posts_on_a_page,
            'pagination': pagination,
            'blog_owner': url_user,
            'blog': blog
        })
Esempio n. 5
0
def blog_dashboard(request, page, url_user=None):
    """
    Dashboard for a blog, only accessible to
    the owner of the blog.
    """
    blog_slug = request.matchdict.get('blog_slug', None)
    blogs = request.db.Blog.query.filter_by(author=url_user.id)
    config = pluginapi.get_config('mediagoblin.media_types.blog')
    max_blog_count = config['max_blog_count']
    if request.user and (request.user.id == url_user.id
                         or request.user.has_privilege(u'admin')):
        if blog_slug:
            blog = get_blog_by_slug(request, blog_slug)
            if not blog:
                return render_404(request)
            else:
                blog_posts_list = blog.get_all_blog_posts().order_by(
                    MediaEntry.created.desc())
                pagination = Pagination(page, blog_posts_list)
                pagination.per_page = 15
                blog_posts_on_a_page = pagination()
                if may_edit_blogpost(request, blog):
                    return render_to_response(
                        request, 'mediagoblin/blog/blog_admin_dashboard.html',
                        {
                            'blog_posts_list': blog_posts_on_a_page,
                            'blog_slug': blog_slug,
                            'blog': blog,
                            'user': url_user,
                            'pagination': pagination
                        })
    if not request.user or request.user.id != url_user.id or not blog_slug:
        blogs = blogs.all()
        return render_to_response(request,
                                  'mediagoblin/blog/list_of_blogs.html', {
                                      'blogs': blogs,
                                      'user': url_user,
                                      'max_blog_count': max_blog_count
                                  })
Esempio n. 6
0
def processing_panel(request, page, url_user):
    """
    Show to the user what media is still in conversion/processing...
    and what failed, and why!
    """
    user = LocalUser.query.filter_by(username=request.matchdict['user']).first()
    # TODO: XXX: Should this be a decorator?
    #
    # Make sure we have permission to access this user's panel.  Only
    # admins and this user herself should be able to do so.
    if not (user.id == request.user.id or request.user.has_privilege(u'admin')):
        # No?  Simply redirect to this user's homepage.
        return redirect(
            request, 'mediagoblin.user_pages.user_home',
            user=user.username)
    # Get media entries which are in-processing
    entries = (MediaEntry.query.filter_by(actor=user.id)
            .order_by(MediaEntry.created.desc()))

    try:
        state = request.matchdict['state']
        # no exception was thrown, filter entries by state
        entries = entries.filter_by(state=state)
    except KeyError:
        # show all entries
        pass

    pagination = Pagination(page, entries)
    pagination.per_page = 30
    entries_on_a_page = pagination()

    # Render to response
    return render_to_response(
        request,
        'mediagoblin/user_pages/processing_panel.html',
        {'user': user,
         'entries': entries_on_a_page,
         'pagination': pagination})