learningequality/ka-lite — pull request #492 by bcipolli (2013-08-15 22:37:46+00:00)
Title: IDOC: Generic "updates" model for communicating between commands, views, and templates

Background:
We use management commands to do key functions (download videos and subtitles, update software) that interactions with the browser through an API. Many of the functions of these browser updates are similar--a progress bar with text-based updates, and events for start, update, error, completion.

Issues:
Here, the update procedure has been generalized to an "updates" app, which includes:
* A model that contains the current status of a process. The model includes a process name (e.g. "videodownload"), a stage (e.g. a particular youtube video), and a percent complete for each, along with "notes".
* class-level functions on the model for creating a row in the updates table, easily updating, and canceling / closing.
* Inheritable command classes that expose simple procedures for doing updates, such as start, update_stage, next_stage, cancel, and complete.
* Generic api views for starting a command, and receiving updates from the front-end.
* A template, css, and js code for triggering updates, getting incremental progress, and showing them in a progress bar.
,
In addition, videodownload / video_download.html has been migrated to use this generic app. it should look extremely similar to the previous instantiation, but what's happening on the back-end differs.

Testing:
* I've written unit tests for the updates app itself.
* I've tested videodownload and video_download.html by hand (see known issues below)

Notes:
* This is an intermediate check-in--having this generic backend-frontend integration will allow an update to the subtitles front-end (necessary for @dylanjbarth 's recent work), as well as software updates.
* Because that code (coming down the pipe) pulls video_download into parts, and uses it in very different ways, we've been unable to integrate many of the recent changes to video_download. Those will be done by hand, once we get the update_all branch (with software updates) stabalized.
* For that reason, subtitle download front-end updates have not been merged here, nor have recent changes to video_download. It's not worth it to work through the merge conflicts at this time.
* Other known issues:
* The "Waiting for download to begin" notification isn't showing (it actually doesn't exist).

The goal of the current pull request is to review the basic design and implementation of this branch, so that future code reviews on the expansive update_all branch would be simplified. In order to accomplish that, we're submitting something that's functional in unit tests, but hasn't been fully integrated in the update page.