Thread sort key and direction for discussion api
Discussion API for thread sorting now takes the sort_by parameter for the sort key such as by comment_count or vote_count. Also takes the sort_direction parameter for sorting the thread results.
This commit is contained in:
@@ -54,8 +54,24 @@ class ThreadListGetForm(_PaginationForm):
|
||||
following = NullBooleanField(required=False)
|
||||
view = ChoiceField(
|
||||
choices=[(choice, choice) for choice in ["unread", "unanswered"]],
|
||||
required=False,
|
||||
)
|
||||
order_by = ChoiceField(
|
||||
choices=[(choice, choice) for choice in ["last_activity_at", "comment_count", "vote_count"]],
|
||||
required=False
|
||||
)
|
||||
order_direction = ChoiceField(
|
||||
choices=[(choice, choice) for choice in ["asc", "desc"]],
|
||||
required=False
|
||||
)
|
||||
|
||||
def clean_order_by(self):
|
||||
"""Return a default choice"""
|
||||
return self.cleaned_data.get("order_by") or "last_activity_at"
|
||||
|
||||
def clean_order_direction(self):
|
||||
"""Return a default choice"""
|
||||
return self.cleaned_data.get("order_direction") or "desc"
|
||||
|
||||
def clean_course_id(self):
|
||||
"""Validate course_id"""
|
||||
|
||||
Reference in New Issue
Block a user