def _list_designs(user, querydict, page_size, prefix="", is_trashed=False):
  """
  _list_designs(user, querydict, page_size, prefix, is_trashed) -> (page, filter_param)

  A helper to gather the designs page. It understands all the GET params in
  ``list_designs``, by reading keys from the ``querydict`` with the given ``prefix``.
  """
  DEFAULT_SORT = ('-', 'date')                  # Descending date

  SORT_ATTR_TRANSLATION = dict(
    date='last_modified',
    name='name',
    desc='description',
    type='extra',
  )

  # Trash and security
  if is_trashed:
    db_queryset = Document.objects.trashed_docs(SavedQuery, user)
  else:
    db_queryset = Document.objects.available_docs(SavedQuery, user)

  # Filter by user
  filter_username = querydict.get(prefix + 'user')
  if filter_username:
    try:
      db_queryset = db_queryset.filter(owner=User.objects.get(username=filter_username))
    except User.DoesNotExist:
      # Don't care if a bad filter term is provided
      pass

  # Design type
  d_type = querydict.get(prefix + 'type')
  if d_type and d_type in SavedQuery.TYPES_MAPPING.keys():
    db_queryset = db_queryset.filter(extra=str(SavedQuery.TYPES_MAPPING[d_type]))

  # Text search
  frag = querydict.get(prefix + 'text')
  if frag:
    db_queryset = db_queryset.filter(Q(name__icontains=frag) | Q(description__icontains=frag))

  # Ordering
  sort_key = querydict.get(prefix + 'sort')
  if sort_key:
    if sort_key[0] == '-':
      sort_dir, sort_attr = '-', sort_key[1:]
    else:
      sort_dir, sort_attr = '', sort_key

    if not SORT_ATTR_TRANSLATION.has_key(sort_attr):
      LOG.warn('Bad parameter to list_designs: sort=%s' % (sort_key,))
      sort_dir, sort_attr = DEFAULT_SORT
  else:
    sort_dir, sort_attr = DEFAULT_SORT
  db_queryset = db_queryset.order_by(sort_dir + SORT_ATTR_TRANSLATION[sort_attr])

  designs = [job.content_object for job in db_queryset.all() if job.content_object and job.content_object.is_auto == False]

  pagenum = int(querydict.get(prefix + 'page', 1))
  paginator = Paginator(designs, page_size)
  page = paginator.page(pagenum)

  # We need to pass the parameters back to the template to generate links
  keys_to_copy = [ prefix + key for key in ('user', 'type', 'sort', 'text') ]
  filter_params = copy_query_dict(querydict, keys_to_copy)

  return page, filter_params
dataset/ETHPy150Open cloudera/hue/apps/beeswax/src/beeswax/views.py/_list_designs/original