Top

telemeta.views.new_playlist module

# -*- coding: utf-8 -*-
from telemeta.views.core import *
from telemeta.models import *
import uuid

class NewPlaylistView(object):

    def display(self, request, type="item"):

        self.type=type

        template_name = loader.get_template('search/addplaylist.html')

        idlist = request.POST.getlist('selected_items_list')
        itemlist = []
        if self.type =="item":
            for itemid in idlist:
                itemlist.append(MediaItem.objects.all().get(id=itemid))

        if self.type =="collection":
            for itemid in idlist:
                itemlist.append(MediaCollection.objects.all().get(id=itemid))

        context = RequestContext(request, {
                'selected_items_list': itemlist,
                'existing_playlists': Playlist.objects.all().filter(author=request.user),
                'type':self.type,
                'lastquerypath':request.POST.get('lastquerypath')})
        return HttpResponse(template_name.render(context))

    def addToPlaylist(self, request, type=None):
        self.type=type

        template_name = loader.get_template('search/confirmation_add_playslist.html')

        idlist = request.POST.getlist('item_id')
        selected_playlist_id = request.POST.get('playlist_id')
        selected_playlist = Playlist.objects.all().get(id=selected_playlist_id)

        itemlist = []
        if self.type == "item":
            for itemid in idlist:
                itemlist.append(MediaItem.objects.all().get(id=itemid))

            for item in itemlist:
                new_id = uuid.uuid4()
                PlaylistResource.objects.get_or_create(resource_type='item',resource_id=item.id,playlist=selected_playlist,defaults={'public_id':new_id})
        else:
            for itemid in idlist:
                itemlist.append(MediaCollection.objects.all().get(id=itemid))

            for item in itemlist:
                new_id = uuid.uuid4()
                PlaylistResource.objects.get_or_create(resource_type='collection',resource_id=item.id,playlist=selected_playlist,defaults={'public_id':new_id})

        context = RequestContext(request, {
                'selected_items_list': itemlist,
                'type':self.type,
                'lastquerypath': request.POST.get('lastquerypath')})
        return HttpResponse(template_name.render(context))

Module variables

var ITEM_PUBLIC_ACCESS_CHOICES

var ITEM_TRANSODING_STATUS

var PUBLIC_ACCESS_CHOICES

var SCOPE_CHOICES

var TYPE_CHOICES

var app_name

var code_linesep

var collection_code_regex

var collection_published_code_regex

var collection_unpublished_code_regex

var default_decoding

var default_encoding

var engine

var eol

var ext

var item_code_regex

var item_published_code_regex

var item_unpublished_code_regex

var mime_type

var mods

var private_extra_types

var public_extra_types

var resource_code_regex

var strict_code

Classes

class NewPlaylistView

class NewPlaylistView(object):

    def display(self, request, type="item"):

        self.type=type

        template_name = loader.get_template('search/addplaylist.html')

        idlist = request.POST.getlist('selected_items_list')
        itemlist = []
        if self.type =="item":
            for itemid in idlist:
                itemlist.append(MediaItem.objects.all().get(id=itemid))

        if self.type =="collection":
            for itemid in idlist:
                itemlist.append(MediaCollection.objects.all().get(id=itemid))

        context = RequestContext(request, {
                'selected_items_list': itemlist,
                'existing_playlists': Playlist.objects.all().filter(author=request.user),
                'type':self.type,
                'lastquerypath':request.POST.get('lastquerypath')})
        return HttpResponse(template_name.render(context))

    def addToPlaylist(self, request, type=None):
        self.type=type

        template_name = loader.get_template('search/confirmation_add_playslist.html')

        idlist = request.POST.getlist('item_id')
        selected_playlist_id = request.POST.get('playlist_id')
        selected_playlist = Playlist.objects.all().get(id=selected_playlist_id)

        itemlist = []
        if self.type == "item":
            for itemid in idlist:
                itemlist.append(MediaItem.objects.all().get(id=itemid))

            for item in itemlist:
                new_id = uuid.uuid4()
                PlaylistResource.objects.get_or_create(resource_type='item',resource_id=item.id,playlist=selected_playlist,defaults={'public_id':new_id})
        else:
            for itemid in idlist:
                itemlist.append(MediaCollection.objects.all().get(id=itemid))

            for item in itemlist:
                new_id = uuid.uuid4()
                PlaylistResource.objects.get_or_create(resource_type='collection',resource_id=item.id,playlist=selected_playlist,defaults={'public_id':new_id})

        context = RequestContext(request, {
                'selected_items_list': itemlist,
                'type':self.type,
                'lastquerypath': request.POST.get('lastquerypath')})
        return HttpResponse(template_name.render(context))

Ancestors (in MRO)

Methods

def addToPlaylist(

self, request, type=None)

def addToPlaylist(self, request, type=None):
    self.type=type
    template_name = loader.get_template('search/confirmation_add_playslist.html')
    idlist = request.POST.getlist('item_id')
    selected_playlist_id = request.POST.get('playlist_id')
    selected_playlist = Playlist.objects.all().get(id=selected_playlist_id)
    itemlist = []
    if self.type == "item":
        for itemid in idlist:
            itemlist.append(MediaItem.objects.all().get(id=itemid))
        for item in itemlist:
            new_id = uuid.uuid4()
            PlaylistResource.objects.get_or_create(resource_type='item',resource_id=item.id,playlist=selected_playlist,defaults={'public_id':new_id})
    else:
        for itemid in idlist:
            itemlist.append(MediaCollection.objects.all().get(id=itemid))
        for item in itemlist:
            new_id = uuid.uuid4()
            PlaylistResource.objects.get_or_create(resource_type='collection',resource_id=item.id,playlist=selected_playlist,defaults={'public_id':new_id})
    context = RequestContext(request, {
            'selected_items_list': itemlist,
            'type':self.type,
            'lastquerypath': request.POST.get('lastquerypath')})
    return HttpResponse(template_name.render(context))

def display(

self, request, type='item')

def display(self, request, type="item"):
    self.type=type
    template_name = loader.get_template('search/addplaylist.html')
    idlist = request.POST.getlist('selected_items_list')
    itemlist = []
    if self.type =="item":
        for itemid in idlist:
            itemlist.append(MediaItem.objects.all().get(id=itemid))
    if self.type =="collection":
        for itemid in idlist:
            itemlist.append(MediaCollection.objects.all().get(id=itemid))
    context = RequestContext(request, {
            'selected_items_list': itemlist,
            'existing_playlists': Playlist.objects.all().filter(author=request.user),
            'type':self.type,
            'lastquerypath':request.POST.get('lastquerypath')})
    return HttpResponse(template_name.render(context))