search.py 844 B

1234567891011121314151617181920212223242526
  1. from misago.decorators import block_crawlers
  2. from misago.models import Post
  3. from misago.apps.errors import error404
  4. from misago.apps.search.views import do_search, results
  5. def allow_search(f):
  6. def decorator(*args, **kwargs):
  7. if not (request.acl.private_threads.can_participate()
  8. and request.settings['enable_private_threads']):
  9. return error404()
  10. return f(*args, **kwargs)
  11. return decorator
  12. @block_crawlers
  13. @allow_search
  14. def search_private_threads(request):
  15. threads = [t.pk for t in request.user.private_thread_set.all()]
  16. queryset = Post.objects.filter(thread_id__in=threads)
  17. return do_search(request, queryset, 'private_threads')
  18. @block_crawlers
  19. @allow_search
  20. def show_private_threads_results(request):
  21. return results(request, 'private_threads')