Ejemplo n.º 1
0
def newrequirement(request):
    content = {}
    adduser(content,request.user)
    if request.method == "POST":
        r = RequirementForm(request.POST)
        if r.is_valid():
            require_name = r.cleaned_data['require_name']
            project = r.cleaned_data['project']
            hardware = r.cleaned_data['hardware']
            software_type = r.cleaned_data['software_type']
            describle = r.cleaned_data['describle']
            details = r.cleaned_data['details']
            only_predev = r.cleaned_data['only_predev']
            need_test = r.cleaned_data['need_test']
            expired_date = r.cleaned_data['expired_date']
            cc = r.cleaned_data['cc']
            executer = r.cleaned_data['executer']
            index=Requirement.objects.all()
            index=index.aggregate(Max("index")).values()[0]
            if index == None:
                index = 1 
            else:
                index += 1
            requirement = Requirement.objects.create(index=index,\
               require_name=require_name,\
               hardware=hardware,\
               software_type=software_type,\
               describle=describle,\
               details=details,\
               project=project,\
               need_test=need_test,\
               only_predev=only_predev,\
               expired_date=expired_date,\
               author=request.user,\
               stat="unlocked")
            requirement.executer = executer
            requirement.cc = cc
            requirement.save()           
            #log 
            stage = u"requirement"
            message = u"requirement was created by %s"%request.user.first_name
            stat = u"unlocked" 
            html = '<a href="/editrequirement/%s/">编辑需求</a> <a href="/viewrequirement/%s/"> 查看需求</a>'%(index,index,)
            log = History(requirement=requirement,stage=stage,stat=stat,message=message,html=html,finished=False)
            log.save()
        else:
            content.update({"requirement":r})
            groups = Group.objects.all()
            content.update({"groups":groups})
            return render_to_response('jforms/newrequirement.html',content)
        content.update({"index":index})
        return render_to_response('jforms/new_successful.html',content)
    r = RequirementForm()
    content.update({"requirement":r})
    groups = Group.objects.all()
    content.update({"groups":groups})
    return render_to_response('jforms/newrequirement.html',content)
Ejemplo n.º 2
0
def predev(request, index):
    content={}
    content.update({"index":index})
    content.update({"username":request.user.first_name})
    groups = Group.objects.all()
    content.update({"groups":groups})
    r = Requirement.objects.filter(index=index)
    r = r[len(r)-1]
    if request.method == "POST":
        j = PreDevelopment.objects.filter(requirement=r) 
        if len(j) != 0:
            d = j[len(j)-1]
            if d.stat == "locked" and d.version is None:
                content.update({"message":"已经锁定,无法再进行修改",})
                return render_to_response("jforms/message.html",content)
        author = request.user
        bg = request.POST.get("bg","")
        design = request.POST.get("design","")
        stat = request.POST.get("stat","unlocked")
        p = PreDevelopment(requirement=r,author=author,bg=bg,design=design,stat=stat)
        p.save()
        #log
        stage = u"predev"
        message = u"predev was edited by %s"%request.user.username
        html = u'<a href="/predev/%s">编辑预研</a>'%(index,)
        log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
        log.save()
        if stat == "locked":
            #log        
            stage = u"predev"
            message = u"predev was locked by %s"%request.user.username
            html = u'<a href="/predevjudge/%s/">新建预研评审</a> <a href="/viewpredev/%s">查看预研</a>'%(index,index)
            log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
            log.save()
            content.update({"message":"本次预研结束"}) 
            return render_to_response("jforms/message.html",content)
        content.update({"message":"本次已经保存,下次可继续进行修改",})
        return render_to_response("jforms/message.html",content)
    
    j = PreDevelopment.objects.filter(requirement=r) 
    if len(j) != 0:
        d = j[len(j)-1]
        if d.ifpass == True:
            content.update({"message":"预研已结束,并且已经通过测试评审",})
            return render_to_response("jforms/message.html",content)
        if d.stat == "locked" and d.version is None:
            content.update({"message":"预研已结束,需求处于后续评审中,无法进行修改",})
            return render_to_response("jforms/message.html",content)
        else:     
            content.update({"dev":d})
    return render_to_response('jforms/predev.html',content)
