Esempio n. 1
0
def ProtagonistaEvent(request):
    global protaform
    if request.method == 'POST' or bool(protaform):
        if request.method == 'POST': protaform = NomDataForm(request.POST)
        protaform.is_valid()
        fdict = {}
        try:
            fdict = protaform.cleaned_data
        except:    
            print('Error al cleaned data Protagonista')
        consultaB = "SELECT * from baptisme natural join event_taula"   #Comencem a crear la consulta
        consultaM = "SELECT * from matrimoni natural join event_taula"
        consultaO = "SELECT * from obituari natural join event_taula"
        Buit = True
        for e in fdict:
            if fdict[e]!='-' and fdict[e]!='':
                consultaB += " WHERE";consultaM += " WHERE";consultaO += " WHERE"
                Buit = False
                break
        consultaB,_= Assistant.AddParameters(fdict,consultaB)
        consultaO,_= Assistant.AddParameters(fdict,consultaO)
        consultaM, newform = Assistant.AddParametersMatrimoni(fdict,consultaM)
        
        Btable = []
        if not Buit: Btable = Assistant.getTable(consultaB,'Baptisme')
        tableB = BatejatTable(Btable)
        RequestConfig(request).configure(tableB)
        tableB.paginate(page = request.GET.get('page',1),per_page=10)
        
        Mtable = []
        if not Buit: Mtable = Assistant.getTable(consultaM,'Matrimoni')
        tableM = MatrimoniTable(Mtable)
        RequestConfig(request).configure(tableM)
        tableM.paginate(page = request.GET.get('page',1),per_page=10)
        
        Otable = []
        if not Buit: Otable = Assistant.getTable(consultaO,'Obituari')
        tableO = ObituariTable(Otable)
        RequestConfig(request).configure(tableO)
        tableO.paginate(page = request.GET.get('page',1),per_page=10)
        
        protaform = NomDataForm(newform)
        context = {'baptismes': tableB, 'matrimoni':tableM,'obituari':tableO,'form':protaform}
        render(request,'tfg/general_protagonista.html',context)
        
    else:
        protaform = NomDataForm()
        tableB = BatejatTable([])
        tableM = MatrimoniTable([])
        tableO = ObituariTable([])
        context = {'baptismes': tableB, 'matrimoni':tableM,'obituari':tableO,'form':protaform}
    return render(request,'tfg/general_protagonista.html',context)
Esempio n. 2
0
def ParticipantEvent(request):
    global pform
    if request.method == 'POST' or bool(pform):
        if request.method == 'POST': pform = NomDataForm(request.POST)
        pform.is_valid()
        fdict = {}
        try:
            fdict = pform.cleaned_data
        except:    
            print('Error al cleaned data Participant')
        consulta = "SELECT * from participant natural join event_taula"
        Buit = True
        for e in fdict:
            if fdict[e]!='-' and fdict[e]!='':
                consulta += " WHERE"
                Buit = False
                break
        consulta,newform = Assistant.AddParameters(fdict,consulta)
        if not Buit:
            partable = Assistant.getTable(consulta,'Participant')
        else:
            partable = []
        table = ParticipantTable(partable)
        RequestConfig(request).configure(table)
        table.paginate(page = request.GET.get('page',1),per_page=50)
        pform = NomDataForm(newform)
        context = {'participant':table,'form':pform}
        render(request,'tfg/general_participant.html',context)
    else:
        pform = NomDataForm()
        table = ParticipantTable([])
        context = {'participant':table,'form':pform}
    return render(request,'tfg/general_participant.html',context)
Esempio n. 3
0
def vida(request):
    global vidaform
    if request.method == 'POST' or bool(vidaform):
        if request.method == 'POST': vidaform = NomDataForm(request.POST)
        vidaform.is_valid()
        fdict = {}
        try:
            fdict = vidaform.cleaned_data
        except:    
            print('Error al cleaned data vida')
        consultaB = "";consultaM = "";consultaO = "";consultaP = ""
        Buit = True
        for e in fdict:
            if fdict[e]!='-' and fdict[e]!='':
                consultaB = "select * from  baptisme natural join event_taula WHERE "
                consultaM = "select * from  matrimoni natural join event_taula WHERE "
                consultaO = "select * from  obituari natural join event_taula WHERE "
                consultaP = "select * from  participant natural join event_taula WHERE "
                Buit = False
                break

        consultaB,_= Assistant.AddParameters(fdict,consultaB)
        consultaO,_= Assistant.AddParameters(fdict,consultaO)
        consultaM,_ = Assistant.AddParametersMatrimoni(fdict,consultaM)   
        consultaP,newform = Assistant.AddParameters(fdict,consultaP)
