Implement pagination feature for blog_post_listing and blog_dashboard pages.
This commit is contained in:
parent
060d15d384
commit
8762609f2a
@ -17,6 +17,7 @@
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
{% extends "mediagoblin/base.html" %}
|
{% extends "mediagoblin/base.html" %}
|
||||||
|
{% from "mediagoblin/utils/pagination.html" import render_pagination %}
|
||||||
|
|
||||||
{% block title -%}
|
{% block title -%}
|
||||||
{{blog.title}} Dashboard — {{ super() }}
|
{{blog.title}} Dashboard — {{ super() }}
|
||||||
@ -50,7 +51,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<h2> Blog Post Entries </h2>
|
<h2> Blog Post Entries </h2>
|
||||||
{% if blog_post_count!=0 %}
|
{% if blog_posts_list.count() %}
|
||||||
<table class="media_panel processing">
|
<table class="media_panel processing">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Title</th>
|
<th>Title</th>
|
||||||
@ -90,6 +91,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% trans %} No blog post yet. {% endtrans %}
|
{% trans %} No blog post yet. {% endtrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{{ render_pagination(request, pagination) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
{% extends "mediagoblin/base.html" %}
|
{% extends "mediagoblin/base.html" %}
|
||||||
|
|
||||||
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
|
{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
|
||||||
|
{% from "mediagoblin/utils/pagination.html" import render_pagination %}
|
||||||
|
|
||||||
{% block title -%}
|
{% block title -%}
|
||||||
{% trans %}{{ blog_owner }} 's Blog{% endtrans %} — {{ super() }}
|
{% trans %}{{ blog_owner }} 's Blog{% endtrans %} — {{ super() }}
|
||||||
@ -45,4 +46,5 @@
|
|||||||
</br>
|
</br>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{{ render_pagination(request, pagination) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -206,33 +206,36 @@ def blogpost_edit(request):
|
|||||||
})
|
})
|
||||||
|
|
||||||
@require_active_login
|
@require_active_login
|
||||||
def blog_dashboard(request):
|
@uses_pagination
|
||||||
|
def blog_dashboard(request, page):
|
||||||
|
|
||||||
url_user = request.matchdict.get('user')
|
url_user = request.matchdict.get('user')
|
||||||
blog_slug = request.matchdict.get('blog_slug', None)
|
blog_slug = request.matchdict.get('blog_slug', None)
|
||||||
_log.info(blog_slug)
|
|
||||||
|
|
||||||
blog = request.db.Blog.query.filter_by(slug=blog_slug).first()
|
blog = request.db.Blog.query.filter_by(slug=blog_slug).first()
|
||||||
|
|
||||||
if not blog:
|
if not blog:
|
||||||
return render_404(request)
|
return render_404(request)
|
||||||
|
|
||||||
blog_posts_list = blog.get_all_posts_of_a_blog(None)
|
blog_posts_list = blog.get_all_posts_of_a_blog().order_by(MediaEntry.created.desc())
|
||||||
blog_post_count = blog_posts_list.count()
|
pagination = Pagination(page, blog_posts_list)
|
||||||
|
pagination.per_page = 15
|
||||||
|
blog_posts_on_a_page = pagination()
|
||||||
|
|
||||||
if may_edit_blogpost(request, blog):
|
if may_edit_blogpost(request, blog):
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
request,
|
request,
|
||||||
'mediagoblin/blog/blog_admin_dashboard.html',
|
'mediagoblin/blog/blog_admin_dashboard.html',
|
||||||
{'blog_posts_list': blog_posts_list,
|
{'blog_posts_list': blog_posts_on_a_page,
|
||||||
'blog_slug':blog_slug,
|
'blog_slug':blog_slug,
|
||||||
'blog':blog,
|
'blog':blog,
|
||||||
'blog_post_count':blog_post_count
|
'pagination':pagination
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
#supposed to list all the blog posts belonging to a particular blog of particular user.
|
#supposed to list all the blog posts belonging to a particular blog of particular user.
|
||||||
def blog_post_listing(request):
|
@uses_pagination
|
||||||
|
def blog_post_listing(request, page):
|
||||||
|
|
||||||
blog_owner = request.matchdict.get('user')
|
blog_owner = request.matchdict.get('user')
|
||||||
blog_slug = request.matchdict.get('blog_slug', None)
|
blog_slug = request.matchdict.get('blog_slug', None)
|
||||||
@ -242,12 +245,16 @@ def blog_post_listing(request):
|
|||||||
if not owner_user or not blog:
|
if not owner_user or not blog:
|
||||||
return render_404(request)
|
return render_404(request)
|
||||||
|
|
||||||
all_blog_posts = blog.get_all_posts_of_a_blog(u'processed')
|
all_blog_posts = blog.get_all_posts_of_a_blog(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(
|
return render_to_response(
|
||||||
request,
|
request,
|
||||||
'mediagoblin/blog/blog_post_listing.html',
|
'mediagoblin/blog/blog_post_listing.html',
|
||||||
{'blog_posts': all_blog_posts,
|
{'blog_posts': blog_posts_on_a_page,
|
||||||
|
'pagination': pagination,
|
||||||
'blog_owner': blog_owner
|
'blog_owner': blog_owner
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user