Change Foreign Key relationship for ResourceBase and Thumbnail

Prevents duplicate thumbnails in db when updatelayers is run

Cascade deletes Thumbnails with ResourceBase removal
use anonymous group to manage anonymous permissions, fixes permissions for newly created users
make flake8 happy
add test for new anonymous group permissions, fix set_default_permissions and group tests
Merge pull request #1689 from simod/master

use anonymous group to manage anonymous permissions, fixes permissions f...
distance profile resources count. Fixes #1651
Merge pull request #1672 from mwengren/thumbnail_fix

Change Foreign Key relationship for ResourceBase and Thumbnail