Ejemplo n.º 3
0
def editrequirement(request, index):
    import sys
    reload(sys)
    sys.setdefaultencoding('utf8')
    content = {}
    content.update({"index":index})
    adduser(content,request.user)
    if request.method == "POST":
        last_r = Requirement.objects.filter(index=index)
        last_stat = last_r[len(last_r)-1].stat
        if last_stat == "prelocked" or last_stat == "locked":
            content.update({"message":u"需求无法进行修改"})
            return render_to_response('jforms/message.html',content)

        r = RequirementForm(request.POST)
        if r.is_valid():
            require_name = r.cleaned_data['require_name']
            project = r.cleaned_data['project']
            hardware = r.cleaned_data['hardware']
            software_type = r.cleaned_data['software_type']
            describle = r.cleaned_data['describle']
            details = r.cleaned_data['details']
            only_predev = r.cleaned_data['only_predev']
            need_test = r.cleaned_data['need_test']
            expired_date = r.cleaned_data['expired_date']
            cc = r.cleaned_data['cc']
            executer = r.cleaned_data['executer']
            stat = request.POST.get('stat','unlocked')
            
            requirement = Requirement.objects.create(index=index,\
               require_name=require_name,\
               hardware=hardware,\
               software_type=software_type,\
               describle=describle,\
               details=details,\
               project=project,\
               need_test=need_test,\
               only_predev=only_predev,\
               expired_date=expired_date,\
               author=request.user,\
               stat=stat)
            requirement.cc = cc
            requirement.executer = executer
            requirement.save()
            #log 
            stage = u"requirement"
            message = u"requirement was edit by %s"%request.user.first_name
            html = '<a href="/editrequirement/%s/">编辑需求</a> <a href="/viewrequirement/%s/"> 查看需求</a>'%(index,index,)
            log = History(requirement=requirement,stage=stage,stat=stat,message=message,html=html,finished=False)
            log.save()

            if stat == "prelocked":
                persons = set()
                persons.add(myboss(request.user))
                persons.add(dept_manager(u"软件部")) 
                if executer is not None and len(executer)!=0 :
                    for i in executer:
                        persons.add(i)
                if project is not None :
                    persons.add(pm(project))
                    if project.sold == True:
                        persons.add(dept_manager(u"市场部")) 
                        persons.add(dept_manager(u"客服部"))
                        persons.add(dept_manager(u"销售部")) 
                for user in persons:
                    rc = RequirementConfirm.objects.create(requirement=requirement,signature=user,signed=False,accept=True)
                    rc.save()
                try:# to mail them to accept
                    message=u"<a href=\"%s/viewrequirement/%s/\"> %s/viewrequirement/%s/</a>"%(settings.SERVER_ROOT,index,settings.SERVER_ROOT,index,)
                    myemail=request.user.email
                    author = request.user.first_name
                    email_to=[]
                    for i in persons:
                        email_to.append(i.email)
                          
                    msg = EmailMessage(u'[%s]请您对软件需求表(%s号:%s)进行需求确认会签'%(author,index,require_name),message, myemail, email_to)
                    msg.content_subtype = "html"
                    msg.send()
                except:
                    pass
                try: 
                    cc.append(centerboss(request.user))
                    cc.append(centerbossof(u"研发中心"))
                    cc.append(centerbossof(u"业务中心"))
                except:
                    pass
                 
                try:# to mail them just to tell them
                    message=u"<a href=\"%s/viewrequirement/%s/\"> %s/viewrequirement/%s/</a>"%(settings.SERVER_ROOT,index,settings.SERVER_ROOT,index,)
                    myemail=request.user.email
                    author = request.user.first_name
                    email_to=[]
                    for i in cc:
                        email_to.append(i.email)
                    msg = EmailMessage(u'[%s]请您知悉软件需求表(%s号:%s)'%(author,index,require_name),message, myemail, email_to)
                    msg.content_subtype = "html"
                    msg.send()
                except:
                    pass
                #log 
                stage = u"requirement"
                message = u"requirement was prelocked"
                stat = u"prelocked" 
                html = '需求确认中 <a href="/viewrequirement/%s/"> 查看需求</a>'%(index,)
                log = History(requirement=requirement,stage=stage,stat=stat,message=message,html=html,finished=False)
                log.save()
            content.update({"message":"本次修改已经保存",})
            return render_to_response('jforms/message.html',content)
        else:
            content.update({"requirement":r})
            groups = Group.objects.all()
            content.update({"groups":groups})
         
            r = Requirement.objects.filter(index=index)
            ancestor = r[0].author
            if len(r)!=0:
                r = r[len(r)-1]
                content.update({"req":r})
            groups = Group.objects.all()
            content.update({"groups":groups})
            if ancestor == request.user:
                content.update({"is_ancestor":"yes"})
            return render_to_response('jforms/editrequirement.html',content)
    
    content.update({"username":request.user.first_name})
    r = Requirement.objects.filter(index=index)
    ancestor = r[0].author
    if len(r)!=0:
        r = r[len(r)-1]
        content.update({"req":r})
    if r.stat == "prelocked" or r.stat=="locked":
        content.update({"message":"需求确认中,无法进行修改"})
        return render_to_response('jforms/message.html',content)
    r = RequirementEditForm(instance=r)
    content.update({"requirement":r})
    groups = Group.objects.all()
    content.update({"groups":groups})
    if ancestor == request.user:
        content.update({"is_ancestor":"yes"})
    return render_to_response('jforms/editrequirement.html',content)
