diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ChannelList.vue b/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ChannelList.vue index 76dc9e1f8c..d348fe805e 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ChannelList.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/views/ImportFromChannels/ChannelList.vue @@ -112,6 +112,7 @@ [this.channelFilter]: true, page: this.$route.query.page || 1, exclude: this.currentChannelId, + ordering: this.channelFilter === 'public' ? 'name' : '-modified', }).then(page => { this.pageCount = page.total_pages; this.channels = page.results; diff --git a/contentcuration/contentcuration/frontend/channelList/views/Channel/ChannelList.vue b/contentcuration/contentcuration/frontend/channelList/views/Channel/ChannelList.vue index 68f506cba2..b1d8327b87 100644 --- a/contentcuration/contentcuration/frontend/channelList/views/Channel/ChannelList.vue +++ b/contentcuration/contentcuration/frontend/channelList/views/Channel/ChannelList.vue @@ -48,7 +48,7 @@ import { mapGetters, mapActions } from 'vuex'; import orderBy from 'lodash/orderBy'; - import { RouteNames, CHANNEL_PAGE_SIZE } from '../../constants'; + import { RouteNames } from '../../constants'; import ChannelItem from './ChannelItem'; import LoadingText from 'shared/views/LoadingText'; import { ChannelListTypes } from 'shared/constants'; @@ -98,9 +98,6 @@ isEditable() { return this.listType === ChannelListTypes.EDITABLE; }, - isStarred() { - return this.listType === ChannelListTypes.STARRED; - }, }, watch: { listType(newListType) { @@ -129,17 +126,6 @@ }, loadData(listType) { this.loading = true; - let parameters = { - listType, - sortBy: '-modified', - }; - - // Don't paginate bookmarked channel list for more - // rapid updating when channels are starred/unstarred - if (!this.isStarred) { - parameters.page = Number(this.$route.query.page || 1); - parameters.page_size = CHANNEL_PAGE_SIZE; - } this.loadChannelList({ listType }).then(() => { this.loading = false; diff --git a/contentcuration/contentcuration/viewsets/channel.py b/contentcuration/contentcuration/viewsets/channel.py index 517e66f0fe..aad4638e3c 100644 --- a/contentcuration/contentcuration/viewsets/channel.py +++ b/contentcuration/contentcuration/viewsets/channel.py @@ -400,6 +400,8 @@ class ChannelViewSet(ValuesViewset): serializer_class = ChannelSerializer pagination_class = ChannelListPagination filterset_class = ChannelFilter + ordering_fields = ["modified", "name"] + ordering = "-modified" field_map = channel_field_map values = base_channel_values + ("edit", "view", "unpublished_changes") @@ -412,6 +414,15 @@ def get_queryset(self): queryset = super(ChannelViewSet, self).get_queryset() user_id = not self.request.user.is_anonymous and self.request.user.id user_queryset = User.objects.filter(id=user_id) + # Add the last modified node modified value as the channel last modified + channel_main_tree_nodes = ContentNode.objects.filter( + tree_id=OuterRef("main_tree__tree_id") + ) + queryset = queryset.annotate( + modified=Subquery( + channel_main_tree_nodes.values("modified").order_by("-modified")[:1] + ) + ) return queryset.annotate( edit=Exists(user_queryset.filter(editable_channels=OuterRef("id"))), @@ -423,12 +434,7 @@ def annotate_queryset(self, queryset): channel_main_tree_nodes = ContentNode.objects.filter( tree_id=OuterRef("main_tree__tree_id") ) - # Add the last modified node modified value as the channel last modified - queryset = queryset.annotate( - modified=Subquery( - channel_main_tree_nodes.values("modified").order_by("-modified")[:1] - ) - ) + # Add the unique count of distinct non-topic node content_ids non_topic_content_ids = ( channel_main_tree_nodes.exclude(kind_id=content_kinds.TOPIC) @@ -561,6 +567,8 @@ class CatalogViewSet(ReadOnlyValuesViewset): serializer_class = ChannelSerializer pagination_class = CatalogListPagination filterset_class = BaseChannelFilter + ordering_fields = [] + ordering = ("-priority", "name") permission_classes = [AllowAny]