def post(self, request): userId = request.POST.get('userId') if is_none_or_empty(userId): return EmptyResponse() user = userId2user(userId) if user: try: userinfo = UserInfo.objects.get(username=user.username) except UserInfo.DoesNotExist: userinfo = None if userinfo: data = { 'username': userinfo.username, 'name': userinfo.name, 'gender': userinfo.gender, 'grade': userinfo.grade, 'college': userinfo.college, 'professional': userinfo.professional, 'classname': userinfo.classname, 'dormitory': userinfo.dormitory, 'number': userinfo.number } return SuccessResponse('获取用户数据成功', data) return ErrorResponse('暂时没有当前用户的信息') else: return UserIdErrorResponse()
def post(self, request): userId = request.POST.get('userId') if is_none_or_empty(userId): return EmptyResponse() user = userId2user(userId) if user: scheduleOption.update_schedule(user) return SuccessResponse('课表更新成功') else: return UserIdErrorResponse()
def post(self, request): loveId = request.POST.get('loveId') if is_none_or_empty(loveId): return EmptyResponse() if len(request.FILES) > 0: file_content = ContentFile(request.FILES['file'].read()) love_image = LoveImage.objects.create(love=Love.objects.get( id=loveId)) love_image.image.save(request.FILES['file'].name, file_content) return SuccessResponse('上传成功', 1)
def post(self, request): userId = request.POST.get('userId') time = request.POST.get('time') if is_none_or_empty(userId, time): return EmptyResponse() user = userId2user(userId) if user: data = resultsOption.query_results(user, time) return SuccessResponse('成绩查询获取成功', data) else: return UserIdErrorResponse()
def post(self, request): areaId = request.POST.get('areaId') architectureId = request.POST.get('architectureId') floorId = request.POST.get('floorId') roomId = request.POST.get('roomId') if is_none_or_empty(areaId, architectureId, floorId, roomId): return EmptyResponse() data = dormitoryOption.query_electricity(areaId, architectureId, floorId, roomId) return SuccessResponse('查询电费成功', data)
def post(self, request): state = request.POST.get('state') userId = request.POST.get('userId') if is_none_or_empty(state, userId): return EmptyResponse() user = userId2user(userId) if user: data = attendanceOption.query_state(user, state) return SuccessResponse('考勤数据获取成功', data) else: return UserIdErrorResponse()
def post(self, request): userId = request.POST.get('userId') time = request.POST.get('time') if is_none_or_empty(userId, time): return EmptyResponse() user = userId2user(userId) if user: data = examOption.query_exam_arrangement(user, time) return SuccessResponse('考试安排查询成功', data) else: return UserIdErrorResponse()
def post(self, request): taskNos = request.POST.get('taskNos') userId = request.POST.get('userId') week = request.POST.get('week') if is_none_or_empty(taskNos, userId, week): return EmptyResponse() user = userId2user(userId) if user: if teachingOption.one_key(user, week, taskNos): return SuccessResponse('一键评教成功') else: return UserIdErrorResponse()
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()
def post(self, request): userId = request.POST.get('userId') if is_none_or_empty(userId): return EmptyResponse() user = userId2user(userId) if user: has_schedule = scheduleOption.exist_schedule_for_semester(user) if has_schedule: return SuccessResponse("本学期已存在课表哦") else: return ErrorResponse('本学期没有导入课表哦', 2) else: return UserIdErrorResponse()
def post(self, request): code = request.POST.get('code') type = int(request.POST.get('type')) if is_none_or_empty(code): return EmptyResponse() if type == 0: openid = self._get_openid(settings.WECHART_APP_ID1, settings.WECHART_APP_SECRET1, code) return self.active_user(openid) elif type == 1: openid = self._get_openid(settings.WECHART_APP_ID2, settings.WECHART_APP_SECRET2, code) return self.active_user(openid) return CodeOverdueResponse()
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()
def post(self, request): userId = request.POST.get('userId') if is_none_or_empty(userId): return EmptyResponse() user = userId2user(userId) if user: if scheduleOption.exist_schedule_for_semester(user): return ErrorResponse('本学期课表已经存在或者正在导入中') scheduleOption.import_schedule(user) # 导入课表 if scheduleOption.exist_schedule_for_semester(user): # 检查课表是否导入成功 return SuccessResponse('导入课表成功') else: return ErrorResponse('导入课表失败') else: return UserIdErrorResponse()
def post(self, request): userId = request.POST.get('userId') nickName = request.POST.get('nickName') avatarUrl = request.POST.get('avatarUrl') gender = request.POST.get('gender') if is_none_or_empty(userId, avatarUrl, gender): return EmptyResponse() user = userId2user(userId) if self.user_exits(user): return SuccessResponse('已存在当前用户数据') else: UserWeChatInfo.objects.create(user=user, nickName=nickName, avatarUrl=avatarUrl, gender=gender) return SuccessResponse('上传微信信息成功')
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()
def post(self, request): userId = request.POST.get('userId') love = request.POST.get('love') if is_none_or_empty(userId, love): return EmptyResponse() user = userId2user(userId) if not user: return UserIdErrorResponse() userWeChatInfo = userId2UserWeChatInfo(userId) if not userWeChatInfo: # 当前用户未授权用户 return ErrorResponse('当前用户未授权微信信息', 2) love = Love.objects.create( user=user, user_weChat_info=userWeChatInfo, content=love, ) return SuccessResponse('发布表白成功,请等待审核哦!', love.id)
def post(self, request): userId = request.POST.get('userId') username = request.POST.get('username') password = request.POST.get('password') if is_none_or_empty(userId, username, password): return EmptyResponse() # 检测用户名和密码是否正确 if userOption.check_username_and_password(username, password): user = userId2user(userId) if user: user.is_active = 1 user.username = username user.password = password user.save() return SuccessResponse('当前用户已激活') return UserIdErrorResponse() else: return ErrorResponse('用户名或密码错误')
def post(self, request): userId = request.POST.get('userId') if is_none_or_empty(userId): return EmptyResponse() user = userId2user(userId) if user: try: user_wechat_info = UserWeChatInfo.objects.get(user=user) except UserWeChatInfo.DoesNotExist: user_wechat_info = None if user_wechat_info: data = { 'avatarUrl': user_wechat_info.avatarUrl, 'gender': user_wechat_info.gender } return SuccessResponse('获取用户数据成功', data) return ErrorResponse('暂时没有当前用户的信息') else: return UserIdErrorResponse()