Beispiel #1
0
def elenco_persone(request,professione_id=0):
    #generi_list,form=get_default()
    parameters=get_default_parameter()
    professioni_list=Professioni.objects.all().order_by('professione')
    if professione_id==0:
        elenco_persone=Persona.objects.all().order_by('cognome','nome')
    else:
        elenco_persone=Persona.objects.filter(professione__id=professione_id).order_by('cognome','nome')
        
        
    paginator = Paginator(elenco_persone, 20) 

    # Make sure page request is an int. If not, deliver first page.
    try:
        page = int(request.GET.get('page', '1'))
    except ValueError:
        page = 1

    # If page request (9999) is out of range, deliver last page of results.
    try:
        persone = paginator.page(page)
    except (EmptyPage, InvalidPage):
        persone = paginator.page(paginator.num_pages)


    #parameters={}
    #parameters['generi_list'] = generi_list
    parameters['professioni_list'] = professioni_list
    parameters['page_tipe'] = 'elenco_persone'
    parameters['persone'] = persone
    #parameters['form'] = form
    parameters['form_persone'] = SearchPersonaForm ()
    t = loader.get_template(settings.SITE_TEMPLATE_PAGES_BASE_PATH +  'home.html')
    c = RequestContext( request, parameters)
    return HttpResponse(t.render(c))
Beispiel #2
0
def scheda(request,persona_id):
    persona=Persona.objects.get(id=persona_id)
    #generi_list,form=get_default()
    parameters=get_default_parameter()
    filmografia=Movie.objects.filter(attori=persona).order_by('anno')
    elenco_link=PersonaLink.objects.filter(persona=persona)
    #parameters=theme()
    #parameters={}
    parameters['persona'] = persona
    parameters['elenco_link'] = elenco_link
    parameters['filmografia'] = filmografia
    #parameters['generi_list'] = generi_list
    parameters['page_tipe'] = 'scheda_persona'
    #parameters['form'] = form
    parameters['form_persone'] = SearchPersonaForm ()
    t = loader.get_template(settings.SITE_TEMPLATE_PAGES_BASE_PATH +  'home.html')
    c = RequestContext( request, parameters)
    return HttpResponse(t.render(c))
Beispiel #3
0
def ricerca_persone(request):
    parameters=get_default_parameter()
    professioni_list=Professioni.objects.all().order_by('professione')
    elenco_persone=None
    if request.method == 'POST':
        form_persone = SearchPersonaForm(request.POST)
        if form_persone.is_valid():
            nome = form_persone.cleaned_data['nome']
            professione = form_persone.cleaned_data['professione']
            elenco_persone=Persona.objects.filter(Q(nome__icontains=nome) | Q(cognome__icontains=nome)).filter(professione=professione).order_by('cognome','nome')
        
        
        
    paginator = Paginator(elenco_persone, 20) 

    # Make sure page request is an int. If not, deliver first page.
    try:
        page = int(request.GET.get('page', '1'))
    except ValueError:
        page = 1

    # If page request (9999) is out of range, deliver last page of results.
    try:
        persone = paginator.page(page)
    except (EmptyPage, InvalidPage):
        persone = paginator.page(paginator.num_pages)


    
    #parameters['generi_list'] = generi_list
    parameters['professioni_list'] = professioni_list
    parameters['page_tipe'] = 'elenco_persone'
    parameters['persone'] = persone
    #parameters['form'] = form
    parameters['form_persone'] = SearchPersonaForm ()
    t = loader.get_template(settings.SITE_TEMPLATE_PAGES_BASE_PATH +  'home.html')
    c = RequestContext( request, parameters)
    return HttpResponse(t.render(c))