MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / patch

Method patch

apps/channels/api_views.py:3043–3066  ·  view source on GitHub ↗

Enable or disable a channel for a specific group

(self, request, profile_id, channel_id)

Source from the content-addressed store, hash-verified

3041 permission_classes = [IsOwnerOfObject]
3042
3043 def patch(self, request, profile_id, channel_id):
3044 """Enable or disable a channel for a specific group"""
3045 channel_profile = get_object_or_404(ChannelProfile, id=profile_id)
3046 channel = get_object_or_404(Channel, id=channel_id)
3047 try:
3048 membership = ChannelProfileMembership.objects.get(
3049 channel_profile=channel_profile, channel=channel
3050 )
3051 except ChannelProfileMembership.DoesNotExist:
3052 # Create the membership if it does not exist (for custom channels)
3053 membership = ChannelProfileMembership.objects.create(
3054 channel_profile=channel_profile,
3055 channel=channel,
3056 enabled=False # Default to False, will be updated below
3057 )
3058
3059 serializer = ChannelProfileMembershipSerializer(
3060 membership, data=request.data, partial=True
3061 )
3062 if serializer.is_valid():
3063 serializer.save()
3064 return Response(serializer.data, status=status.HTTP_200_OK)
3065
3066 return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
3067
3068
3069class BulkUpdateChannelMembershipAPIView(APIView):

Calls 4

getMethod · 0.45
createMethod · 0.45
saveMethod · 0.45