#        newform = dict(list(newform1.items()) + list(newformData.items()))
        tableB=[];tableM=[];tableO=[];tableP=[]
        if not Buit:
            tableB = Assistant.getTable(consultaB,'Baptisme')
            tableM = Assistant.getTable(consultaM,'Matrimoni')
            tableO = Assistant.getTable(consultaO,'Obituari')
            tableP = Assistant.getTable(consultaP,'Participant')

        vides = Assistant.getVides(tableB,tableM,tableO,tableP)
        vidaform = NomDataForm(newform)
        context = {'form':vidaform,'vides':vides}
        return render(request,'tfg/general_vida.html',context)
    else:
        vidaform = NomDataForm()
        vides = []
        context = {'form':vidaform,'vides':vides}
        return render(request,'tfg/general_vida.html',context)
Esempio n. 4
0
def Obituaris(request):
    global oform
    url = request.build_absolute_uri()
    if request.method == 'POST' or 'cerca-obituaris' in url:
        if request.method == 'POST': oform = NomDataForm(request.POST)
        oform.is_valid()
        fdict = oform.cleaned_data
        consulta = "SELECT * from obituari natural join event_taula"   #Comencem a crear la consulta
        Buit = True
        for e in fdict:
            if fdict[e]!='-' and fdict[e]!='':
                consulta += " WHERE"
                Buit = False
                break            
        consulta,newform = Assistant.AddParameters(fdict,consulta)
        if not Buit:
            Otable = Assistant.getTable(consulta,'Obituari')
        else:
            Otable = []
        tableO = ObituariTable(Otable)
        RequestConfig(request).configure(tableO)
        tableO.paginate(page = request.GET.get('page',1),per_page=20)
        oform = NomDataForm(newform)
        context = {'obituaris': tableO,'form': oform}
        return render(request,'tfg/base_obituaris.html',context)
        

    else:
        arxiutable = [] 
        with connection.cursor() as cursor:
            cursor.execute("SELECT * from arxiu where nom_llibre LIKE 'O%'")
            arxius = cursor.fetchall()
        for a in arxius:
            arxiutable.append({'Arxiu':a[0],'Nom_Parroquia':a[1],
                               'Persona_B':a[2],'Persona_R':a[3]})
        table = ArxiuTable(arxiutable)
        RequestConfig(request).configure(table)
        table.paginate(page = request.GET.get('page',1),per_page=25)
        
        oform = NomDataForm()
        context = {'obituaris': table,
                   'form': oform}
    return render(request,'tfg/base_obituaris.html',context)
Esempio n. 5
0
def Baptismes(request):
    global bform
    url = request.build_absolute_uri()
    if request.method == 'POST' or 'cerca-batejat' in url:
        if request.method == 'POST': bform = NomDataForm(request.POST)
        bform.is_valid()
        fdict = bform.cleaned_data
        consulta = "SELECT * from baptisme natural join event_taula"   #Comencem a crear la consulta
        for e in fdict:
            if fdict[e]!='-' and fdict[e]!='':
                consulta += " WHERE"
                break        
        consulta,newform = Assistant.AddParameters(fdict,consulta)
        baptable = Assistant.getTable(consulta,'Baptisme')
        table = BatejatTable(baptable)
        RequestConfig(request).configure(table)
        table.paginate(page = request.GET.get('page',1),per_page=50)
        bform = NomDataForm(newform)
        context = {'baptismes': table,'form': bform}
        return render(request,'tfg/base_baptismes.html',context)
        
    else:
        arxiutable = [] 
        with connection.cursor() as cursor:
            cursor.execute("SELECT * from arxiu where nom_llibre LIKE 'B%'")
            arxius = cursor.fetchall()
        for a in arxius:
            arxiutable.append({'Arxiu':a[0],'Nom_Parroquia':a[1],
                               'Persona_B':a[2],'Persona_R':a[3]})
        table = ArxiuTable(arxiutable)
        RequestConfig(request).configure(table)
        table.paginate(page = request.GET.get('page',1),per_page=25)
        
        bform = NomDataForm()
        context = {'baptismes': table,
                   'form': bform}
    return render(request,'tfg/base_baptismes.html',context)