Ejemplo n.º 1
0
    def get(self, request, sid, aid):
        """
        获取协会用户列表
        :param request:
        :param sid:
        :param aid:
        :return:
        """
        # 自动权限检查
        logic = AssociationLogic(self.auth, sid, aid)
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        accounts = AssociationAccount.objects.values(
            'id', 'update_time').filter(association__id=aid)

        if params.has('key'):
            accounts = accounts.filter(
                nickname__contains=params.str('key', desc='关键字'))
        if params.has('role'):
            accounts = accounts.filter(role=params.int('role', desc='身份'))
        if params.has('retire'):
            accounts = accounts.filter(
                retire=params.bool('retire', desc='退休与否'))
        if params.has('department'):
            accounts = accounts.filter(
                department__id=params.int('department', desc='部门id'))

        accounts, pagination = slicer(accounts, limit=limit, page=page)()()
        return Result(accounts=accounts,
                      pagination=pagination,
                      association_id=self.auth.get_association_id())
Ejemplo n.º 2
0
    def get(self, request, sid, cid):
        """
        获取老师对学生评价列表
        :param request:
        :param sid:
        :param cid:
        :return:
        """
        logic = CourseLogic(self.auth, sid, cid)
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        evaluates = PracticeEvaluateTeacherToStudent.objects.filter(
            author=logic.course.author).values('id', 'update_time')
        if params.has('star'):
            evaluates = evaluates.filter(star=params.int('star', desc='星级'))
        if params.has('key'):
            key = params.str('key', desc='关键字')
            evaluates = evaluates.filter(
                Q(student__realname__contains=key)
                | Q(student__code__contains=key))

        evaluates_list, pagination = slicer(evaluates, limit=limit,
                                            page=page)()()
        return SuccessResult(evaluates=evaluates_list, pagination=pagination)
Ejemplo n.º 3
0
    def get(self, request, sid):
        """
        获取课程列表
        :param request:
        :param sid:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        courses = PracticeCourse.objects.filter(school_id=sid).values(
            'id', 'update_time')
        if params.has('name'):
            courses = courses.filter(
                name__contains=params.str('name', desc='名称'))
        if params.has('tag'):
            courses = courses.filter(tag_id=params.int('tag', desc='tagid'))
        if params.has('start_time'):
            courses = courses.filter(
                start_time__gte=params.float('start_time', desc='开始时间'))
        if params.has('end_time'):
            courses = courses.filter(
                end_time__lte=params.float('end_time', desc='结束时间'))

        courses_list, pagination = slicer(courses, limit=limit, page=page)()()
        return SuccessResult(courses=courses_list, pagination=pagination)
Ejemplo n.º 4
0
    def get(self, request):
        """
        获取记录列表
        :param request:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        if self.auth.get_account().role == int(AccountRoleEnum.ADMIN) and \
            params.has('account'):
            _account = FaceUAccount.objects.get_once(
                pk=params.int('account', desc="用户id"))
        else:
            _account = self.auth.get_account()

        record = FaceUDistinguishRecord.objects.filter(author=_account)\
            .values('id', 'update_time', 'group_id').order_by('-create_time')
        if params.has('group'):
            record = record.filter(group_id=params.int('group', desc='分组id'))
        if params.has('start_time'):
            record = record.filter(
                create_time__gte=params.float('start_time', desc='开始时间'))
        if params.has('end_time'):
            record = record.filter(
                create_time__lte=params.float('end_time', desc='结束时间'))
        if params.has('overall'):
            record = record.filter(
                group__isnull=params.bool('overall', desc='全局与否'))
        record_list, pagination = slicer(record, limit=limit, page=page)()()
        return SuccessResult(records=record_list, pagination=pagination)
