alphagov/panopticon — pull request #239 by rboulton (2014-12-03 14:42:55+00:00)
Title: Add a script to redirect a specialist sector

Currently, when changing a slug for a specialist sector, we first
archive the sector at the old slug (causing it to return a 410 Gone HTTP
status), and then apply a change with router-data to redirect the old
slug to the new one.

Instead, this commit adds a script to redirect a sector to a new slug,
archiving the sector in panopticon, and then registering the old slug as
a redirect content item in the content store.

The repository that this script lives in is awkward to get right: I've
chosen to put it in panopticon, because it lives in panopticon, and uses
govuk_content_models to archive the topic. However, collections-publisher
is the publishing app for "curated" sectors, so we register the document
as having "collections-publisher" as the owning app. In the near future,
collections-publisher will take ownership of topics, so this is a
convenient "lie".

This script should only exist until collections-publisher takes
ownership of topics, which is work we hope to complete in the next few
weeks. However, we also have potentially a lot of topic slug changes to
do in the next few weeks, so making this process easy at the cost of
some code mess seems like a good tradeoff.

It's also worth noting that when the topic is archived, a "gone" route
will be set up in the router, but this will be overwritten within
seconds by the redirect route from the content store. This is unlikely
to affect users, so I don't think it's worth trying to avoid this at the
cost of a more intrusive script.