Ejemplo n.º 4
0
def judgerequirementconfirm(request,username, index):
    content={}
    content.update({"index":index})
    content.update({"username":request.user.first_name})
    if request.method == "POST":
        password=request.POST.get("password")
        user = authenticate(username=username, password=password)
        if user is not None:
            r = Requirement.objects.filter(index=index)
            r = r[len(r)-1]
            s = RequireJudgementConfirm.objects.get(requirement=r,user=user)
            s.signed = True
            s.time = datetime.datetime.now()
            s.save()
            s = RequireJudgementConfirm.objects.filter(requirement=r)
            done = True
            for i in s:
                if i.signed == False:
                    done = False
                    break
            if done == True:
                p = RequireJudgement.objects.filter(requirement=r)
                if len(p) != 0:
                    p = p[len(p)-1]
                    p.stat = "locked"
                    p.save()
                    
                    if p.result != "reject":
                        q1 = Q(project=r.project)
                        q2 = Q(p_index__isnull=False)
                        items_of_project = Requirement.objects.filter(q1&q2)
                        if len(items_of_project) == 0:
                            r.p_index = 1
                        else:
                            item = items_of_project[len(items_of_project)-1]
                            r.p_index = item.p_index+1
                        r.save()
  
                    #log
                    stage = u"requirement"
                    message = u"judgement signature done:%s"%p.result
                    stat = p.stat
                    if p.result == "develop":
                        html = u'<a href="/viewrequirement/%s/">查看需求详情</a>'%(index,)
                        log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                        log.save() 
                        stage = "dev"
                        html = u'<a href="/dev/%s/">新建研发</a>'%(index,) 
                        log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                        log.save()
                    elif p.result == "predev":
                        html = u'<a href="/viewrequirement/%s/">查看需求详情</a>'%(index,)
                        log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                        log.save()
                        stage = u"predev"
                        html = u'<a href="/predev/%s/">新建预研</a>'%(index,)
                        log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                        log.save()
                    elif p.result == "reject":
                        html = u'<font color=red>需求评审结束,需求拒绝</font> <a href="/viewrequirement/%s/">查看需求详情</a>'%(index,)
                        log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=True)
                        log.save()

            content.update({"message":"评审会签成功"})
            return render_to_response("jforms/message.html",content);
        else:
            content.update({"message":"未通过验证,会签失败"})
            return render_to_response("jforms/message.html",content);
    
    r = Requirement.objects.filter(index=index)
    r =r[len(r)-1]
    user = User.objects.get(username=username)
    s = RequireJudgementConfirm.objects.get(requirement=r,user=user)
    if s.signed == True:
            content.update({"message":"该用户已经对评审进行会签"})
            return render_to_response("jforms/message.html",content);
     
    return render_to_response('jforms/requirejudementconfirm.html',content)
Ejemplo n.º 5
0
def judgerequirement(request,index):
    content={}
    content.update({"index":index})
    content.update({"username":request.user.first_name})
    if request.method == "POST":
        r = Requirement.objects.filter(index=index)
        if len(r) != 0:
            r=r[len(r)-1]
        exist = True
        last = RequireJudgement.objects.filter(requirement=r)
        if len(last) != 0:
            last = last[len(last)-1]
            if last.stat == "locked" or last.stat == "prelocked":
                content.update({"message":"评审无法进行修改"})
                return render_to_response('jforms/message.html',content)
        else:
            exist = False
        rj = RequireJudgementForm(request.POST)
        if rj.is_valid():
            judgement = rj.cleaned_data["judgement"]
            result = rj.cleaned_data["result"]
            judges = rj.cleaned_data["judges"]
            stat = request.POST.get("stat","unlocked")
            rj = RequireJudgement.objects.create(requirement=r,author=request.user, \
                            judgement=judgement,result=result,stat=stat)
            rj.judges = judges
            rj.save()
            if stat == "prelocked":
                #log
                stage = u"requirement"
                message = u"judgement was prelocked by %s"%request.user.first_name
                html = u'需求评审会签中 <a href="/judgerequirementview/%s/">需求评审详情</a>'%(index,)
                stat = stat 
                log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                log.save()
                #
                persons = set()
                r = Requirement.objects.filter(index=index)
                ancestor = r[0].author
                project = r[len(r)-1].project
                persons.add(myboss(ancestor))
                persons.add(myboss(request.user))
                persons.add(dept_manager("软件部")) 
                if judges is not None and len(judges)!=0 :
                    for i in judges:
                        persons.add(i)
                if project is not None :
                    persons.add(pm(project))
                for user in persons:
                    rc = RequireJudgementConfirm.objects.create(requirement=r[len(r)-1],user=user,signed=False)
                    rc.save()
                #email them
                try :# to mail them to accept
                    message="<a href=\"%s/judgerequirementview/%s/\"> %s/judgerequirementview/%s/</a>"%(settings.SERVER_ROOT,index,settings.SERVER_ROOT,index,)
                    myemail=request.user.email
                    author = request.user.first_name
                    email_to=[]
                    for i in persons:
                        email_to.append(i.email)
                    msg = EmailMessage('[%s]请您对软件需求表(%s号:%s)进行需求评审会签'%(author,index,r[0].require_name),message, myemail, email_to)
                    msg.content_subtype = "html"
                    msg.send()
                except:
                    pass
            
            else:
                if exist == False: 
                    stage = u"requirement"
                    message = u"judgement was created by %s"%request.user.first_name
                    stat = stat 
                    html = u'<a href=/judgerequirement/%s/>编辑需求评审 <a href="/viewrequirement/%s/"> 需求详情</a>'%(index,index,)
                    log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                    log.save()
            content.update({"message":"评审已保存"})
            return render_to_response('jforms/message.html',content)

    r = Requirement.objects.filter(index=index)
    if len(r) != 0:
        r=r[len(r)-1]
    rj = RequireJudgement.objects.filter(requirement=r)
    if len(rj) != 0:
        rj = rj[len(rj)-1]
        content.update({"rj":rj})
        if rj.stat == "locked" or rj.stat == "prelocked":
            content.update({"message":"评审无法进行修改"})
            return render_to_response('jforms/message.html',content)
        rjef = RequireJudgementEditForm(instance=rj)
    else:
        rjef = RequireJudgementEditForm()
    content.update({"rjef":rjef})

    groups = Group.objects.all()
    content.update({"groups":groups})
    
    return render_to_response('jforms/requirejudement.html',content)
