Example #1
0
def update_solution_admininfo(**args):
    token = token_service.get_token(args.get('http_request'))
    has_role = token.has_role('ROLE_MANAGER')

    solution = Solution()
    solution.__dict__ = solution_db.get_solution_by_id(args.get('solutionId'))

    if not has_role:
        raise Exception('403 Forbidden')

    solution.subject1 = args.get('subject1') if args.get('subject1') else ''
    solution.subject2 = args.get('subject2') if args.get('subject2') else ''
    solution.subject3 = args.get('subject3') if args.get('subject3') else ''
    solution.displayOrder = args.get('displayOrder') if args.get(
        'displayOrder') else 0
    solution.modifiedDate = mytime.now()

    solution_db.update_solution_admininfo(solution)
    return 0
Example #2
0
def create_solution(**args):
    token = token_service.get_token(args.get('http_request'))
    if not token.is_valid:
        raise Exception('403 Forbidden')
    user_login = token.username

    solution = Solution()
    solution.__dict__ = args.get('solution')
    if user_login != solution.authorLogin and user_login != 'internal':
        raise Exception('403 Forbidden')

    solution.active = True
    solution.company = ''
    solution.starCount = 0
    solution.viewCount = 0
    solution.downloadCount = 0
    solution.commentCount = 0
    solution.displayOrder = 0
    solution.createdDate = mytime.now()
    solution.modifiedDate = mytime.now()

    solution_id = solution_db.create_solution(solution)

    # 为solution创建描述,其uuid设为与solution的uuid一致。 ----huolongshe
    # description表只能在这里创建
    description = Description()
    description.solutionUuid = solution.uuid
    description.authorLogin = solution.authorLogin
    description.content = r'<p>无内容</p>'
    description_db.create_description(description)

    credit = Credit()
    credit.__dict__ = credit_service.find_user_credit(solution.authorLogin)
    credit_service.do_update_credit(credit, 3,
                                    '创建新模型<{}>'.format(solution.name))

    return solution_id