(request, episode)
return HttpResponseRedirect(
        get_episode_link_target(episode, podcast, "episode-publisher-detail")
    )
sets a new "main" slug, and moves the existing to the merged slugs
sets a new "main" slug, and moves the existing to the merged slugs
sets a new main slug and moves the existing to the merged slugs
def update_episode_slug(request, episode):
    """sets a new "main" slug, and moves the existing to the merged slugs"""

    new_slug = request.POST.get("slug")
    podcast = episode.podcast

    if new_slug:
        # remove the new slug from other episodes (of the same podcast)
        other_episodes = Episode.objects.filter(
            podcast=podcast,
            slugs__slug=new_slug,
            slugs__content_type=ContentType.objects.get_for_model(Episode),
        )

        for other_episode in other_episodes:

            if other_episode == episode:
                continue

            other_episode.remove_slug(new_slug)
            messages.warning(
                request,
                _(
                    "Removed slug {slug} from {episode}".format(
                        slug=new_slug, episode=other_episode.title
                    )
                ),
            )

    episode.set_slug(new_slug)

    # TODO: we should use better cache invalidation
    cache.clear()

    return HttpResponseRedirect(
        get_episode_link_target(episode, podcast, "episode-publisher-detail")
    )
def update_episode_slug ( request , episode ) : new_slug = request . POST . get ( "slug" ) podcast = episode . podcast if new_slug : # remove the new slug from other episodes (of the same podcast) other_episodes = Episode . objects . filter ( podcast = podcast , slugs__slug = new_slug , slugs__content_type = ContentType . objects . get_for_model ( Episode ) , ) for other_episode in other_episodes : if other_episode == episode : continue other_episode . remove_slug ( new_slug ) messages . warning ( request , _ ( "Removed slug {slug} from {episode}" . format ( slug = new_slug , episode = other_episode . title ) ) , ) episode . set_slug ( new_slug ) # TODO: we should use better cache invalidation cache . clear ( ) return HttpResponseRedirect ( get_episode_link_target ( episode , podcast , "episode-publisher-detail" ) )