from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect

from BasicData.templatetags.custom_tag import get_decision_annuelle_etudiant, decision_annuelle_etudiant
from BasicData.templatetags.custom_tag_obj import get_semestre_niveau_by_annee, get_pat_responsabilite
from session_tracking.utils import track_insert
from .forms import *
from BasicData.models import *
from .models import *
from django.contrib import messages
from django.http import FileResponse, Http404


# Create your views here.

@login_required(login_url='BasicData:login')
def drh_home(request):
    user = Personnel.objects.get(email=request.user.email)
    print(get_pat_responsabilite(request.user.email))
    context = {
        'user':user,
    }
    return render(request, 'drh/drh_base.html',context)


@login_required(login_url='BasicData:login')
def personnel_list(request):
    user = Personnel.objects.get(email=request.user.email)
    # On recupere tout les Etudiants
    personnel = Personnel.objects.all().order_by('nom')
    # Nombre total d'étudiant
    total = len(personnel)
    print(user.resposabilite.libelle)

    context = {
        'user':user,
        'personnel':personnel,
    }
    return render(request, 'drh/personnel/personnel_list.html', context)