Ejemplo n.º 6
0
def editassessment(request,index):
    content={}
    content.update({"index":index})
    content.update({"username":request.user.first_name})
    if request.method == "POST":
        r = Requirement.objects.filter(index=index)
        if len(r)!=0:
            r = r[len(r)-1]
        exist = True
        last = Assessment.objects.filter(requirement=r)
        if len(last) != 0:
            last = last[len(last)-1]
            if last.stat == "locked":
                content.update({"message":"评估无法进行修改"})
                return render_to_response('jforms/message.html',content)
        else:
            exist = False
        ass = AssessmentForm(request.POST)
        if ass.is_valid():
            assessment = ass.cleaned_data["assessment"]
            need_predev = ass.cleaned_data["need_predev"]
            need_test = ass.cleaned_data["need_test"]
            assessor = ass.cleaned_data["assessor"]
            stat = request.POST.get("stat","unlocked")
            ass = Assessment.objects.create(requirement=r,author=request.user, \
                            assessment=assessment, need_test=need_test, need_predev=need_predev,stat=stat)
            ass.assessor = assessor
            ass.save()
            if stat == "locked":
                #log
                stage = u"requirement"
                message = u"assessment was locked by %s"%request.user.first_name
                html = u'<a href="/judgerequirement/%s/">新建需求评审</a> <a href="/viewrequirement/%s/"> 查看需求详情</a>'%(index,index,)
                stat = stat 
                log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                log.save()
            else:
                if exist == False: 
                    stage = u"requirement"
                    message = u"assessment was created by %s"%request.user.first_name
                    stat = stat 
                    html = u'<a href="/editassessment/%s/">编辑需求评估</a> <a href="/viewrequirement/%s/"> 查看需求详情</a>'%(index,index,)
                    log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                    log.save()
                
            content.update({"message":"评估已保存"})
            return render_to_response('jforms/message.html',content)
            
    r = Requirement.objects.filter(index=index)
    if len(r)!=0:
        r = r[len(r)-1]
    content.update({"req":r})
    assessment = Assessment.objects.filter(requirement=r)
    if len(assessment) != 0:
        last = assessment[len(assessment)-1]
        if last.stat == "locked":
            content.update({"message":"评估无法进行修改"})
            return render_to_response('jforms/message.html',content)
    if len(assessment)!=0:
        assessment = assessment[len(assessment)-1]
        content.update({"ass":assessment})
        assessment = AssessmentEditForm(instance=assessment)
    else:
        assessment = AssessmentEditForm()
    content.update({"assessment":assessment})
    groups = Group.objects.all()
    content.update({"groups":groups})
    
    return render_to_response('jforms/editassessment.html',content)
Ejemplo n.º 7
0
def requirementconfirm(request,username,index):
    import sys 
    reload(sys)
    sys.setdefaultencoding('utf8') 
    content = {}
    adduser(content,request.user)
    if request.method == "POST":
        reason = request.POST.get("txt","")
        result = request.POST.get("result","")
        user = User.objects.get(username=username)
        r = Requirement.objects.filter(index=index)
        r = r[len(r)-1]
        rc = RequirementConfirm.objects.get(requirement=r,signature=user)
        if result == "accept":
            rc.accept = True
        else:
            rc.accept = False
            rc.reason = reason
        rc.whosigned = request.user
        rc.time = datetime.datetime.now()
        rc.signed = True
        rc.save()

        rcs = RequirementConfirm.objects.filter(requirement=r)
        done = True
        accept = True
        if len(rcs) != 0:
            for i in rcs:
                if  i.signed == True and i.accept == False :
                    accept = False
                if i.signed == False:
                    done = False
            
            if accept == False: 
                r.stat = "locked"
                r.save()
                #log
                stage = u"requirement"
                message = u"requirement was reject"
                stat = u"aborted"
                html = u'<font color=red>有确认人员拒绝需求<font> <a href="/viewrequirement/%s/"> 查看详情</a>'%(index,)
                log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=True)
                log.save()
            else:
                if done == True:
                    r.stat = "locked"
                    r.save()
                    #log
                    stage = u"requirement"
                    message = u"requirement was accept"
                    stat = u"accept"
                    html = u'<a href="/editassessment/%s/"> 新建风险评估 </a> <a href="/viewrequirement/%s/"> 查看需求详情</a>'%(index,index)
                    log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                    log.save()
        content.update({"message":"需求确认成功!"})
        return render_to_response("jforms/message.html",content);

    user = User.objects.get(username = username)
    if myboss(request.user) != user  and username != request.user.username:
        content.update({"message":"无权进行需求确认并且无权代理此人进行需求确认!"})
        return render_to_response("jforms/message.html",content);
    r = Requirement.objects.filter(index=index)
    r = r[len(r)-1]
    rc = RequirementConfirm.objects.get(requirement=r,signature=user)
    if rc.signed == True:
        if rc.whosigned == rc.signature:
            content.update({"message":"确认已经被用户本人确认"})
            return render_to_response("jforms/message.html",content);
        else:
            content.update({"message":"确认已经由%s代理确认"%(rs.whosigned.first_name,)})
            return render_to_response("jforms/message.html",content)

    if username == request.user.username:
        content.update({"agent":"no"})
    else:
        content.update({"agent":"yes"})
    
    content.update({"username1":username})
    content.update({"index":index})
    return render_to_response('jforms/requirementconfirm.html',content)
