WebAPIKey: initial Flask port

* Moves `web_api_key` logic to the model.

* Refactors functions to work with sqlalchemy and flask request.

* Refactors `web_api_key` to work with model functions.

* Updates `web_api_key_regression_tests`.

Signed-off-by: Konstantinos Ntemagkos <konstantinos.ntemagkos@cern.ch>
Reviewed-by: Jiri Kuncar <jiri.kuncar@cern.ch>
mailutils: Flask-Email initial port

* Adds new configuration variable CFG_MAIL_BACKEND.  (closes #1531)

* Adds html and plaintext email templates.

* Adds unit tests for sending emails.

* Adds `mailtutils_backend_adminonly` for sending emails only to
  CFG_SITE_ADMIN_EMAIL.

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
installation: jinja2utils and requirements upgrade

* Upgrades python dependencies to latest versions and fixes
  compatibility issues with Jinja2/MarkupSafe packages.
  (addresses #1476)

* NOTE run `pip install -r requirements-flask.txt --upgrade` and
  `pip install -r requirements-flask-ext.txt --upgrade`. You might need
  to clean pip cache and build directories
  (`rm -rf ~/.pip/cache/* ~/.pip/build/*`).

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
BibWorkflow: workflow query API initial release

Reviewed-by: Jiri Kuncar <jiri.kuncar@cern.ch>
inveniomanage: cache, bibrecord and runserver cmds

* Adds `cache` manager for reseting all record structure caches.

* Adds `bibrecord` manager for reseting `recstruct` caches.

* Adds expunge command to `bibformat` manager that removes
  static formats from bibfmt cache.  (addresses #1549)

* Uses host and port from config variable CFG_SITE_URL as default for
  `runserver` command.

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
Co-authored-by: Esteban J. G. Gabancho <esteban.gabancho@cern.ch>
WebSearch: CollectionExample demosite fixture fix

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
WebStyle: authorized decorator fix

* Addresses issues with authorized code different from 0 and 1.

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
installation: mysql default date value fix

* Fixes problem while installing Invenio using fixtures where some dates
  were set with year=1, which is not accepted by mysql and this made the
  installation crash. Now, they are set to 1900 which is the lowest
  value accepted by MySQL.

Signed-off-by: Alberto Rodriguez Peon <alberto.rodriguez.peon@cern.ch>
Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
WebSearch: record usage tab fix

* Fixes `rnkDOWNLOADS` and `rnkPAGEVIEWS` logging.

Signed-off-by: Jaime García <jaime.garcia.llopis@cern.ch>
Co-authored-by: Jiri Kuncar <jiri.kuncar@cern.ch>
datastructures: lazy dictionaries addition

* Adds two types of lazy dictionaries that load their content only when
  is needed or accessed for the first time.

Signed-off-by: Esteban J. G. Gabancho <esteban.gabancho@cern.ch>
Co-authored-by: Jiri Kuncar <jiri.kuncar@cern.ch>
jinja2utils: functions and filter to context

* Like for bfe_* it allows the admin user to add new functions,
  `template_context_functions` (tfn), to display content within
  a jinja template.

* Adds the possibility to create new filters
  `template_context_filters` (tfi).

Signed-off-by: Esteban J. G. Gabancho <esteban.gabancho@cern.ch>
Co-authored-by: Jiri Kuncar <jiri.kuncar@cern.ch>
BibField: laziest reader loading

* Improves lazy loading of bibfield readers using `LaziestDict`.

* Improves lazy loading of bibfield functions and field type checks.

* Addresses issue with missing application context regresion tests.

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
WebStyle: fix external url creation

* Addresses problem with creation of external urls via `url_for`
  where `CFG_SITE_URL` and `CFG_SITE_SECURE_URL` were ignored.

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
travis