示例#1
0
def form(user, t, n, post=None):
    """
        Returns the form in the modify view or in the filter in the watch view
    
    :param user: not used yet
    :type user: not use yet
    :param t: it represent which kind of data it is (exemple: a groupe)
    :type t: int 
    :param n: if =0, it is filter ; if =2 it is change, if =3 it is a formset, else ids to add
    :type n: inr
    :param post: request.POST value
    :type post: request.POST of Django
    """
    
    if t == 1:
        if n == 0:
            if post == None:
                return fitrerGroupe()
            else:
                return fitrerGroupe(post)
        elif n == 2:
            if post == None:
                return forms.changeGroupe()
            else:
                return forms.changeGroupe(post)
        elif n == 3:
            return forms.NomFormSet
        else:
            if post == None:
                return forms.AjouterGroupe
            else:
                return forms.AjouterGroupe(post)
    elif t == 2:
        if n == 0:
            if post == None:
                return forms.fitrerUV()
            else:
                return forms.fitrerUV(post)
        elif n == 2:
            if post == None:
                return forms.changeUV()
            else:
                return forms.changeUV(post)
        elif n == 3:
            return forms.NomFormSet
        else:
            if post == None:
                return forms.AjouterUV
            else:
                return forms.AjouterUV(post)
    elif t == 3:
        if n == 0:
            if post == None:
                return forms.fitrerModule()
            else:
                return forms.fitrerModule(post)
        elif n == 2:
            if post == None:
                return forms.changeModule()
            else:
                return forms.changeModule(post)
        elif n == 3:
            return forms.moduleFormSet
        else:
            if post == None: 
                return forms.AjouterModule
            else:
                return forms.AjouterModule(post)
    elif t == 4:
        if n == 0:
            if post == None:
                return forms.fitrerCalendrier()
            else:
                return forms.fitrerCalendrier(post)
        elif n == 2:
            if post == None:
                return forms.changeCalendrier()
            else:
                return forms.changeCalendrier(post)
        elif n == 3:
            return forms.CalendrierFormSet
        else:
            if post == None: 
                return forms.AjouterCalendrier
            else:
                return forms.AjouterCalendrier(post) 
    elif t == 6:
        if n == 0:
            if post == None:
                return forms.fitrerNote()
            else:
                return forms.fitrerNote(post)
        elif n == 2:
            if post == None:
                return forms.changeNote()
            else:
                return forms.changeNote(post)
        elif n == 3:
            return forms.BaseNoteFormSet
        else:
            if post == None: 
                return forms.AjouterNote
            else:
                return forms.AjouterNote(post) 
    elif t == 5:
        if n == 0:
            if post == None:
                return forms.fitrerSalle()
            else:
                return forms.fitrerSalle(post)
        elif n == 2:
            if post == None:
                return forms.changeSalle()
            else:
                return forms.changeSalle(post)
        elif n == 3:
            return forms.NomFormSet
        else:
            if post == None: 
                return forms.AjouterSalle
            else:
                return forms.AjouterSalle(post)
    elif t == 7:
        if n == 0:
            if post == None:
                return forms.fitrerCour()
            else:
                return forms.fitrerCour(post)
        elif n == 2:
            if post == None:
                return forms.changeCour()
            else:
                return forms.changeCour(post)
        elif n == 3:
            return None
        else:
            if post == None: 
                return forms.AjouterCour
            else:
                return forms.AjouterCour(post)
    else:
        if n == 0:
            if post == None:
                return fitrerP()
            else:
                return fitrerP(post)
        elif n == 2:
            if post == None:
                return forms.changeP()
            else:
                return forms.changeP(post)
        elif n == 3:
            return forms.PersonneFormSet
        else:
            if post == None:
                return AjouterP
            else:
                return AjouterP(post)