Esempio n. 1
0
def get_user_view_channels(request):
    view_channels = request.user.view_only_channels.exclude(deleted=True)\
                    .select_related('main_tree').prefetch_related('editors')\
                    .defer('trash_tree', 'clipboard_tree', 'staging_tree', 'chef_tree', 'previous_tree', 'viewers')

    channel_serializer = AltChannelListSerializer(view_channels, many=True)
    return Response(channel_serializer.data)
Esempio n. 2
0
def get_user_public_channels(request):
    channels = Channel.objects.filter(public=True)\
                    .exclude(deleted=True)\
                    .select_related('main_tree').prefetch_related('editors')\
                    .defer('trash_tree', 'clipboard_tree', 'staging_tree', 'chef_tree', 'previous_tree', 'viewers')
    channel_serializer = AltChannelListSerializer(channels, many=True)
    return Response(channel_serializer.data)
Esempio n. 3
0
def accept_channel_invite(request):
    invitation = Invitation.objects.get(pk=request.data.get('invitation_id'))
    channel = invitation.channel
    channel.is_view_only = invitation.share_mode == VIEW_ACCESS
    channel_serializer = AltChannelListSerializer(channel)
    add_editor_to_channel(invitation)

    return Response(channel_serializer.data)
Esempio n. 4
0
def accept_channel_invite(request):
    if request.method != 'POST':
        return HttpResponseBadRequest("Only POST requests are allowed on this endpoint.")

    data = json.loads(request.body)
    invitation = Invitation.objects.get(pk=data['invitation_id'])
    channel = invitation.channel
    channel.is_view_only = invitation.share_mode == VIEW_ACCESS
    channel_serializer = AltChannelListSerializer(channel)
    add_editor_to_channel(invitation)

    return HttpResponse(JSONRenderer().render(channel_serializer.data))
Esempio n. 5
0
def get_user_edit_channels(request):
    edit_channels = request.user.editable_channels.exclude(deleted=True)\
                    .select_related('main_tree').prefetch_related('editors')\
                    .defer('trash_tree', 'clipboard_tree', 'staging_tree', 'chef_tree', 'previous_tree', 'viewers')
    return HttpResponse(JSONRenderer().render(
        AltChannelListSerializer(edit_channels, many=True).data))
Esempio n. 6
0
def get_user_public_channels(request):
    channels = ChannelCacher.get_public_channels(defer_nonmain_trees=True)
    channel_serializer = AltChannelListSerializer(channels, many=True)
    return Response(channel_serializer.data)