Exemplo n.º 1
0
def createBranch(projectId):
    '''
    创建分支
    '''
    if projectId:
        return ProjectModule.createBranch(projectId=projectId)
    else:
        return False, ''
Exemplo n.º 2
0
def unarchive(requestInfo):
    '''
    取消归档项目
    '''
    projectId = int(requestInfo['projectId']) if 'projectId' in requestInfo else 0

    if projectId:
        result, message = ProjectModule.unarchive(projectId)
        return result, message
    else:
        return False, '参数错误'
Exemplo n.º 3
0
def delayed(requestInfo):
    '''
    归档项目
    '''
    projectId = int(requestInfo['projectId']) if 'projectId' in requestInfo else 0

    if projectId:
        result, message = ProjectModule.delayed(projectId)
        return result, message
    else:
        return False, '参数错误'
Exemplo n.º 4
0
def archivedProjects(request):
    '''
    已归档的项目
    '''
    q = __buildQuery(archived=True)
    projects, pager = ProjectModule.getProjects(q=q, page=request.GET.get('page', '1'))

    return {
        'projects': projects,
        'pager': pager,
        'project_statuses': PROJECT_STATUS_CLASSES,
        'tab': 'archive',
    }
Exemplo n.º 5
0
def refresh_pg(requestInfo,user):
    '''
    测试环境更新到最新代码
    '''
    projectId = int(requestInfo['projectId'] or 0) if 'projectId' in requestInfo else 0
    remote = requestInfo['remote'] if 'remote' in requestInfo else ''
    fpxx = requestInfo['fpxx'] if 'fpxx' in requestInfo else ''
    if projectId > 0:
        branch_name = ProjectModule.getBranchByPid(projectId)
        result,message,gitOutputs = Git.refresh_pg(branch_name,projectId,fpxx,user,remote)
        return result, message,gitOutputs
    else:
        return False, '参数错误', []
Exemplo n.º 6
0
def modifyOnlineDate(request):
    if request.method == 'GET':
        return render(request, NOT_FOUND_PAGE)

    from_url = request.META['HTTP_REFERER'];
    pid = request.REQUEST.get('pid')
    newDate = request.REQUEST.get('newDate')
    if len(pid) == 0:
        return render(request, NOT_FOUND_PAGE)

    project = ProjectModule.getProject(pid)
    project.onlineDate = newDate
    project.save()
    return HttpResponseRedirect(from_url)
Exemplo n.º 7
0
def myProjects(request):
    '''
    我的项目
    '''
    q = __buildQuery(user=User.objects.get(id=request.user.pk))

    projects, pager = ProjectModule.getProjects(q=q, page=request.GET.get('page', '1'))

    return {
        'projects': projects,
        'pager': pager,
        'project_statuses': PROJECT_STATUS_CLASSES,
        'tab': 'my',
    }
Exemplo n.º 8
0
def projects(request):
    '''
    项目列表
    '''
    searching = True if request.GET.get('q') else False
    q = __buildQuery(query=request.GET.get('q', ''))

    projects, pager = ProjectModule.getProjects(q=q, page=request.GET.get('page', '1'))

    return {
        'projects': projects,
        'pager': pager,
        'project_statuses': PROJECT_STATUS_CLASSES,
        'tab': '' if searching else 'all',
    }
Exemplo n.º 9
0
def pendingProjects(request, type):
    '''
    某段时间上线项目
    '''
    if type not in ['today', 'tomorrow', 'week','delayed']:
        return redirect('/nofound')

    q = __buildQuery(day=type)
    projects, pager = ProjectModule.getProjects(q=q, page=request.GET.get('page', '1'))

    return {
        'projects': projects,
        'pager': pager,
        'project_statuses': PROJECT_STATUS_CLASSES,
        'tab': type,
    }
