diff --git a/contentcuration/contentcuration/frontend/administration/vuex/channelAdmin/actions.js b/contentcuration/contentcuration/frontend/administration/vuex/channelAdmin/actions.js index 23b9f3400a..c58cd6350b 100644 --- a/contentcuration/contentcuration/frontend/administration/vuex/channelAdmin/actions.js +++ b/contentcuration/contentcuration/frontend/administration/vuex/channelAdmin/actions.js @@ -6,10 +6,13 @@ import { Channel } from 'shared/data/resources'; export function loadChannels({ commit }, params) { const extendedParams = { ...params, - deleted: Boolean(params.deleted) && params.deleted.toString() === 'true', page_size: params.page_size || 25, }; + if (params.has_community_library_submission === undefined) { + extendedParams.deleted = Boolean(params.deleted) && params.deleted.toString() === 'true'; + } + const paramsSerializer = { indexes: null, // Handle arrays by providing the same query param multiple times }; diff --git a/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue b/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue index 6ca82f5d2d..7b602dbd46 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/views/TreeView/TreeViewBase.vue @@ -254,29 +254,14 @@ @syncing="syncInProgress" /> - - {{ $tr('deletePrompt') }} - - + - - {{ canEdit ? $tr('deletePrompt') : $tr('removePrompt') }} - + @delete="handleDelete" + @close="deleteDialog = false" + /> + + +
+ +
+ +
+ + + + + + + + diff --git a/contentcuration/contentcuration/tests/viewsets/test_channel.py b/contentcuration/contentcuration/tests/viewsets/test_channel.py index 591f7505d5..814acdabb6 100644 --- a/contentcuration/contentcuration/tests/viewsets/test_channel.py +++ b/contentcuration/contentcuration/tests/viewsets/test_channel.py @@ -819,25 +819,43 @@ def test_admin_channel_filter__community_library_live(self): [submission1.channel.id], ) - def test_admin_channel_filter__has_community_library_submission(self): - self.client.force_authenticate(user=self.admin_user) - + def test_has_community_library_submission_endpoint(self): + """Test the on-demand has_community_library_submission endpoint""" + user = testdata.user() + channel_with_submission = testdata.channel() + channel_with_submission.editors.add(user) + channel_with_submission.version = 1 + channel_with_submission.save() submission = testdata.community_library_submission() + submission.channel = channel_with_submission + submission.author = user + submission.channel_version = channel_with_submission.version + submission.save() + + channel_without_submission = testdata.channel() + channel_without_submission.editors.add(user) - testdata.channel() # Another channel without submission + self.client.force_authenticate(user=user) response = self.client.get( - reverse_with_query( - "admin-channels-list", - query={"has_community_library_submission": True}, + reverse( + "channel-has-community-library-submission", + kwargs={"pk": channel_with_submission.id}, ), format="json", ) self.assertEqual(response.status_code, 200, response.content) - self.assertCountEqual( - [ch["id"] for ch in response.data], - [submission.channel.id], + self.assertTrue(response.data["has_community_library_submission"]) + + response = self.client.get( + reverse( + "channel-has-community-library-submission", + kwargs={"pk": channel_without_submission.id}, + ), + format="json", ) + self.assertEqual(response.status_code, 200, response.content) + self.assertFalse(response.data["has_community_library_submission"]) def test_create_channel(self): user = testdata.user() diff --git a/contentcuration/contentcuration/viewsets/channel.py b/contentcuration/contentcuration/viewsets/channel.py index 78b76bfa70..7d28c6387f 100644 --- a/contentcuration/contentcuration/viewsets/channel.py +++ b/contentcuration/contentcuration/viewsets/channel.py @@ -899,6 +899,19 @@ def get_published_data(self, request, pk=None) -> Response: return Response(channel.published_data) + @action( + detail=True, + methods=["get"], + url_path="has_community_library_submission", + url_name="has-community-library-submission", + ) + def has_community_library_submission(self, request, pk=None) -> Response: + channel = self.get_object() + has_submission = CommunityLibrarySubmission.objects.filter( + channel_id=channel.id + ).exists() + return Response({"has_community_library_submission": has_submission}) + def _channel_exists(self, channel_id) -> bool: """ Check if a channel exists. @@ -1050,6 +1063,7 @@ def annotate_queryset(self, queryset): class AdminChannelFilter(BaseChannelFilter): + latest_community_library_submission_status = CharFilter( method="filter_latest_community_library_submission_status" )