ernestophone.ens.fr/trombonoscope/views.py
2020-09-10 15:06:53 +02:00

24 lines
1.1 KiB
Python

from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from gestion.models import ErnestoUser
from trombonoscope.forms import ChangeTrombonoscope
from django.shortcuts import render, redirect
@login_required
def changetrombonoscope(request):
if request.method == 'POST':
requbis = request.POST.copy()
form = ChangeTrombonoscope(request.POST,request.FILES, instance=request.user.profile)
if form.is_valid():
form.save()
success = True
return redirect('trombonoscope:view')
else:
form = ChangeTrombonoscope(instance=request.user.profile)
return render(request, 'trombonoscope/changetrombonoscope.html', locals())
@login_required
def trombonoscope(request):
trombonoscope_actuel = ErnestoUser.objects.filter(trombonoscope = "o_a")
trombonoscope_vieux = ErnestoUser.objects.filter(trombonoscope = "o_v")
return render(request, 'trombonoscope/trombonoscope.html', {'trombonoscope_actuel':trombonoscope_actuel,'trombonoscope_vieux':trombonoscope_vieux})