Files
Reskreen/collabs/views.py
Ambulance Clerc efdf44864f avancé dev
2022-03-01 07:09:12 +01:00

35 lines
1.0 KiB
Python

from django.db.models import Sum
from django.shortcuts import render
from django.shortcuts import get_object_or_404, render
from django.http import Http404
from django.http import HttpResponse, HttpResponseRedirect
from django.urls import reverse
from django.views import generic
from collabs.models import *
# Create your views here.
class ExportView(generic.ListView):
model = Collabs_hour
template_name = 'collabs_hour/detail.html'
context_object_name = 'latest_hour_list'
def get_queryset(self):
collabs = Collabs_hour.objects.filter(dtCreated__year=self.kwargs.get("year"), dtCreated__month= self.kwargs.get("month"))
ret = []
last_user = 0
for collab in collabs:
print(f"last_id = {last_user} id={collab.user}")
if last_user != collab.user:
last_user = collab.user
#collab.total = collab.get_total_hour_by_user(self.kwargs.get("year"), self.kwargs.get("month"))
ret.append(collab)
return ret