'Returns true if the given user has permissions based on users, groups, or all flag'

def user_has_access(self, user):

    return (self.groups.filter(id__in=user.groups.all()).exists() or (user in self.users.all()))
