improve flask configuration managament

This fixes CSRFProtect so it works in deployment and also is correctly disabled
when running tests locally.
Naming database constants in config with different variables rather than
a hash, which makes it easier to replace the password in the install
script for Ubuntu.
Changes setup_ubuntu.sh to install MySQL and set up databases and tables as needed
Merging flask-rewrite into feature/issue95