learning-unlimited/ESP-Website — pull request #977 by pricem (2014-01-26 20:36:05+00:00)
Title: Prevent overwriting static files when loading themes

See issue #881. Comments copied from commit messages:

Loading a theme would normally copy images and scripts to the /media/
dirs. In many cases users have customized those files (e.g. using the
admin filebrowser) and don't want their changes to be overwritten. The
typical case is a chapter's logo image.

The solution presented here is to create a new view, confirm_overwrite().
This view is called whenever a difference is detected between the theme
provided files and the files currently in /media. In this case, the user
has to choose whether to keep or overwrite each file (the default is
keep). With this form submitted, confirm_overwrite hands control back
to the previous view function (e.g. select() or recompile()) which tells
the ThemeController which files to keep.

The way to test this is to use the filebrowser to upload some new files in the images/theme and scripts/theme directories (note that they must have the same filenames as existing files), and make sure that you are prompted whether to overwrite them when loading or recompiling a theme. Also make sure that it actually preserves the files you want to preserve, and overwrites the files you want to overwrite.