Ejemplo n.º 8
0
Archivo: dev.py Proyecto: zjj/django-sw
def devjudgeconfirm(request, username, index):
    content = {}
    content.update({"index": index})
    content.update({"username": request.user.first_name})

    r = Requirement.objects.filter(index=index)
    r = r[len(r) - 1]
    d = Development.objects.filter(requirement=r)
    d = d[len(d) - 1]
    dj = DevJudgement.objects.filter(dev=d)
    dj = dj[len(dj) - 1]
    if request.method == "POST":
        password = request.POST.get("password")
        user = authenticate(username=username, password=password)
        if user is not None:
            djc = DevJudgementConfirm.objects.get(devjudge=dj, user=user)
            djc.signed = True
            djc.time = datetime.datetime.now()
            djc.save()
            s = DevJudgementConfirm.objects.filter(devjudge=dj)
            done = True
            for i in s:
                if i.signed == False:
                    done = False
                    break
            if done == True:
                dj.stat = "locked"
                dj.save()
                # log
                q1 = Q(version__isnull=False)
                q2 = Q(requirement=r)
                ver = Development.objects.filter(q1 & q2)
                if len(ver) == 0:
                    version = ""
                else:
                    version = ver[len(ver) - 1].version + 1

                if dj.result == "test":
                    stage = u"dev"
                    message = u"devjudge done:test"
                    if version == "":
                        html = (
                            u'<a href="/testjudge/%s">新建测试评审</a> <a href="/viewdev/%s">查看研发</a> <a href="/viewdevjudge/%s/">查看研发评审</a>'
                            % (index, index, index)
                        )
                    else:
                        html = (
                            u'<a href="/testjudge/%s">新建测试评审</a> <sup><font color=red>第%s次修正</font></sup> <a href="/viewdev/%s">查看研发</a> \
                                    <a href="/viewdevjudge/%s/">查看研发评审</a> <a href="/history/%s/"><sup> 历史</sup></a>'
                            % (index, version - 1, index, index, index)
                        )
                    log = History(requirement=r, stage=stage, stat=dj.stat, message=message, html=html, finished=False)
                    log.save()

                elif dj.result == "success":
                    stage = u"dev"
                    message = u"devjudge done :success"
                    if version == "":
                        html = (
                            u'<font color=green>研发完成</font> <a href="/viewdev/%s">查看研发</a> <a href="/viewdevjudge/%s/">查看研发评审</a>'
                            % (index, index)
                        )
                    else:
                        html = (
                            u'<font color=green>研发完成</font> <a href="/viewdev/%s">查看研发</a> <a href="/viewdevjudge/%s/">查看研发评审</a> \
                                <a href="/history/%s/"><sup> 历史</sup></a>'
                            % (index, index, index)
                        )
                    stat = dj.result
                    log = History(requirement=r, stage=stage, stat=stat, message=message, html=html, finished=True)
                    log.save()

                elif dj.result == "amend":
                    q1 = Q(version__isnull=False)
                    q2 = Q(requirement=r)
                    last_d = Development.objects.filter(q1 & q2)
                    if len(last_d) == 0:
                        d.version = 1
                        d.ifpass = False
                        d.save()
                    else:
                        last = last_d[len(last_d) - 1]
                        d.version = last.version + 1
                        d.ifpass = False
                        d.save()
                    # log
                    stage = u"dev"
                    version = d.version
                    message = u"devjudge done :amend "
                    html = (
                        u'<a href="/dev/%s/">编辑研发<a> <sup><font color=red>第%s次修正</font></sup> <a href="/history/%s"> <sup>历史</sup> </a>'
                        % (index, version, index)
                    )
                    stat = dj.result
                    log = History(requirement=r, stage=stage, stat=stat, message=message, html=html, finished=False)
                    log.save()

                elif dj.result == "failure":
                    stage = u"dev"
                    message = u"devjudge done :failure "
                    if version == "":
                        html = (
                            u'<font color=green>研发完成</font> <a href="/viewdev/%s">查看研发</a> <a href="/viewdevjudge/%s/">查看研发评审</a>'
                            % (index, index)
                        )
                    else:
                        html = (
                            u'<font color=green>研发完成</font> <a href="/viewdev/%s">查看研发</a> <a href="/viewdevjudge/%s/">查看研发评审</a> \
                                <a href="/history/%s/"><sup> 历史</sup></a>'
                            % (index, index, index)
                        )
                    stat = dj.result
                    log = History(requirement=r, stage=stage, stat=stat, message=message, html=html, finished=True)
                    log.save()

            content.update({"message": "会签成功"})
        else:
            content.update({"message": "密码错误,会签失败"})
        return render_to_response("jforms/message.html", content)

    return render_to_response("jforms/testconfirm.html", content)
