Exclude plugins from Django cms search -
i'm using aldryn-search
on django cms site. 1 of custom plugins has manytomany field django groups, indicate user groups may see plugin (and of course child plugins). i'm considering field in render()
method of plugin.
this works fine on page, can't find way prevent regarding plugins being indexed search (which elastic search). idea?
so exclude plugin being searched completely. can set search_fulltext = false
in plugin class or plugin model.
to exclude plugin users not have access bit more work not complex.
you have create dedicated index class plugin , deactivate cms page search shown below.
then in dedicated plugin index class, add multivaluefield
hold list of user ids can see plugin, note you'll have make sure index plugins have page attached them plugins.filter(placeholder__page__isnull=false)
, plugins page published , public.
after finishing index class/logic, if using solr, update schema reflect new field.
rebuild index.
here's example on how query like:
if request.user.is_authenticated(): searchqueryset().models(pluginclass).filter(allowed_user_ids=request.user.pk)
let me know how goes :)
Comments
Post a Comment