Beispiel #1
0
 def schedule_for_day(self, user):
     """获取指定周,天的课表"""
     schedules = Schedule.objects.filter(username=user.username,
                                         semester=settings.SEMESTER,
                                         week=current_week(),
                                         day=current_day())
     return self.schedules_to_list(schedules)
 def post(self, request):
     userId = request.POST.get('userId')
     week = request.POST.get('week')
     if is_none_or_empty(userId):
         return EmptyResponse()
     if is_none_or_empty(week) or int(week) < 0:
         week = current_week() - 1
     user = userId2user(userId)
     if user:
         data = teachingOption.info(user, week)
         return SuccessWeekResponse('评教信息获取成功', int(week), data)
     else:
         return UserIdErrorResponse()
Beispiel #3
0
    def schedule_for_tomorrow(self, user):
        """获取明天的课程表"""
        week = current_week()
        day = current_day()

        if day == 7:
            week += 1
            day = 1
        else:
            day += 1
        schedules = Schedule.objects.filter(username=user.username,
                                            semester=settings.SEMESTER,
                                            week=week,
                                            day=day)
        return self.schedules_to_list(schedules)
    def post(self, request):
        userId = request.POST.get('userId')

        if is_none_or_empty(userId):
            return EmptyResponse()

        user = userId2user(userId)
        if user:
            schedules = scheduleOption.schedule_for_tomorrow(user)
            if schedules:
                return SuccessWeekResponse('明日课表获取成功', current_week(),
                                           schedules)
            else:
                return ErrorResponse('明天没有课哦', 2)
        else:
            return UserIdErrorResponse()
Beispiel #5
0
 def info(self, user, week):
     """获取指定周数的评教信息"""
     session = sessionManager.get_session(user.username, user.password)
     response = session.post(url=self.teaching_info, data={'week': week})
     dataInfoTemp = json.loads(response.text).get('data')[0].get('dataInfo')
     dataInfo = []
     for data in dataInfoTemp:
         data['status'] = int(data['status'])
         data['type'] = data['type']  # 返回的类型有字符 不能转换int
         if len(data['core']) > 0:  # 星星处理
             data['core'] = format(float(data['core']), '.1f')
             data['starsArr'] = self.stars_calc(data['core'])
         else:
             data['starsArr'] = [2, 2, 2, 2, 2]
         if int(week) >= current_week():
             data['status'] = 2
         dataInfo.append(data)
     return dataInfo
    def post(self, request):
        userId = request.POST.get('userId')
        week = request.POST.get('week')

        if is_none_or_empty(userId):
            return EmptyResponse()
        if is_none_or_empty(week) or int(week) < 0:
            week = current_week()
        user = userId2user(userId)

        if user:
            schedules = scheduleOption.schedule_for_week(user, week)
            if schedules:
                return SuccessWeekResponse('课表获取成功', week, schedules)
            else:
                return ErrorResponse('这周没有课哦', 2)
        else:
            return UserIdErrorResponse()