Ejemplo n.º 9
0
Archivo: dev.py Proyecto: zjj/django-sw
def dev(request, index):
    content = {}
    content.update({"index": index})
    content.update({"username": request.user.first_name})
    r = Requirement.objects.filter(index=index)
    r = r[len(r) - 1]
    h = History.objects.filter(requirement=r, finished=True)
    if len(h) != 0:
        content.update({"message": "该需求已结束"})
        return render_to_response("jforms/message.html", content)

    if request.method == "POST":
        j = Development.objects.filter(requirement=r)
        if len(j) != 0:
            d = j[len(j) - 1]
            if d.stat == "locked" and d.version is None:
                content.update({"message": "已经锁定,无法再进行修改"})
                return render_to_response("jforms/message.html", content)
        author = request.user
        bg = request.POST.get("bg", "")
        design = request.POST.get("design", "")
        stat = request.POST.get("stat", "unlocked")
        p = Development(requirement=r, author=author, bg=bg, design=design, stat=stat)
        p.save()
        # log
        q1 = Q(version__isnull=False)
        q2 = Q(requirement=r)
        ver = Development.objects.filter(q1 & q2)
        if len(ver) == 0:
            version = ""
        else:
            version = ver[len(ver) - 1].version + 1
        stage = u"dev"
        message = u"dev was edited by %s" % request.user.username
        if version == "":
            html = u'<a href="/dev/%s/">编辑研发<a> <a href="/viewdev/%s">查看研发</a>' % (index, index)
        else:
            html = (
                u'<a href="/dev/%s/">编辑研发<a><sup><font color=red>第%s次修正</font></sup> <a href="/viewdev/%s/">查看研发</a> \
                    <a href="/history/%s/"><sup>历史</sup></a>'
                % (index, version - 1, index, index)
            )
        log = History(requirement=r, stage=stage, stat=stat, message=message, html=html, finished=False)
        log.save()

        if stat == "locked":
            stage = u"dev"
            message = u"dev was locked by %s" % request.user.username
            if version == "":
                html = u'<a href="/devjudge/%s/">新建研发评审</a> <a href="/viewdev/%s">查看研发</a>' % (index, index)
            else:
                html = (
                    u'<a href="/devjudge/%s/">新建研发评审</a> <sup><font color=red>第%s次修正</font></sup> \
                        <a href="/viewdev/%s">查看研发</a> <a href="/history/%s/"><sup>历史</sup></a>'
                    % (index, version - 1, index, index)
                )
            log = History(requirement=r, stage=stage, stat=stat, message=message, html=html, finished=False)
            log.save()
            content.update({"message": "本次研发结束"})
            return render_to_response("jforms/message.html", content)
        content.update({"message": "本次已经保存,下次可继续进行修改"})
        return render_to_response("jforms/message.html", content)

    j = Development.objects.filter(requirement=r)
    if len(j) != 0:
        d = j[len(j) - 1]
        if d.ifpass == True:
            content.update({"message": "研发已结束,并且已经通过测试评审"})
            return render_to_response("jforms/message.html", content)
        if d.stat == "locked" and d.version is None:
            content.update({"message": "研发已结束,需求处于后续评审中,无法进行修改"})
            return render_to_response("jforms/message.html", content)
        else:
            content.update({"dev": d})
    return render_to_response("jforms/dev.html", content)
Ejemplo n.º 10
0
Archivo: dev.py Proyecto: zjj/django-sw
def devjudge(request, index):
    content = {}
    content.update({"index": index})
    content.update({"username": request.user.first_name})
    r = Requirement.objects.filter(index=index)
    r = r[len(r) - 1]

    h = History.objects.filter(requirement=r, finished=True)
    if len(h) != 0:
        content.update({"message": "该需求已结束"})
        return render_to_response("jforms/message.html", content)

    d = Development.objects.filter(requirement=r)
    d = d[len(d) - 1]

    if request.method == "POST":
        dj = DevJudgement.objects.filter(dev=d)
        if len(dj) != 0:
            dj = dj[len(dj) - 1]
            if dj.stat == "prelocked" or dj.stat == "locked":
                content.update({"message": "该编号研发评审已经定稿,无法再次修改"})
                return render_to_response("jforms/message.html", content)

        djf = DevJudgeForm(request.POST)
        if djf.is_valid():
            bg = djf.cleaned_data["bg"]
            testinside = djf.cleaned_data["testinside"]
            judgement = djf.cleaned_data["judgement"]
            result = djf.cleaned_data["result"]
            judges = djf.cleaned_data["judges"]
            stat = request.POST.get("stat", "unlocked")
            dj = DevJudgement.objects.create(
                dev=d, author=request.user, bg=bg, testinside=testinside, judgement=judgement, result=result, stat=stat
            )
            dj.judges = judges
            dj.save()
            # log
            q1 = Q(version__isnull=False)
            q2 = Q(requirement=r)
            ver = Development.objects.filter(q1 & q2)
            if len(ver) == 0:
                version = ""
            else:
                version = ver[len(ver) - 1].version + 1
            stage = u"dev"
            message = u"dev was edited by %s" % request.user.username
            if version == "":
                html = (
                    u'<a href="/devjudge/%s/">编辑研发评审</a> <a href="/viewdevjudge/%s/">查看研发评审</a> <a href="/viewdev/%s">查看研发</a>'
                    % (index, index, index)
                )
            else:
                html = (
                    u'<a href="/devjudge/%s/">编辑研发评审</a> <sup><font color=red>第%s次修正</font></sup> <a href="/viewdevjudge/%s/">查看研发评审</a> \
                        <a href="/viewdev/%s">查看研发</a> <a href="/history/%s/"><sup>历史</sup></a>'
                    % (index, version - 1, index, index, index)
                )
            log = History(requirement=r, stage=stage, stat=stat, message=message, html=html, finished=False)
            log.save()
            if stat == "prelocked":
                persons = set()
                for user in dj.judges.all():
                    persons.add(user)
                try:
                    persons.add(dept_manager("软件部"))
                except:
                    pass
                r = Requirement.objects.filter(index=index)
                ancestor = r[0].author
                project = r[len(r) - 1].project
                persons.add(myboss(ancestor))
                persons.add(pm(project))
                for i in persons:
                    djc = DevJudgementConfirm.objects.create(devjudge=dj, user=i, signed=False)

                stage = u"dev"
                message = u"devjudge was locked by %s" % request.user.username
                if version == "":
                    html = u'研发评审中 <a href="/viewdevjudge/%s/">查看研发评审</a> <a href="/viewdev/%s">查看研发</a>' % (
                        index,
                        index,
                    )
                else:
                    html = (
                        u'研发评审中 <a href="/viewdevjudge/%s/">查看研发评审</a> <a href="/viewdev/%s">查看研发</a> <sup><font color=red>第%s次修正</font></sup> \
                            <a href="/history/%s/"><sup> 历史</sup></a>'
                        % (index, index, version - 1, index)
                    )
                log = History(
                    requirement=r[len(r) - 1], stage=stage, stat=stat, message=message, html=html, finished=False
                )
                log.save()

                try:  # to mail them to confirm
                    message = u'<a href="%s/viewdevjudge/%s/"> %s/viewdevjudge/%s/</a>' % (
                        settings.SERVER_ROOT,
                        index,
                        settings.SERVER_ROOT,
                        index,
                    )
                    myemail = request.user.email
                    author = request.user.first_name
                    email_to = []
                    for i in persons:
                        email_to.append(i.email)
                    msg = EmailMessage(
                        u"[%s]请您对软件需求表(%s号:%s)进行研发评审会签" % (author, index, r[0].require_name), message, myemail, email_to
                    )
                    msg.content_subtype = "html"
                    msg.send()
                except:
                    pass

                content.update({"message": "研发评审已保存,并且已经定稿"})
                return render_to_response("jforms/message.html", content)
            content.update({"message": "研发评审已保存"})
            return render_to_response("jforms/message.html", content)
        else:
            content["devjudge"] = djf
            groups = Group.objects.all()
            content.update({"groups": groups})
            return render_to_response("jforms/devjudge.html", content)

    dj = DevJudgement.objects.filter(dev=d)
    if len(dj) != 0:
        dj = dj[len(dj) - 1]
        content.update({"dj": dj})
        if dj.stat == "prelocked" or dj.stat == "locked":
            content.update({"message": "该编号研发评审已经定稿,无法再次修改"})
            return render_to_response("jforms/message.html", content)
        j = DevJudgeEditForm(instance=dj)
    else:
        j = DevJudgeForm()
    content["devjudge"] = j
    groups = Group.objects.all()
    content.update({"groups": groups})
    return render_to_response("jforms/devjudge.html", content)
