learning-unlimited/ESP-Website — pull request #886 by pricem (2013-12-31 04:42:36+00:00)
Title: Used hashed URL as identifier in client side QSD editing

Miles and I were getting some IntegrityErrors on the production sites after upgrading to the new code. It turns out that there was a regression somewhere in our code post-schema-simplification, and I made it worse somewhere in the mit-theme-tweaks branch. This is an attempt to solve the underlying problem: allowing QSD display/editing to work for both existing a new QSDs.

We used to identify QSDs by anchor, and now after schema simplification,
we mainly identify them by URL. (This is helpful in our inline QSD
block rendering, where we don't want to create a QSD object unless the
default text is edited by an admin... so we don't have an ID to work
with.) The problem is you can't name an HTML DOM element after a URL.

To fix this, pass around URLs instead of IDs in our Javascript, and
compute an 8-character hash of the URL (which is referred to as the
edit_id) to use as a "slug" for DOM IDs.

This is another method of addressing the underlying problem that
I (incorrectly) hacked around in ca061ad.