def index(request): username = request.session if 'idsession' not in request.session: return redirect("/") gest = dbEtablissement() schools = gest.returnAll() return render(request, 'etablissement/lister.html', {'school': schools,'username':username['idsession']})
def supprimer(request,id): username = request.session if 'idsession' not in request.session: return redirect("/") gest = dbEtablissement() etab = gest.returnOne(id) return render(request, 'etablissement/supprimer.html',{'etab':etab,'username':username['idsession']})
def sauvegarder(request): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() gest = dbEtablissement() progr = dbProgramme() programme = progr.returnAll() nometab = request.GET['etablissement'] etabli = gest.searchEtab(nom=nometab) all = gest.returnAll() annee = request.GET['annee'] semestre = request.GET['semestre'] nomcours = request.GET['nomcours'] etab = dbIdcours() code = "{}-{}{}-{}".format(etabli.nom,annee,semestre,nomcours) ecole = Idcours(etablissement=etabli,annee=annee,semestre=semestre,nomcours=nomcours,codecours=code,date=now) if(not etab.isExist(id_etablissement=etabli,annee=annee,semestre=semestre,nomcours=nomcours,codecours=code)): if(not etab.save(ecole)): message = "Code cours ajouter !" else: message = "Code cours non ajouter." else: message = "le Code cours {} existe deja.".format(code) return render(request, 'idcours/ajouter.html',{'message': message,'etab':all,'programme':programme,'username':username['idsession']})
def savemodification(request,id): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() cod = request.GET['idcours'] code = dbIdcours() idcours = code.returnID(codecours=cod) p = request.GET['professeur'] pro = dbProfesseur() prof = pro.returnOne(id=p) nomab = request.GET['etablissement'] tab = dbEtablissement() etablissement = tab.returnOne(id=nomab) titre = request.GET['titre'] creditECTS = request.GET['creditECTS'] public = request.GET['public'] objectif = request.GET['objectif'] description = request.GET['description'] formatcours = request.GET['formatcours'] prerequis = request.GET['prerequis'] ressources = request.GET['ressources'] evaluation = request.GET['evaluation'] plan = request.GET['plan'] etab = dbCours() if(etab.modify(id=id,idcours=idcours,professeur=prof,etablissement=etablissement,titre=titre,creditECTS=creditECTS,public=public,objectif=objectif,description=description,plan=plan,formatcours=formatcours,prerequis=prerequis,ressources=ressources,evaluation=evaluation,date=now)): message = "Code cours non modifier !" else: message = "Code cours modifier." return render(request, 'cours/savemodification.html',{'message':message,'username':username['idsession']})
def modifier(request,id): username = request.session if 'idsession' not in request.session: return redirect("/") idcours = dbIdcours() cours = idcours.returnOne(id) gest = dbEtablissement() etab = gest.returnAll() return render(request, 'idcours/modifier.html',{'etab':cours,'school':etab,'username':username['idsession']})
def ajouter(request): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() gest = dbEtablissement() etab = gest.returnAll() progr = dbProgramme() programme = progr.returnAll() t = get_template('idcours/ajouter.html') html = t.render(Context({'current_date': now,'etab':etab,'programme':programme,'username':username['idsession']})) return HttpResponse(html)
def savesuppression(request,id): username = request.session if 'idsession' not in request.session: return redirect("/") gest = dbEtablissement() if(not gest.returnOne(id=id) == None): if(not gest.delete(id=id)): message = "Etablissement effacee." else: message = "Etablissement non effacee." else: message = "L'etablissemnt n'existe pas !" return render(request, 'etablissement/savesuppression.html',{'message':message,'username':username['idsession']})
def savemodification(request,id): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() nom = request.GET['nom'] lieu = request.GET['lieu'] gest = dbEtablissement() etab = Etablissement(nom=nom,lieu=lieu,date=now) if(gest.modify(id=id,nom=nom,lieu=lieu,date=now)): message = "Etablissement non modifier !" else: message = "Etablissement modifier." return render(request, 'etablissement/savemodification.html',{'message':message,'username':username['idsession']})
def ajouter(request): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() id = dbIdcours() idcours = id.returnAll() dico = {} for ele in idcours: dico = {ele.id:ele.nomcours} gest = dbEtablissement() etab = gest.returnAll() dbprof = dbProfesseur() prof = dbprof.returnAll() t = get_template('cours/ajouter.html') html = t.render(Context({'current_date': now,'idcours':idcours,'prof':prof,'etab':etab,'dico':dico,'username':username['idsession']})) return HttpResponse(html)
def sauvegarder(request): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() nom = request.GET['nom'] lieu = request.GET['lieu'] etab = dbEtablissement() ecole = Etablissement(nom=nom,lieu=lieu,date=now) if(not etab.isExist(nom=nom,lieu=lieu)): if(not etab.save(ecole)): message = "Etablissement ajouter !" else: message = "Etablissemenet non ajouter." else: message = "l'etablissement {} existe deja.".format(nom) return render(request, 'etablissement/ajouter.html',{'message': message,'username':username['idsession']})
def savemodification(request,id): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() gest = dbEtablissement() nometab = request.GET['etablissement'] etabli = gest.searchEtab(nom=nometab) all = gest.returnAll() annee = request.GET['annee'] semestre = request.GET['semestre'] nomcours = request.GET['nomcours'] code = "{}-{}{}-{}".format(etabli.nom,annee,semestre,nomcours) etab = dbIdcours() ecole = Idcours(etablissement=etabli,annee=annee,semestre=semestre,nomcours=nomcours,codecours=code,date=now) if(etab.modify(id=id,id_etablissement=etabli,annee=annee,semestre=semestre,nomcours=nomcours,codecours=code,date=now)): message = "Code cours non modifier !" else: message = "Code cours modifier." return render(request, 'idcours/savemodification.html',{'message':message,'etab':ecole,'school':all,'username':username['idsession']})
def sauvegarder(request): username = request.session if 'idsession' not in request.session: return redirect("/") now = datetime.datetime.now() idcours = request.GET['idcours'] prof = request.GET['professeur'] nometab = request.GET['etablissement'] titre = request.GET['titre'] creditECTS = request.GET['creditECTS'] public = request.GET['public'] objectif = request.GET['objectif'] description = request.GET['description'] formatcours = request.GET['formatcours'] prerequis = request.GET['prerequis'] ressources = request.GET['ressources'] evaluation = request.GET['evaluation'] plan = request.GET['plan'] id = dbIdcours() cours = id.returnAll() gest = dbEtablissement() etabli = gest.returnAll() dbprof = dbProfesseur() professeur = dbprof.returnAll() etab = dbCours() ecole = Cours(idcours=id.returnOne(id=idcours),professeur=dbprof.returnOne(id=prof),etablissement=gest.returnOne(id=nometab),titre=titre,creditECTS=creditECTS,public=public,objectif=objectif,description=description,plan=plan,formatcours=formatcours,prerequis=prerequis,ressources=ressources,evaluation=evaluation,date=now) if(not etab.isExist(idcours=id.returnOne(id=idcours),professeur=dbprof.returnOne(id=prof),etablissement=gest.returnOne(id=nometab),titre=titre)): if(not etab.save(ecole)): message = "Code cours ajouter !" else: message = "Code cours non ajouter." else: message = "le cours {} existe deja.".format(ecole.titre) return render(request, 'cours/ajouter.html',{'message': message,'idcours':cours,'prof':professeur,'etab':etabli,'username':username['idsession']})