瀏覽代碼

lessons and courses in the future no more appearing

Denis Merigoux 10 年之前
父節點
當前提交
7f97789a43
共有 2 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      census/views.py
  2. 二進制
      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)

二進制
db.sqlite3