Ejemplo n.º 11
0
def predevjudge(request,index):
    content={}
    content.update({"index":index})
    content.update({"username":request.user.first_name})
    groups = Group.objects.all()
    content.update({"groups":groups})
    r = Requirement.objects.filter(index=index)
    r = r[len(r)-1]
    content.update({"req":r})
    ass = Assessment.objects.filter(requirement=r)
    ass = ass[len(ass)-1]
    content.update({"ass":ass})
    d = PreDevelopment.objects.filter(requirement=r)
    d = d[len(d)-1]
    if request.method == "POST":
        last = PreDevJudgement.objects.filter(predev=d)
        if len(last) >0:
            last = last[len(last)-1]
            if last.stat == "prelocked" or last.stat == "locked":
                content.update({"message":"已经锁定,无法再进行修改",})
                return render_to_response("jforms/message.html",content)
            last_testapply = last.testapply
            last_testreport = last.testreport
        else:
            last_testapply = None
            last_report = None
        try:  
            testapply = request.FILES.get("testapply",None)
            if testapply == None:
                testapply = last_testapply
        except:
            pass
        try:
            testreport = request.FILES.get("testreport",None)
            if testreport == None:
                testreport = last_testreport
        except:
            pass
        stat = request.POST.get("stat","unlocked")
        pdjef = PreDevJudgeEditForm(request.POST)
        if pdjef.is_valid():
            pdj = pdjef.save()
            pdj.predev = d
            pdj.testapply = testapply
            pdj.testreport = testreport
            pdj.author = request.user
            pdj.stat = stat
            pdj.save()
            prestat =stat
            if stat == "prelocked" and  r.need_test and r.only_predev or ass.need_test :
                if pdj.testapply.name == "" or pdj.testapply == None: 
                    content.update({"testapply_error":"测试申请单未上传"})
                    stat = "unlocked"
                    pdj.stat = "unlocked"
                    pdj.save()
                if pdj.testreport.name == "" or pdj.testreport == None: 
                    content.update({"testreport_error":"测试申请单未上传"})
                    stat = "unlocked"
                    pdj.stat = "unlocked"
                    pdj.save()
            
            #log
            stage = u"predev"
            message = u"predevjudge was edited by %s"%request.user.username
            html = u'<a href="/predevjudge/%s/">编辑预研评审</a> <a href="/viewpredev/%s">查看预研</a> <a href="/viewpredevjudge/%s/">查看评审详情</a>'%(index,index,index)
            log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
            log.save()
            if prestat != "prelocked":
                content.update({"message":"预研评审已经保存."})
                return render_to_response('jforms/message.html',content)
            if stat == "prelocked":
                persons = set()
                for user in pdj.judges.all():
                    persons.add(user)
                try:
                    persons.add(dept_manager("软件部"))
                    if pdj.testreport :
                        persons.add(dept_manager("测试部"))
                except:
                    pass
                r = Requirement.objects.filter(index=index)
                ancestor = r[0].author
                project = r[len(r)-1].project
                persons.add(myboss(ancestor))
                persons.add(pm(project))
                for i in persons:
                    pdjc = PreDevJudgementConfirm.objects.create(predevjudge=pdj,user=i,signed=False)
                #log
                stage = u"predev"
                message = u"predevjudge was locked by %s"%request.user.username
                html = u'预研评审会签中 <a href="/viewpredev/%s">查看预研</a> <a href="/viewpredevjudge/%s/">查看评审详情</a>'%(index,index)
                log = History(requirement=r[len(r)-1],stage=stage,stat=stat,message=message,html=html,finished=False)
                log.save()

                try :# to mail them to confirm
                    message="<a href=\"%s/viewpredevjudge/%s/\"> %s/viewpredevjudge/%s/</a>"%(settings.SERVER_ROOT,index,settings.SERVER_ROOT,index,)
                    myemail=request.user.email
                    author = request.user.first_name
                    email_to=[]
                    for i in persons:
                        email_to.append(i.email)
                    msg = EmailMessage('[%s]请您对软件需求表(%s号:%s)进行预研评审会签'%(author,index,r[0].require_name),message, myemail, email_to)
                    msg.content_subtype = "html"
                    msg.send()
                except:
                    pass
                content.update({"message":"预研评审已经保存,并已定稿"})
                return render_to_response('jforms/message.html',content)
        else:
            pdj = PreDevJudgement.objects.filter(predev=d)
            if len(pdj) == 0:
                j = PreDevJudgeEditForm()
            else:
                pdj = pdj[len(pdj)-1]
                try:
                    content.update({"testapply_name":pdj.testapply.name.split("/")[-1]})
                    content.update({"testapply_url":pdj.testapply.url})
                except:
                    pass
                try:
                    content.update({"testreport_name":pdj.testreport.name.split("/")[-1]})
                    content.update({"testreport_url":pdj.testreport.url})
                except:
                    pass
            content.update({"predevjudge":pdjef}) 
            return render_to_response('jforms/predev_judge.html',content)
        
    pdj = PreDevJudgement.objects.filter(predev=d)
    if len(pdj) == 0:
        j = PreDevJudgeEditForm()
    else:
        pdj = pdj[len(pdj)-1]
        if pdj.stat == "prelocked" or pdj.stat == "locked":
            content.update({"message":"已经锁定,无法再进行修改",})
            return render_to_response("jforms/message.html",content)
        content.update({"pdj":pdj})
        try:
            content.update({"testapply_name":pdj.testapply.name.split("/")[-1]})
            content.update({"testapply_url":pdj.testapply.url})
        except:
            pass
        try:
            content.update({"testreport_name":pdj.testreport.name.split("/")[-1]})
            content.update({"testreport_url":pdj.testreport.url})
        except:
            pass
        j = PreDevJudgeEditForm(instance=pdj) 
    content["predevjudge"]=j
    groups = Group.objects.all()
    content.update({"groups":groups})
    return render_to_response('jforms/predev_judge.html',content)
