Update the public ChannelMetadata viewset to support token filter#5715
Conversation
|
|
||
| if channels.exists(): | ||
| channel_ids = list(channels.values_list("id", flat=True)) | ||
| return models.ChannelMetadata.objects.filter(id__in=channel_ids), None |
There was a problem hiding this comment.
Hey @taoerman! It seems there has been a misunderstanding here, for this spec:
We'll need to create a
get_queryset_from_tokenmethod. This method will receive a token and will build the channel queryset, fetching the Channels with the token matching one of its secret tokens, andChannelVersions whose secret token matches the token. Then, we will need to annotate this queryset to fill the missing fields that the Viewset exposes or filters, or that have a different name in the contentcuration models. The idea is that all transformations that we do with the current queryset can be made within the context of this new queryset.
We should get the data from the contentcuration models, because the channels we will import using tokens are private, not public, this is why we can't retrieve them from the public models like this return models.ChannelMetadata.objects.filter(id__in=channel_ids), we will need to get the data from the private models, and annotate/adapt the fields that are different/missing on the public models. As a result, we should get an annotated queryset that complies with the api that we are exposing in the viewset values field
Summary
Implements token-based filtering for the ChannelMetadataViewSet (v2 public API). Previously, token-based channel lookup was only available through the v1 endpoint (get_public_channel_lookup). This change brings that functionality to the v2 API with support for both Channel tokens and ChannelVersion tokens.
References
Fixed #5462
Reviewer guidance
Run Unit Tests