소스 검색

Users no more able to post counts for outdated lessons

Denis Merigoux 10 년 전
부모
커밋
5674582ce1
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      census/views.py

+ 2 - 2
census/views.py

@@ -83,7 +83,7 @@ def addcount(request):
83 83
     if request.method == 'POST':
84 84
         # create a form instance and populate it with data from the request:
85 85
         form = addCountForm(request.POST)
86
-        form.fields["lesson"].queryset = Lesson.objects.filter(date__lte=datetime.now()).order_by('-date')
86
+        form.fields["lesson"].queryset = Lesson.objects.filter(date__lte=datetime.now(),date__gte=datetime.now()-datetime.timedelta(30)).order_by('-date')
87 87
         # check whether it's valid:
88 88
         if form.is_valid():
89 89
             count = form.save()
@@ -91,6 +91,6 @@ def addcount(request):
91 91
     # if a GET (or any other method) we'll create a blank form
92 92
     else:
93 93
         form = addCountForm()
94
-        form.fields["lesson"].queryset = Lesson.objects.filter(date__lte=datetime.now()).order_by('-date') 
94
+        form.fields["lesson"].queryset = Lesson.objects.filter(date__lte=datetime.now(),date__gte=datetime.now()-timedelta(30)).order_by('-date') 
95 95
 
96 96
     return render(request, 'addcountTemplate.html', {'form': form})