Esempio n. 1
0
def designcreate(request, projectId):
    if projectId == None:
        return render(request, NOT_FOUND_PAGE)
    
    # 判断该项目是否存在 如过不存在 跳转到404页面
    try:
        plist = Project.objects.get(pk=projectId)
    except Project.DoesNotExist:
        return render(request, NOT_FOUND_PAGE)
    
    if request.method == 'GET':#显示创建页面
        try:
            model = Design.objects.get(project=plist)
        except Design.DoesNotExist:
            model = None
        cm = cateModule()
        #获取功能块 DOM
        cateList = cm.getCateListByProjectId(projectId)
        cateListDom = '' if cateList==None else cateList
        topCate = cm.getCateByParentId(0)
        #获取附件
        attachList = DesignAttach.objects.filter(project=plist,status=0)
        return render(request, 'project/design/create.html', {'plist':plist,'design':model,'topCate':topCate, 'cateListDom':cateListDom,'attachList':attachList})
    else: #提交数据
        content = request.REQUEST.get('content')
        complete_flag = DESIGN_FLAG_SAVE if request.REQUEST.get('save_action') != None else DESIGN_FLAG_COMPLETE
        now = time.strftime("%Y-%m-%d %X", time.localtime())
        cm = cateModule()
        try: #更新
            #更新项目设计
            design = Design.objects.get(project=plist)
            design.content = content
            design.updated = now
        except Design.DoesNotExist:#插入
            #插入项目设计
            design = Design(project=plist, content=content, complete=complete_flag, status=0, creater=request.user.id, created=now, updated=now)
        design.save()
        #更新功能块
        catelist = request.REQUEST.getlist('cate')
        if catelist == None:
            pass
        else:#插入功能块:
            cm.replaceProjectCate(projectId,catelist,request.user.id)
        #上传附件
        filelist = request.FILES.getlist('design_files') if 'design_files' in request.FILES else None
        if filelist == None:
            pass
        else:#插入附件:
            cm.createDesignAttach(projectId,filelist,request.user.id)
        return HttpResponseRedirect('/project/design/detail/%d/' % int(projectId))
Esempio n. 2
0
def designdetail(request, projectId):
    if projectId == None:
        return render(request, NOT_FOUND_PAGE)
    try:
        plist = Project.objects.get(pk=projectId)
        design = Design.objects.get(project=plist)
        cm = cateModule()
        cateList = cm.getCateListByProjectId(projectId,False)
        cateListDom = '' if cateList==None else cateList
        #获取附件
        attachList = DesignAttach.objects.filter(project=plist,status=0)
        if design != None:
            return render(request, 'project/design/detail.html', {'design':design,'cateListDom':cateListDom,'attachList':attachList})
    except Project.DoesNotExist:
        return render(request, NOT_FOUND_PAGE)
    return render(request, NOT_FOUND_PAGE)
Esempio n. 3
0
def designdetail(request, projectId):
    if projectId == None:
        return render(request, NOT_FOUND_PAGE)
    try:
        plist = Project.objects.get(pk=projectId)
        design = Design.objects.get(project=plist)
        cm = cateModule()
        cateList = cm.getCateListByProjectId(projectId, False)
        cateListDom = '' if cateList == None else cateList
        #获取附件
        attachList = DesignAttach.objects.filter(project=plist, status=0)
        if design != None:
            return render(
                request, 'project/design/detail.html', {
                    'design': design,
                    'cateListDom': cateListDom,
                    'attachList': attachList
                })
    except Project.DoesNotExist:
        return render(request, NOT_FOUND_PAGE)
    return render(request, NOT_FOUND_PAGE)
Esempio n. 4
0
def designcreate(request, projectId):
    if projectId == None:
        return render(request, NOT_FOUND_PAGE)

    # 判断该项目是否存在 如过不存在 跳转到404页面
    try:
        plist = Project.objects.get(pk=projectId)
    except Project.DoesNotExist:
        return render(request, NOT_FOUND_PAGE)

    if request.method == 'GET':  #显示创建页面
        try:
            model = Design.objects.get(project=plist)
        except Design.DoesNotExist:
            model = None
        cm = cateModule()
        #获取功能块 DOM
        cateList = cm.getCateListByProjectId(projectId)
        cateListDom = '' if cateList == None else cateList
        topCate = cm.getCateByParentId(0)
        #获取附件
        attachList = DesignAttach.objects.filter(project=plist, status=0)
        return render(
            request, 'project/design/create.html', {
                'plist': plist,
                'design': model,
                'topCate': topCate,
                'cateListDom': cateListDom,
                'attachList': attachList
            })
    else:  #提交数据
        content = request.REQUEST.get('content')
        complete_flag = DESIGN_FLAG_SAVE if request.REQUEST.get(
            'save_action') != None else DESIGN_FLAG_COMPLETE
        now = time.strftime("%Y-%m-%d %X", time.localtime())
        cm = cateModule()
        try:  #更新
            #更新项目设计
            design = Design.objects.get(project=plist)
            design.content = content
            design.updated = now
        except Design.DoesNotExist:  #插入
            #插入项目设计
            design = Design(project=plist,
                            content=content,
                            complete=complete_flag,
                            status=0,
                            creater=request.user.id,
                            created=now,
                            updated=now)
        design.save()
        #更新功能块
        catelist = request.REQUEST.getlist('cate')
        if catelist == None:
            pass
        else:  #插入功能块:
            cm.replaceProjectCate(projectId, catelist, request.user.id)
        #上传附件
        filelist = request.FILES.getlist(
            'design_files') if 'design_files' in request.FILES else None
        if filelist == None:
            pass
        else:  #插入附件:
            cm.createDesignAttach(projectId, filelist, request.user.id)
        return HttpResponseRedirect('/project/design/detail/%d/' %
                                    int(projectId))