def separation(request): eleves = UserProfile.objects.all() result = [] recherche = False if request.method == 'POST': recherche = True start = UserProfile.objects.get(user__username = request.POST.get('start_username', '')) end = UserProfile.objects.get(user__username = request.POST.get('end_username', '')) #UserProfile.depthFirstSearch(start, end, result) result = UserProfile.find_shortest_path(start, end, result) return render_to_response('trombi/separation.html', {'eleves': eleves, 'result':result, 'recherche':recherche},context_instance=RequestContext(request))
def separation(request): """Le plus court chemin séparant deux élèves""" eleves = UserProfile.objects.all() result = [] recherche = False if request.method == 'POST': recherche = True start = UserProfile.objects.get(user__username = request.POST.get('start_username', '')) end = UserProfile.objects.get(user__username = request.POST.get('end_username', '')) result = UserProfile.BFS(start, end) result_string = chemin_to_html(result) return render(request, 'trombi/separation.html', {'eleves': eleves, 'result':result, 'result_string':result_string, 'recherche':recherche})
def handle(self, *args, **options): if len(args) < 2: print 'entrez les usernames de depart et arrivee' else: start_username = args[0] end_username = args[1] start = UserProfile.objects.get(user__username = start_username) goal = UserProfile.objects.get(user__username = end_username) result = [] if UserProfile.depthFirstSearch(start, goal, result): print 'resultat : ', [u.user.username for u in result] else: print 'pas de resultat'
class ParrainageVoeuxForm(ModelForm): #formulaire pour les fillots du parrainage fillot_n1 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) fillot_n2 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) fillot_n3 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) fillot_n4 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) fillot_n5 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) fillot_n6 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) fillot_n7 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) fillot_n8 = forms.ModelChoiceField(queryset=UserProfile.objects.filter( promo=UserProfile.premiere_annee())) class Meta: model = ParrainageVoeux exclude = ('parrain', )