Exemplo n.º 10
0
def create(request):
    '''
    创建项目
    '''

    if request.method == 'POST':
        form = NewProject(request.POST)
        if form.is_valid():
            projectId = ProjectModule.create(data=form.cleaned_data, user=request.user)
            return redirect("/project/detail/%d#cb" % projectId)
    else:
        form = NewProject(initial={'createPerson': request.user.first_name})

    #多人开发的有效可用pmt主分支
    parent_list = Project.objects.filter(pmtType=2, status__lt=6, type=1)

    return {
        'form': form,
        'parent_list': parent_list,
    }
Exemplo n.º 11
0
def viewDetail(request, projectId):
    '''
    查看详情页
    '''
    project = ProjectModule.getProject(projectId=projectId)
    project.barClass = 'bar-danger' if project.type == 2 else 'bar-normal'
    branch_info = BranchInfo.objects.filter(plist_id=projectId)
    for subproject in project.subprojects:
        subproject.barClass = 'bar-danger' if subproject.type == 2 else 'bar-normal'


    return {
        'branch_name': project.branch_name,
        'project': project,
        'bugs': project.bugs,
        'gitlogs': project.gitlogs,
        'description': project.description,
        'memos': project.memos,
        'staffs': project.relatedPersons,
        'pgurl': project.branch_name+".anjuke.test",
    }
Exemplo n.º 12
0
def merge_to_master(requestInfo):
    """
    """

    branch_name = requestInfo["branchName"] if "branchName" in requestInfo else ""
    branch_name = branch_name.strip()
    branch_type = requestInfo["which"] if "which" in requestInfo else ""
    type1 = requestInfo["type"] if "type" in requestInfo else ""
    print (branch_name)
    start = branch_name.find("-")
    end = start + 6
    branch_id = branch_name[start + 1 : end]
    if "pmt" in branch_name:
        bt = 1
    else:
        bt = 2
    try:
        branch = Project.objects.filter(relatedId=branch_id, type=bt)[0]
        branch_desc = branch.name
        if str(bt) == "1":
            plist_id = branch.id
        else:
            plist_id = 0
        if "(" in branch_desc:
            branch_desc = branch_desc.replace("(", "")
        if ")" in branch_desc:
            branch_desc = branch_desc.replace(")", "")
        if "(" in branch_desc:
            branch_desc = branch_desc.replace("(", "")
        if ")" in branch_desc:
            branch_desc = branch_desc.replace(")", "")
    except:
        branch_desc = ""
    if not branch_name:
        return "请输入分支名"
    #    if branch_type not in branch_name:
    #        message = '分支名:'+branch_name+"当前仓库:"+branch_type+'不匹配。请去对应的页面做操作。'
    #        return message
    if (
        "api" not in branch_type
        and "java" not in branch_type
        and "_chat" not in branch_type
        and "cms" not in branch_type
    ):
        try:
            if_check = BranchDiff.objects.filter(branch_name=branch_name).order_by("-id")[0]
            if_check_status = if_check.status
        except:
            if_check_status = 0
    else:
        if_check_status = 1

    if str(if_check_status) == "1":
        message = Git.mergeToBranch(branch_name, branch_type, branch_desc)
    else:
        message = branch_name + "分支还没被check,请找开发check"

    def sha1(type):
        try:
            shellPath = settings.SHELL_PATH
            opResult = os.popen(shellPath + "get-sha1.sh %s" % (type)).read()
            sha = str(opResult)
            sha1 = sha[0:6]
        except:
            sha1 = "error"
        return sha1

    if message == "合并成功":
        versionList = VersionList(
            version="",
            branch_type=type1,
            branch_name=branch_name,
            title=branch_desc,
            sha1=sha1(branch_type),
            if_on_beta=0,
            if_on_ga=0,
            first_create_ga_generator=0,
            last_create_ga_generator=0,
            status=0,
            back_num=0,
            branch_id=branch_id,
            plist_id=plist_id,
        )
        versionList.save()
        branch_info = BranchInfo.objects.get(branch_name=branch_name)
        branch_info.status = 88
        branch_info.save()
        if str(bt) == "1":
            ProjectModule.updateInfo(plist_id, branch_id)
    print (message)

    return message
Exemplo n.º 13
0
def testCompleted(projectId,user):
    return ProjectModule.testCompleted(projectId,user)