def sign_in(self, request, data, *args, **kwargs):
     serializer = IsAuthenticatedSerializer(data=data)
     serializer.is_valid(raise_exception=True)
     band_id = kwargs.get("band_id")
     user = self.check_chat_perms(serializer, band_id)
     if user is not None:
         request.channel_session["user"] = user.id
         group = Group(self.CHAT_GROUP_TEMPLATE % band_id)
         group.add(request.reply_channel)
         messages = Message.objects.select_related("author").filter(band_id=band_id)[: self.MESSAGES_COUNT][::-1]
         self.route_send(request.reply_channel, MessagesSerializer({"messages": messages}).data)
     else:
         raise PermissionDenied
 def sign_in(self, request, data, *args, **kwargs):
     serializer = IsAuthenticatedSerializer(data=data)
     serializer.is_valid(raise_exception=True)
     composition_id = kwargs.get("composition_id")
     user = self.check_composition_perms(serializer, composition_id)
     if user is not None:
         request.channel_session["user"] = user.id
         Group(self.COMPOSITION_GROUP_TEMPLATE % composition_id).add(request.reply_channel)
         composition = Composition.objects.get(id=composition_id)
         diff_version = composition.diff_versions.last()
         if diff_version is None:
             composition_version = composition.versions.order_by("create_datetime").last()
             diff_version = DiffCompositionVersion.copy_from_version(composition_version)
         self.route_send(request.reply_channel, DiffCompositionVersionSerializer(diff_version).data)
     else:
         raise PermissionDenied