Пример #1
0
def new_repo(request, sid):
    """
    增加仓库
    :param request:
    :param sid:
    :return:
    """
    wejudge_session = WeJudgeEducationSession(request)      # 创建会话
    response = WeJudgeResponse(wejudge_session)             # 创建响应

    manager = libs.EducationRepositoryController(request, response, sid)
    result = manager.edit_repo()

    return response.json(WeJudgeResult(result))
Пример #2
0
def get_files_map(request, sid, rid):
    """
    获取文件列表
    :param request:
    :param sid:
    :param rid:
    :return:
    """
    wejudge_session = WeJudgeEducationSession(request)      # 创建会话
    response = WeJudgeResponse(wejudge_session)             # 创建响应

    manager = libs.EducationRepositoryController(request, response, sid)
    manager.get_repository(rid)
    result = manager.get_files_map()

    return response.json(WeJudgeResult(result))
Пример #3
0
def get_folders_tree(request, sid, rid):
    """
    获取文件夹列表树(jstree格式)
    :param request:
    :param sid:
    :param rid:
    :return:
    """
    wejudge_session = WeJudgeEducationSession(request)      # 创建会话
    response = WeJudgeResponse(wejudge_session)             # 创建响应

    manager = libs.EducationRepositoryController(request, response, sid)
    manager.get_repository(rid)
    result = manager.get_folders_tree()

    return response.json(result)
Пример #4
0
def repo_delete(request, sid, rid):
    """
    删除文件/文件夹
    :param request:
    :param sid:
    :param rid:
    :return:
    """
    wejudge_session = WeJudgeEducationSession(request)      # 创建会话
    response = WeJudgeResponse(wejudge_session)             # 创建响应

    manager = libs.EducationRepositoryController(request, response, sid)
    manager.get_repository(rid)
    result = manager.repo_delete()

    return response.json(WeJudgeResult(result))
Пример #5
0
def repositories_list(request, sid, cid=None):
    """
    获取学校下的所有仓库列表
    :param request:
    :param sid:
    :param cid:
    :return:
    """
    wejudge_session = WeJudgeEducationSession(request)      # 创建会话
    response = WeJudgeResponse(wejudge_session)             # 创建响应

    manager = libs.EducationRepositoryController(request, response, sid)

    if cid is not None:
        manager.get_course(cid)

    result = manager.get_repositories_list()

    return response.json(WeJudgeResult(result))
Пример #6
0
def repo_info(request, sid, rid):
    """
    获取仓库信息
    :param request:
    :param sid:
    :param rid:
    :return:
    """
    wejudge_session = WeJudgeEducationSession(request)      # 创建会话
    response = WeJudgeResponse(wejudge_session)             # 创建响应

    manager = libs.EducationRepositoryController(request, response, sid)
    manager.get_repository(rid)
    result = manager.repository.json(items=[
        'id', 'title', 'author', 'author__id', 'author__nickname',
        'author__realname', 'public_level', 'cur_size',
    ])

    return response.json(WeJudgeResult(result))
Пример #7
0
def repository(request, sid, rid):

    wejudge_session = WeJudgeEducationSession(request)  # 创建会话
    response = WeJudgeResponse(wejudge_session)         # 创建响应

    manager = libs.EducationRepositoryController(request, response, sid)
    manager.get_repository(rid)
    manager.check_repo_visit_privilege()

    response.set_navlist([
        const.apps.EDUCATION,
        [manager.school.name, 'education.school', (manager.school.id,)],
        ['教学资源仓库', 'education.school.repository', (manager.school.id,)],
        [manager.repository.title]
    ])

    return response.render_page(request, 'education/repository/repository.tpl', {
        "school": manager.school,
        "repository": manager.repository,
        "page_name": "REPOSITORY"
    })