def handle_checkin_lesson(self, request): self.checkMandatoryParams(request, ['lessonid']) lessonid = request.param_dict['lessonid'] studentid = request.session['studentid'] try: lesson = Lesson.objects.get(id=lessonid) except: return JsonResponse({'retcode': 2, 'reason': 'illegal lessonid'}) starttime = lesson.starttime begin = starttime - timedelta(minutes=10) end = starttime + timedelta(minutes=30) curTime = timezone.now() if curTime < begin: return JsonResponse({'retcode': 2, 'reason': u'签到时间还没有到'}) if curTime > end: return JsonResponse({'retcode': 2, 'reason': u'签到时间已过'}) ret = StudentCheckin.addOne(studentid, lessonid) return JsonResponse(ret)
def handle_list_my_checkinrecords(self, request): self.checkMandatoryParams(request, ['pagenum', 'pagesize']) studentid = request.session['studentid'] pagenum = int(request.param_dict['pagenum']) pagesize = int(request.param_dict['pagesize']) return JsonResponse( StudentCheckin.listRecords_by_student(pagenum, pagesize, request.param_dict, studentid))
def handle_list_lesson_checkins(self, request): self.checkMandatoryParams(request, ['lessonid']) lessonid = request.param_dict['lessonid'] return JsonResponse(StudentCheckin.listRecords_by_lesson(lessonid))