Merge pull request #213 from Turbo87/api

Improved /api code
views/settings: Fixed typo in password() handler

The current_password should be validated, not the new password!! D'oh!
model: Moved "db" object into model package and use lazy initialization
tests/lib/test_sql: Use test class to get rid of global context variable
tracking: Fixed tracking daemon to work with lazy init db object
scripts: Use app context before interacting with the database
views: Use model.db instead of app.db
tests: Use model.db instead of app.db
worker, analysis: Use model.db instead of app.db
alembic: Use model.db instead of app.db
scripts: Use create_app() factory function instead of app
app: Don't export db object

Use model.db instead.
app: Use create_app() instead of app
app: Use app factory pattern
app: Call add_celery() from add_web_components()

The celery worker and the analyse_delayed.py script call celery.init_app()
themselves and running add_celery() would duplicate that.
app: Added create_frontend_app() function
app: Added create_celery_app() function
app: Removed unused wdb support
tests: Explicitly use testing config
app: Removed add_web_components() method