Exemple #1
0
    def mutate(self, info, discourse_code, review_fail_reason):
        user = get_user(info)
        # if user.role != 'manager':
        #     raise Exception('您没有评审权限')
        conn = utils.get_conn()
        with conn.cursor() as cur:
            cur.execute(
                '''
                update discourse_quata
                set discourse_review_user = %(username)s,
                    review_status = '评审未通过',
                    review_fail_reason = %(review_fail_reason)s,
                    tag_status = '待修改'
                where discourse_code = %(discourse_code)s
                ''',
                dict(
                    discourse_code=discourse_code,
                    review_fail_reason=review_fail_reason,
                    username=user.username,
                )
            )
            if cur.rowcount != 1:
                raise Exception('没有成功更新 discourse_quata 记录状态')

            conn.commit()

        res = update_discourse_status_to_es(discourse_code)
        return NotPassDiscourseReview(status=res['result'], discourse=get_discourse(discourse_code))
Exemple #2
0
    def mutate(self, info, title_ident, review_fail_reason):
        user = get_user(info)
        if user is None:
            raise Exception('此操作需要用户登录')
        # if user.role != 'manager':
        #     raise Exception('您没有评审权限')
        conn = utils.get_conn()
        with conn.cursor() as cur:
            cur.execute(
                '''
                update title_bank
                set label_review_user = %(username)s,
                    label_review_status = '评审未通过',
                    review_fail_reason = %(review_fail_reason)s,
                    label_tag_status = '待修改'
                where title_ident = %(title_ident)s
                ''',
                dict(
                    title_ident=title_ident,
                    review_fail_reason=review_fail_reason,
                    username=user.username,
                )
            )
            if cur.rowcount != 1:
                raise Exception('没有成功更新 title_bank 记录状态')

            conn.commit()

        res = update_question_status_to_es(title_ident)
        return NotPassQuestionDetailReview(status=res['result'], title=get_title(title_ident))
Exemple #3
0
    def mutate(self, info, discourse_code):
        user = get_user(info)
        conn = utils.get_conn()
        with conn.cursor() as cur:
            cur.execute(
                '''
                update discourse_quata
                set discourse_tag_user = %(username)s,
                    tag_status = '已标注'
                where discourse_code = %(discourse_code)s
                and tag_status != '已标注'
                ''',
                dict(discourse_code=discourse_code, username=user.username)
            )
            # if cur.rowcount != 1:
            #     raise Exception('没有成功更新 discourse_quata 记录状态,可能记录已标注')

            conn.commit()

        res = update_discourse_status_to_es(discourse_code)
        return PushDiscourse(status=res['result'], discourse=get_discourse(discourse_code))
Exemple #4
0
    def mutate(self, info, title_ident):
        user = get_user(info)
        conn = utils.get_conn()
        with conn.cursor() as cur:
            cur.execute(
                '''
                update title_bank
                set label_tag_user = %(username)s,
                    label_tag_status = '已标注'
                where title_ident = %(title_ident)s
                and label_tag_status != '已标注'
                ''',
                dict(title_ident=title_ident, username=user.username)
            )
            # if cur.rowcount != 1:
            #     raise Exception('没有成功更新 title_bank 记录状态,可能记录已标注')

            conn.commit()

        res = update_question_status_to_es(title_ident)
        return PushTitle(status=res['result'])
Exemple #5
0
    def mutate(self, info, username, password, email, role):
        user = get_user(info)
        role = json.loads(user.role)
        if role['role'] != 'manager':
            raise Exception('只有管理员可以添加新用户')
        if not (username and password and email and role):
            raise Exception('字段值不可为空')
        if User.objects.filter(username=username).count() > 0:
            raise Exception('username: %s already exists' % username)

        if User.objects.filter(email=email).count() > 0:
            raise Exception('email: %s already exists' % email)

        user = User(
            username=username,
            email=email,
            role=role,
        )
        user.set_password(password)
        user.save()

        return CreateUser(created_user=user)
Exemple #6
0
    def mutate(self, info, title_ident):
        user = get_user(info)
        # if user.role != 'manager':
        #     raise Exception('您没有评审权限')
        conn = utils.get_conn()
        with conn.cursor() as cur:
            cur.execute(
                '''
                update title_bank
                set label_review_user = %(username)s,
                    label_review_status = '评审通过',
                    label_tag_status = '已标注'
                where title_ident = %(title_ident)s
                ''',
                # and label_review_status != '评审通过'
                dict(title_ident=title_ident, username=user.username)
            )
            # if cur.rowcount != 1:
            #     raise Exception('没有成功更新 title_bank 记录状态')

            conn.commit()

        res = update_question_status_to_es(title_ident)
        return PassQuestionDetailReview(status=res['result'], title=get_title(title_ident))
Exemple #7
0
 def resolve_me(self, info):
     user = get_user(info)
     if not user:
         raise Exception('Not logged!')
     return user
Exemple #8
0
 def mutate(self, info, **kwargs):
     user = get_user(info)     # noqa
     title = get_title(kwargs.get('title_ident'))  # noqa
     table_name = 'question_detail'
     res = _mutate(ChangeQuestion, "question", table_name, Question, kwargs, info)
     return res