Stanford-Online/class2go — pull request #2257 by jrbl (2013-02-15 23:40:34+00:00)
Title: Jrbl 330 mode switching problems

@sefk or @jbau please

I tested as I went, which is why this took a while, and it resulted in some collateral tickets. I think a good review strategy is to read the decorator itself (in courses/actions.py) and convince yourself that it is safe, and then note that the rest of the diff is just sprinkling that decorator around where it seems to make sense. Some spots are marked as "Not strictly necessary" - in these spots, I was on the fence about whether to add the decorator because the code in the function already did something safe, even if it wasn't ideal. In these cases I opted to add the decorator anyway so there'd be uniformity of behavior and an opportunity to cull out the guesswork code later (Cf. #2244)

Thanks to @jbau for refactor ```common_paged_data_middleware``` to be a lot easier to understand.
* Implement courses.actions.always_switch_mode decorator to force a
function to always be run in draft mode. (closes #330)
* ```@always_switch_mode wrapper``` installed and tested in following places:
* File Upload/Edit/Delete
* Exam Edit/Save/Delete
* Video Upload/Edit/Save/Delete
* Content Section Rename/Save/Delete/Move
* Static page Add/Save/Delete/Move
* Announcement Create/Edit/Delete
* Decorator updated to only switch mode if mode switch is necessary
* Cleanup of unused imports in a variety of places
* courses/email_members audited but mode switching didn't seem necessary