Browse Source

lessons and courses in the future no more appearing

Denis Merigoux 11 years ago
parent
commit
7f97789a43
2 changed files with 2 additions and 2 deletions
  1. 2 2
      census/views.py
  2. BIN
      db.sqlite3

+ 2 - 2
census/views.py

18
 		return "danger"
18
 		return "danger"
19
 
19
 
20
 def getCourseStatistics(course):
20
 def getCourseStatistics(course):
21
-	course.lessons = Lesson.objects.filter(course=course).order_by('number')
21
+	course.lessons = Lesson.objects.filter(course=course,date__lte=datetime.today()).order_by('number')
22
 	course.totalsum = 0
22
 	course.totalsum = 0
23
 	course.nonnulllessonscount = 0
23
 	course.nonnulllessonscount = 0
24
 	for lesson in course.lessons:
24
 	for lesson in course.lessons:
56
 
56
 
57
 def home(request):
57
 def home(request):
58
 	#Retrieving the course list and the statistics
58
 	#Retrieving the course list and the statistics
59
-	courses = Course.objects.all().annotate(latest_lesson_date=Max('lesson__date')).order_by('-latest_lesson_date')
59
+	courses = Course.objects.annotate(latest_lesson_date=Max('lesson__date')).filter(latest_lesson_date__lte=datetime.today()).order_by('-latest_lesson_date')
60
 	#courses = Course.objects.all().order_by('-promotion')
60
 	#courses = Course.objects.all().order_by('-promotion')
61
 	for course in courses:
61
 	for course in courses:
62
 		course = getCourseStatistics(course)
62
 		course = getCourseStatistics(course)

BIN
db.sqlite3