| 985 | return qs |
| 986 | |
| 987 | def get_serializer_context(self): |
| 988 | context = super().get_serializer_context() |
| 989 | include_streams = ( |
| 990 | self.request.query_params.get("include_streams", "false") == "true" |
| 991 | ) |
| 992 | context["include_streams"] = include_streams |
| 993 | # source_stream is only needed by the channel edit form. For get_ids |
| 994 | # and summary the channelstream_set prefetch is skipped entirely, so |
| 995 | # source_stream cannot be computed without hitting the DB per channel. |
| 996 | # For list and write/retrieve paths the prefetch is present, so we |
| 997 | # can populate it from memory without extra queries. |
| 998 | context["include_source_stream"] = action not in ( |
| 999 | "get_ids", "summary" |
| 1000 | ) if (action := getattr(self, "action", None)) else False |
| 1001 | return context |
| 1002 | |
| 1003 | @extend_schema( |
| 1004 | methods=["PATCH"], |