'Checks if a user can join a group.'

def user_can_join(self, userprofile):

    return (userprofile.is_vouched and (getattr(self, 'accepting_new_members', 'yes') != 'no') and (not (self.has_member(userprofile=userprofile) or self.has_pending_member(userprofile=userprofile))))