Ejemplo n.º 12
0
def predevconfirm(request,username,index):
    content={}
    content.update({"index":index})
    content.update({"username":request.user.first_name})

    r = Requirement.objects.filter(index=index)
    r = r[len(r)-1]
    ass = Assessment.objects.filter(requirement=r)
    ass = ass[len(ass)-1]
    pd = PreDevelopment.objects.filter(requirement=r)
    pd = pd[len(pd)-1]
    pdj = PreDevJudgement.objects.filter(predev=pd)
    pdj = pdj[len(pdj)-1]
    if request.method == "POST":
        password=request.POST.get("password")
        user = authenticate(username=username, password=password)
        if user is not None:
            pdjc = PreDevJudgementConfirm.objects.get(predevjudge=pdj,user=user)
            pdjc.signed = True
            pdjc.time = datetime.datetime.now()
            pdjc.save()
            s = PreDevJudgementConfirm.objects.filter(predevjudge=pdj)
            done = True
            for i in s:
                if i.signed == False:
                    done = False
                    break
            if done == True:
                pdj.stat = "locked"
                pdj.save()
                #log
                if pdj.result == "failure":
                    stage = u"predev"
                    message = u"predevjudge done "
                    html = u'<font color=red>研发放弃</font> <a href="/viewpredev/%s">查看预研</a> <a href="/viewpredevjudge/%s/">查看评审详情</a>'%(index,index)
                    stat = pdj.result 
                    log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=True)
                    log.save()
                elif pdj.result == "success":
                    stage = u"predev"
                    message = u"predevjudge done "
                    html = u'<font color=green>需求完成</font> <a href="/viewpredev/%s">查看预研</a> <a href="/viewpredevjudge/%s/">查看评审详情</a>'%(index,index)
                    stat = pdj.result 
                    log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=True)
                    log.save()
                elif pdj.result == "dev":
                    stage = u"predev"
                    message = u"predevjudge done "
                    html = u'<a href="/viewpredev/%s">查看预研</a> <a href="/viewpredevjudge/%s/">查看评审详情</a>'%(index,index)
                    stat = pdj.result
                    log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                    log.save()
                    stage = u"dev"
                    message = u"predevjudge done"
                    html = u'<a href="/dev/%s">新建研发</a>'%(index,)
                    stat = pdj.stat
                    log = History(requirement=r,stage=stage,stat=stat,message=message,html=html,finished=False)
                    log.save()

            content.update({"message":"会签成功"})
        else:
            content.update({"message":"密码错误,会签失败"})
        return render_to_response('jforms/message.html',content)
 
    return render_to_response('jforms/testconfirm.html',content)