Ejemplo n.º 5
0
    def get(self, request, sid, cid, aid):
        """
        获取排课考勤
        :param request:
        :param sid:
        :param cid:
        :param aid:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        attendances = PracticeAttendance.objects.filter(
            arrangement_id=aid).values('id', 'update_time')

        if params.has('leaver'):
            attendances = attendances.filter(
                leaver__gte=params.int('leaver', desc='请假次数'))
        if params.has('absent'):
            attendances = attendances.filter(
                absent__gte=params.int('absent', desc='缺勤'))
        if params.has('late'):
            attendances = attendances.filter(
                late__gte=params.int('late', desc='迟到'))
        if params.has('key'):
            attendances = attendances.filter(
                student__realname__contains=params.str('key',
                                                       desc='关键字(学生姓名)'))

        attendance_list, pagination = slicer(attendances,
                                             limit=limit,
                                             page=page)()()
        return SuccessResult(attendances=attendance_list,
                             pagination=pagination)
Ejemplo n.º 6
0
    def get(self, request, sid, aid):
        """
        获取评分表列表
        :param request:
        :param sid:
        :param aid:
        :return:
        """
        logic = AppraisingLogic(self.auth, sid, aid)
        # logic.check(AssociationPermissionEnum.APPRAISING)
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        template = AppraisingScoreTemplate.objects.values(
            'id', 'update_time').filter(association=logic.association)

        if params.has('title'):
            template = template.filter(
                title__contains=params.str('title', desc='标题'))

        templates, pagination = slicer(template, limit=limit, page=page)()()
        return Result(templates=templates,
                      pagination=pagination,
                      association_id=self.auth.get_association_id())
Ejemplo n.º 7
0
    def get(self, request, sid, aid):
        """
        获取报名表列表
        :param request:
        :param sid:
        :param aid:
        :return:
        """
        logic = AssociationLogic(self.auth, sid, aid)
        # logic.check(AssociationPermissionEnum.INTERVIEW)
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        registrations = InterviewRegistration.objects.values(
            'id', 'update_time').filter(association=logic.association)

        if params.has('version'):
            registrations = registrations.filter(
                version=params.int('version', desc='版本号'))
        if params.has('key'):
            key = params.str('key', desc='关键字 报名用户昵称 真实名称')
            registrations = registrations.filter(
                Q(account__nickname__contains=key)
                | Q(account__realname__contains=key))

        registrations, pagination = slicer(registrations,
                                           limit=limit,
                                           page=page)()()
        return Result(registrations=registrations,
                      pagination=pagination,
                      association_id=self.auth.get_association_id())
Ejemplo n.º 8
0
    def get(self, request):
        """
        获取任务列表
        :param request:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        tasks = Task.objects.values('id', 'title', 'task_type', 'stage',
                                    'classification', 'update_time')
        if params.has('task_type'):
            tasks = tasks.filter(
                task_type=params.int('task_type', desc='任务类型'))
        if params.has('stage'):
            stage = params.int('stage', desc='任务阶段')
            if stage == int(TaskStageEnum.RELEASE):
                tasks.exclude(publish_end_time__lte=time.time())
            tasks = tasks.filter(stage=stage)
        if params.has('classification'):
            tasks = tasks.filter(
                classification_id=params.int('classification', desc='分类id'))
        if params.has('title'):
            tasks = tasks.filter(
                title__contains=params.str('title', desc='标题'))

        tasks, pagination = slicer(tasks, limit=limit, page=page)()()
        return SuccessResult(tasks=tasks, pagination=pagination)
Ejemplo n.º 9
0
    def get(self, request, sid, aid):
        """
        获取报名表模板列表
        :param request: 
        :param sid: 
        :param aid: 
        :return: 
        """
        logic = TemplateLogic(self.auth, sid, aid)
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        templates = InterviewRegistrationTemplate.objects.values('id', 'update_time').filter(
            association=logic.association)

        if params.has('key'):
            key = params.str('key', desc='关键字 标题 创建人昵称')
            templates = templates.filter(
                Q(title__contains=key) |
                Q(author__nickname__contains=key)
            )

        templates, pagination = slicer(templates, limit=limit, page=page)()()

        return Result(templates=templates, pagination=pagination, association_id=self.auth.get_association_id())
Ejemplo n.º 10
0
    def get(self, request, sid, cid):
        """
        获取学生对课程评价列表
        :param request:
        :param sid:
        :param cid:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        evaluates = PracticeEvaluateStudentToCourse.objects.filter(
            course_id=cid).values('id', 'update_time')
        if params.has('star'):
            evaluates = evaluates.filter(star=params.int('star', desc='星级'))
        if params.has('key'):
            key = params.str('key', desc='关键字关键字(学生真实名称、学号)弱匹配')
            evaluates = evaluates.filter(
                Q(author__realname__contains=key)
                | Q(author__code__contains=key))

        evaluates_list, pagination = slicer(evaluates, limit=limit,
                                            page=page)()()
        return SuccessResult(evaluates=evaluates_list, pagination=pagination)
Ejemplo n.º 11
0
    def get(self, request):
        """
        获取学校列表
        :param request:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        schools = PracticeSchool.objects.values('id', 'update_time')
        if params.has('name'):
            schools = schools.filter(
                name__contains=params.str('name', desc='学校名称'))

        schools_list, pagination = slicer(schools, limit=limit, page=page)()()
        return SuccessResult(schools=schools_list, pagination=pagination)
Ejemplo n.º 12
0
    def get(self, request):
        """
        获取用户列表
        :param request:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        accounts = FaceUAccount.objects.values('id', 'update_time', 'nickname')
        if params.has('nickname'):
            accounts = accounts.filter(
                nickname__contains=params.str('nickname'))

        account_list, pagination = slicer(accounts, limit=limit, page=page)()()
        return SuccessResult(accounts=account_list, pagination=pagination)
Ejemplo n.º 13
0
    def get(self, request, sid, cid):
        """
        获取排课列表
        :param request:
        :param sid:
        :param cid:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        arrangements = PracticeArrangement.objects.filter(course_id=cid).values('id', 'update_time')
        if params.has('name'):
            arrangements = arrangements.filter(name__contains=params.str('name', desc='名称'))

        arrangements_list, pagination = slicer(arrangements, limit=limit, page=page)()()
        return SuccessResult(arrangements=arrangements_list, pagination=pagination)
