Check study access rights and study exists

 Fix #445
Ah, yes, that is some vestigial code left from when the template was being rendered instead of raising errors. Can fix that.