Make pagination respect any filters or searches or sort keys. Searches and filters will
query the comment service to get their results rather than filtering threads that have already been loaded.
This commit is contained in:
@@ -22,7 +22,7 @@ import django_comment_client.utils as utils
|
||||
import comment_client as cc
|
||||
import xml.sax.saxutils as saxutils
|
||||
|
||||
THREADS_PER_PAGE = 2
|
||||
THREADS_PER_PAGE = 5
|
||||
INLINE_THREADS_PER_PAGE = 5
|
||||
PAGES_NEARBY_DELTA = 2
|
||||
escapedict = {'"': '"'}
|
||||
@@ -78,8 +78,8 @@ def get_threads(request, course_id, discussion_id=None, per_page=THREADS_PER_PAG
|
||||
user.save()
|
||||
|
||||
query_params = merge_dict(default_query_params,
|
||||
strip_none(extract(request.GET, ['page', 'sort_key', 'sort_order', 'text', 'tags'])))
|
||||
|
||||
strip_none(extract(request.GET, ['page', 'sort_key', 'sort_order', 'text', 'tags', 'commentable_ids'])))
|
||||
|
||||
threads, page, num_pages = cc.Thread.search(query_params)
|
||||
|
||||
query_params['page'] = page
|
||||
@@ -143,6 +143,8 @@ def forum_form_discussion(request, course_id):
|
||||
return utils.JsonResponse({
|
||||
'discussion_data': threads, # TODO: Standardize on 'discussion_data' vs 'threads'
|
||||
'annotated_content_info': annotated_content_info,
|
||||
'num_pages': query_params['num_pages'],
|
||||
'page': query_params['page'],
|
||||
})
|
||||
else:
|
||||
#recent_active_threads = cc.search_recent_active_threads(
|
||||
|
||||
@@ -11,7 +11,7 @@ cache = cache.get_cache('default')
|
||||
def cached_has_permission(user, permission, course_id=None):
|
||||
"""
|
||||
Call has_permission if it's not cached. A change in a user's role or
|
||||
a role's permissions will only become effective after CACHE_LIFESPAN seconds.
|
||||
a role's permissions will only become effective after CACHE_LIFESPAN seconds.
|
||||
"""
|
||||
CACHE_LIFESPAN = 60
|
||||
key = "permission_%d_%s_%s" % (user.id, str(course_id), permission)
|
||||
@@ -54,8 +54,8 @@ def check_conditions_permissions(user, permissions, course_id, **kwargs):
|
||||
"""
|
||||
Accepts a list of permissions and proceed if any of the permission is valid.
|
||||
Note that ["can_view", "can_edit"] will proceed if the user has either
|
||||
"can_view" or "can_edit" permission. To use AND operator in between, wrap them in
|
||||
a list.
|
||||
"can_view" or "can_edit" permission. To use AND operator in between, wrap them in
|
||||
a list.
|
||||
"""
|
||||
|
||||
def test(user, per, operator="or"):
|
||||
@@ -87,7 +87,7 @@ VIEW_PERMISSIONS = {
|
||||
'vote_for_thread' : [['vote', 'is_open']],
|
||||
'undo_vote_for_thread': [['unvote', 'is_open']],
|
||||
'follow_thread' : ['follow_thread'],
|
||||
'follow_commentable': ['follow_commentable'],
|
||||
'follow_commentable': ['follow_commentable'],
|
||||
'follow_user' : ['follow_user'],
|
||||
'unfollow_thread' : ['unfollow_thread'],
|
||||
'unfollow_commentable': ['unfollow_commentable'],
|
||||
|
||||
Reference in New Issue
Block a user