Move code from CommunitiesController into Community model