示例#1
0
    def get_queryset(self):
        """Returns list of querysets containing content a user is allowed to search.

        This is determined by a user's organization.
        """

        user_org = self.request.user.organization
        user = self.request.user

        # retrieve all content a user is allowed to search
        searchable_org_objects = Organization.get_org_searchable_content(user_org)
        searchable_user_objects = User.get_user_searchable_content(user)

        # unpack the querysets from the list of querysets returned
        series, stories, webfacets, printfacets, audiofacets, videofacets, imageassets, networknotes, orgnotes, seriesnotes, storynotes = (
            searchable_org_objects
        )
        usernotes = searchable_user_objects

        # pass all querysets to search method
        return watson.search(
            self.query,
            models=[
                series,
                stories,
                webfacets,
                printfacets,
                audiofacets,
                videofacets,
                imageassets,
                networknotes,
                orgnotes,
                seriesnotes,
                storynotes,
                usernotes,
            ],
        )