Add is_editable_by_user to more managers.

KeyManager, ScalingFunctionManager, DeviceManager, PortcullisUserManager
Add general permission check for editing objects.
Code refactor
Fix merge conflict in ajax.py