Cache a user's group membership

and add attributes .is_user, .is_tutor and .is_trainer, to save SQL
queries.