Skip to content

Commit

Permalink
Merge pull request #4581 from bjester/covid-free
Browse files Browse the repository at this point in the history
Remove pinned covid channel collection
  • Loading branch information
marcellamaki authored Jun 3, 2024
2 parents b10e013 + 7d91bad commit 07dde98
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,68 +19,6 @@
@click="clearFilters"
/>
</div>
<div v-else>
<VLayout row wrap>
<VFlex
v-for="collection in collections"
:key="`public-collection-${collection.id}`"
xs12
class="py-2"
>
<VCard
tabindex="0"
class="pt-2"
data-test="collection"
@click="setCollection(collection.id)"
@keyup.enter="setCollection(collection.id)"
>
<VLayout>
<div class="px-2 text-xs-center">
<Icon style="font-size: 75px;">
local_hospital
</Icon>
</div>
<VCardTitle primary-title class="pb-2 pt-2">

<!-- TODO: add 'notranslate' class once we figure out how to handle collections
that have multiple channel languages inside -->
<h3 class="headline mb-0">
{{ collection.name }}
</h3>
<p class="body-1 grey--text">
{{ $tr('channelCount', { count: collection.count }) }}
</p>
<p v-if="collection.description">
{{ collection.description }}
</p>
</VCardTitle>
</VLayout>
<VCardActions>
<VSpacer />
<IconButton
icon="copy"
:text="$tr('copyToken')"
@click.stop="displayToken = collection.token"
/>
</VCardActions>
</VCard>
</VFlex>
</VLayout>

<KModal
v-if="displayToken"
:title="$tr('copyTitle')"
:text="$tr('copyTokenInstructions')"
:cancelText="$tr('close')"
@cancel="displayToken = null"
>
<div class="mb-3">
{{ $tr('copyTokenInstructions') }}
</div>
<CopyToken :token="displayToken" />
</KModal>

</div>
</VContainer>

</template>
Expand All @@ -90,10 +28,6 @@
import flatten from 'lodash/flatten'; // Tests fail with native Array.flat() method
import { catalogFilterMixin } from './mixins';
import { constantsTranslationMixin } from 'shared/mixins';
import IconButton from 'shared/views/IconButton';
import CopyToken from 'shared/views/CopyToken';
const publicCollections = window.publicCollections || [];
/*
Returns the expected format for filters
Expand All @@ -108,16 +42,7 @@
export default {
name: 'CatalogFilterBar',
components: {
IconButton,
CopyToken,
},
mixins: [constantsTranslationMixin, catalogFilterMixin],
data() {
return {
displayToken: null,
};
},
computed: {
currentFilters() {
return flatten([
Expand Down Expand Up @@ -150,24 +75,10 @@
createFilter(this.coach, this.$tr('coachContent'), this.resetCoach),
createFilter(this.assessments, this.$tr('assessments'), this.resetAssessments),
createFilter(this.subtitles, this.$tr('subtitles'), this.resetSubtitles),
createFilter(this.collection, this.getCollectionName(), this.resetCollection),
]).filter(Boolean);
},
collections() {
return publicCollections;
},
},
methods: {
getCollectionName() {
const collection = this.collections.find(c => c.id === this.collection);
return collection && collection.name;
},
setCollection(collectionId) {
this.collection = collectionId;
},
resetCollection() {
this.setCollection(null);
},
resetKeywords() {
this.keywords = '';
},
Expand Down Expand Up @@ -200,12 +111,6 @@
subtitles: 'Subtitles',
starred: 'Starred',
clearAll: 'Clear all',
channelCount: '{count, plural,\n =1 {# channel}\n other {# channels}}',
copyToken: 'Copy collection token',
copyTitle: 'Copy collection token',
copyTokenInstructions:
'Paste this token into Kolibri to import the channels contained in this collection',
close: 'Close',
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@ describe('catalogFilterBar', () => {
wrapper = makeWrapper();
});

describe('public collections', () => {
it('should list collections if no filters are selected', () => {
expect(wrapper.find('[data-test="collection"]').exists()).toBe(true);
});
it('should filter by collection if one on click', () => {
wrapper.find('[data-test="collection"]').trigger('click');
expect(wrapper.vm.collection).toBe(collection.id);
});
});

describe('removing filters', () => {
beforeEach(() => {
Object.entries(query).forEach(([key, val]) => {
Expand Down Expand Up @@ -75,15 +65,6 @@ describe('catalogFilterBar', () => {
expect(wrapper.vm.$route.query.languages).toBeTruthy();
expect(wrapper.vm.$route.query.keywords).toBeTruthy();
});
it('removing collection filter should remove it from the query', () => {
wrapper.vm.resetCollection();
expect(wrapper.vm.$route.query.collection).toBeUndefined();

// Make sure other queries weren't affected
expect(wrapper.vm.$route.query.coach).toBeTruthy();
expect(wrapper.vm.$route.query.languages).toBeTruthy();
expect(wrapper.vm.$route.query.keywords).toBeTruthy();
});
it('removing list-based filter should only remove that item from the query', () => {
wrapper.vm.removeLanguage('en');
expect(wrapper.vm.$route.query.languages).toBe('es');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
var publicLanguages = JSON.parse({{ public_languages | safe }});
var publicLicenses = JSON.parse({{ public_licenses | safe }});
var publicKinds = JSON.parse({{ public_kinds | safe }});
var publicCollections = JSON.parse({{ public_collections | safe }});
</script>
{% render_bundle 'channel_list' 'js' %}

Expand Down
18 changes: 0 additions & 18 deletions contentcuration/contentcuration/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,6 @@ def channel_list(request):
kinds = list(public_kind_query)
cache.set(PUBLIC_CHANNELS_CACHE_KEYS["kinds"], json_for_parse_from_data(kinds), None)

# Get public channel sets
collections = cache.get(PUBLIC_CHANNELS_CACHE_KEYS["collections"])
if collections is None:
public_channelset_query = ChannelSet.objects.filter(public=True).annotate(
count=SQCountDistinct(
Channel.objects.filter(
secret_tokens=OuterRef("secret_token"),
public=True,
main_tree__published=True,
deleted=False,
).values_list("id", flat=True),
field="id",
)
)
cache.set(PUBLIC_CHANNELS_CACHE_KEYS["collections"], json_for_parse_from_serializer(
PublicChannelSetSerializer(public_channelset_query, many=True)), None)

return render(
request,
"channel_list.html",
Expand All @@ -291,7 +274,6 @@ def channel_list(request):
"public_languages": languages,
"public_kinds": kinds,
"public_licenses": licenses,
"public_collections": collections,
},
)

Expand Down

0 comments on commit 07dde98

Please sign in to comment.