(request, username, format)
return response
Creates a new podcast list and links to it in the Location header
Creates a new podcast list and links to it in the Location header
Creates a new podcast list and links to it in the Location header
def create(request, username, format):
    """Creates a new podcast list and links to it in the Location header"""

    title = request.GET.get("title", None)

    if not title:
        return HttpResponseBadRequest("Title missing")

    slug = slugify(title)

    if not slug:
        return HttpResponseBadRequest("Invalid title")

    plist, created = PodcastList.objects.get_or_create(
        user=request.user,
        slug=slug,
        defaults={
            "id": uuid.uuid1(),
            "title": title,
            "slug": slug,
            "created": datetime.utcnow(),
            "modified": datetime.utcnow(),
        },
    )

    if not created:
        return HttpResponse("List already exists", status=409)

    urls = parse_subscription(request.body.decode("utf-8"), format)
    podcasts = [Podcast.objects.get_or_create_for_url(url).object for url in urls]

    for podcast in podcasts:
        plist.add_entry(podcast)

    response = HttpResponse(status=201)
    list_url = reverse("api-get-list", args=[request.user.username, slug, format])
    response["Location"] = list_url

    return response
def create ( request , username , format ) : title = request . GET . get ( "title" , None ) if not title : return HttpResponseBadRequest ( "Title missing" ) slug = slugify ( title ) if not slug : return HttpResponseBadRequest ( "Invalid title" ) plist , created = PodcastList . objects . get_or_create ( user = request . user , slug = slug , defaults = { "id" : uuid . uuid1 ( ) , "title" : title , "slug" : slug , "created" : datetime . utcnow ( ) , "modified" : datetime . utcnow ( ) , } , ) if not created : return HttpResponse ( "List already exists" , status = 409 ) urls = parse_subscription ( request . body . decode ( "utf-8" ) , format ) podcasts = [ Podcast . objects . get_or_create_for_url ( url ) . object for url in urls ] for podcast in podcasts : plist . add_entry ( podcast ) response = HttpResponse ( status = 201 ) list_url = reverse ( "api-get-list" , args = [ request . user . username , slug , format ] ) response [ "Location" ] = list_url return response