Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export function useLatestCommunityLibrarySubmission({ channelId, admin = false }

function fetchLatestSubmission() {
// Submissions are ordered by most recent first in the backend
return Resource.fetchCollection({ channel: channelId, max_results: 1 }).then(response => {
return Resource.fetchCollection({
channel: channelId,
max_results: 1,
ordering: '-date_created',
}).then(response => {
if (response.results.length > 0) {
return response.results[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from contentcuration.viewsets.base import RESTCreateModelMixin
from contentcuration.viewsets.base import RESTDestroyModelMixin
from contentcuration.viewsets.base import RESTUpdateModelMixin
from contentcuration.viewsets.base import ValuesViewsetOrderingFilter
from contentcuration.viewsets.common import UserFilteredPrimaryKeyRelatedField
from contentcuration.viewsets.sync.utils import (
generate_added_to_community_library_event,
Expand Down Expand Up @@ -244,12 +245,15 @@ class CommunityLibrarySubmissionViewSetMixin:
"resolved_by_name": get_resolved_by_name,
"channel_name": lambda item: item.get("channel__name"),
}
queryset = CommunityLibrarySubmission.objects.all().order_by("-date_updated")
filter_backends = [DjangoFilterBackend, SearchFilter]
queryset = CommunityLibrarySubmission.objects.all()
filter_backends = [DjangoFilterBackend, SearchFilter, ValuesViewsetOrderingFilter]
filterset_class = CommunityLibrarySubmissionFilterSet
search_fields = ["channel__name"]
pagination_class = CommunityLibrarySubmissionPagination

ordering_fields = ["date_updated", "date_created"]
ordering = "-date_updated"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Good design — setting ordering = "-date_updated" as the viewset default preserves backward compatibility for all other callers while enabling the frontend to override with -date_created when needed.


def consolidate(self, items, queryset):
countries = {}
for (submission_id, country_code,) in Country.objects.filter(
Expand Down
Loading