Ejemplo n.º 14
0
    def get(self, request, sid, aid=""):
        """
        重置协会码 or 获取协会列表
        :param request:
        :param sid:
        :param aid:
        :return:
        """
        # 重置协会码
        if not self.LIST:
            check_login(lambda x: True)(self)
            logic = AssociationLogic(self.auth, sid, aid)
            # logic.check(AssociationPermissionEnum.ASSOCIATION_VIEW_DATA)

            logic.association.choosing_code = AssociationLogic.elective_code()
            logic.association.save()
            return Result(id=aid)
        # 获取协会列表
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)
        associations = Association.objects.values('id', 'update_time').filter(school__id=sid)

        if params.has('key'):
            key = params.str('key', desc='关键字 名称 缩写')
            try:
                key = int(key)
                associations = associations.filter(
                    Q(name__contains=key) |
                    Q(short_name__contains=key) |
                    Q(id=key)
                )
            except:
                associations = associations.filter(
                    Q(name__contains=key) |
                    Q(short_name__contains=key)
                )

        associations, pagination = slicer(associations, limit=limit, page=page)()()
        return Result(associations=associations, pagination=pagination, association_id=self.auth.get_association_id())
Ejemplo n.º 15
0
    def get(self, request):
        """
        获取用户列表
        :param request:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        accounts = Account.objects.values('id', 'update_time', 'username', 'nickname')
        if params.has('role'):
            accounts = accounts.filter(role=params.int('role', desc='角色'))
        if params.has('key'):
            key = params.str('key', desc='关键字 过滤用户名和昵称', max_length=MAX_USERNAME_LENGTH)
            accounts = accounts.filter(
                Q(username__contains=key) |
                Q(nickname__contains=key)
            )

        account_list, pagination = slicer(accounts, limit=limit, page=page)()()

        return SuccessResult(accounts=account_list, pagination=pagination)
Ejemplo n.º 16
0
    def get(self, request, sid):
        """
        获取学生列表
        :param request:
        :param sid:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        studentuser = PracticeStudentUser.objects.filter(school_id=sid).values(
            'id', 'update_time')
        if params.has('key'):
            studentuser = studentuser.filter(
                Q(realname__contains=params.str('key'))
                | Q(code__contains=params.str('key')))

        studentuser_list, pagination = slicer(studentuser,
                                              limit=limit,
                                              page=page)()()
        return SuccessResult(studentusers=studentuser_list,
                             pagination=pagination)
Ejemplo n.º 17
0
    def get(self, request, sid, aid):
        """
        获取评分列表
        :param request:
        :param sid:
        :param aid:
        :return:
        """
        logic = AppraisingScoreLogic(self.auth, sid, aid)
        # logic.check(AssociationPermissionEnum.APPRAISING)

        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        score = AppraisingScore.objects.values('id', 'update_time').filter(association=logic.association)

        if params.has('author'):
            score = score.filter(author_id=params.int('author', desc='提交人id'))

        if params.has('version'):
            score = score.filter(version=params.int('version', desc='版本号'))

        if params.has('target'):
            score = score.filter(target_id=params.int('target', desc='被评价人id'))

        if params.has('key'):
            key = params.str('key', desc='关键字 提交者昵称 对象昵称')
            score = score.filter(
                Q(author__nickname__contains=key) |
                Q(target__nickname__contains=key)
            )

        scores, pagination = slicer(score, limit=limit, page=page)()()

        return Result(scores=scores, pagination=pagination, association_id=self.auth.get_association_id())
Ejemplo n.º 18
0
    def get(self, request, sid):
        """
        获取学校教室列表
        :param request:
        :param sid:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        classrooms = PracticeClassroom.objects.filter(school_id=sid).values(
            'id', 'update_time')
        if params.has('name'):
            classrooms = classrooms.filter(
                name__contails=params.str('name', desc='教室名称'))
        if params.has('size'):
            classrooms = classrooms.filter(
                size__gte=params.int('size', desc='教室大小'))

        classrooms_list, pagination = slicer(classrooms,
                                             limit=limit,
                                             page=page)()()
        return SuccessResult(classrooms=classrooms_list, pagination=pagination)
Ejemplo n.º 19
0
    def get(self, request):
        """
        获取分组列表
        :param request:
        :return:
        """
        params = ParamsParser(request.GET)
        limit = params.int('limit', desc='每页最大渲染数', require=False, default=10)
        page = params.int('page', desc='当前页数', require=False, default=1)

        groups = FaceUGroups.objects.values('id', 'update_time', 'title')
        if params.has('account') and self.auth.get_account().role == int(
                AccountRoleEnum.ADMIN):
            groups = groups.filter(
                author_id=params.int('account', desc='用户id'))
        else:
            groups = groups.filter(author=self.auth.get_account())

        if params.has('title'):
            groups = groups.filter(
                title__contains=params.str('title', desc='标题'))

        groups_list, pagination = slicer(groups, limit=limit, page=page)()()
        return SuccessResult(groups=groups_list, pagination=pagination)