Django Library PyGal
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

queries.py 546B

1234567891011121314151617181920
  1. from .models import Item, supported_types
  2. import pygal
  3. from .search import load_index, search
  4. def get_readable_item_query(request, item_query):
  5. uids = []
  6. for i in item_query:
  7. if i.may_read(request.user):
  8. if i.type in supported_types():
  9. uids.append(i.id)
  10. uids = set(uids)
  11. return Item.objects.filter(id__in=uids)
  12. def search_result_query(request):
  13. search_txt = pygal.get_search_query(request)
  14. ix = load_index()
  15. #
  16. return get_readable_item_query(request, search(ix, search_txt))