def supprime_graphe(request): if 'id' in request.POST: test=Graphe_competences.objects.filter(competence__id=request.POST['id']).aggregate(graphe=Max('graphe')) graphe=test['graphe'] if graphe is not None: Graphe_competences.delete_graphe(graphe) return {'success':True,'msg':u'Graphe N° %s supprimé' % graphe} else: return {'success':False,'msg':u'Pas de graphe lié à la compétence n° %s' % request.POST['id']} return {'success':False,'msg':'Clé manquante'}
def init_test(): Graphe_competences.delete_graphe(0) Graphe_competences.delete_graphe(1) Graphe_competences.delete_graphe(2) Graphe_competences.delete_graphe(3) Graphe_competences.init_graphe_sql(niveau=0, competence_id=917, graphe=0) Graphe_competences.init_graphe_sql(niveau=1, competence_id=927, graphe=1) Graphe_competences.init_graphe_sql(niveau=2, competence_id=941, graphe=2) Graphe_competences.init_graphe_sql(niveau=2, competence_id=949, graphe=3)