Example #1
0
 def pag(self):
   data_dict = {
     'object_list': City.objects.all(),
     'fields': ['id','city'],
     'page': 1,
     'show_per_page': 5,
   }
   print pagination(data_dict)
Example #2
0
File: ajax.py Project: gtuxer/sigep
def datagridx(request):
  """
  Exibe os pontos de rede.
  """

  if request.method == 'POST':
    """Retorna valores necessarios para construcao do datagrid em javascript."""

    page = int(request.POST.get('page'))
    id_client = int(request.POST.get('obj_id'))
    search_text = request.POST.get('search_text')
    search_text = search_text.strip()

    fields = ['ip','mac','plan.plan','accesspoint.accesspoint','router.hostname','useproxy','isblocked','isbound']

    # se houver algum texto no campo de busca, realiza uma consulta nos campos ip e mac
    if search_text != '' and search_text != 'Busca' and len(search_text) > 0:
      n = NetworkNode.objects.filter(Q(client=id_client)& Q(ip__icontains=search_text)|Q(mac__icontains=search_text))
    else:
      n = NetworkNode.objects.filter(client=id_client)  # lista todos objetos a serem paginados

    return pagination(n, fields, page)