[#3892] ticket:91 Refactoring and test

Optimized migration code.
Fixed 'Edit' link: show only to users with `update` permission.
Tests added for two cases:
* user has permission `create` but not `update`.
* user has both `create` and `update` permissions.
3 files changed