예제 #1
0
파일: views.py 프로젝트: 13accus/PMbook
def ri(request, project):

    #creates/edit a risk or issue
    if request.method == 'POST':

        if request.POST.get("risk_or_issue", "")  == "risk":
            Risk_id = Risk.objects.filter(project_id=project).filter(risk_id=request.POST.get("id", ""))
            if Risk_id.count() > 0:
                r = Risk_id.get(newest=True)
                r.newest = False
                r.save()
        if request.POST.get("risk_or_issue", "") == "issue":
            Issue_id = Issue.objects.filter(project_id=project).filter(issue_id=request.POST.get("id", ""))
            if Issue_id.count() > 0:
                i = Issue_id.get(newest=True)
                i.newest = False
                i.save()
        

        
        Title = request.POST.get("title", "")
        Category = request.POST.get("category", "")
        Severity = request.POST.get("severity", "")
        Probability = request.POST.get("probability", "")
        Comment = request.POST.get("comment", "")
        Open_date = request.POST.get("open_date", "")
        Close_date = request.POST.get("close_date", "")
        Assigned_to = request.POST.get("assigned_to", "")
        Next_step = request.POST.get("next_step", "")
        External_dependencies = request.POST.get("external_dependencies", "")
        Project_id  = request.POST.get("project_id", "")
        RID = request.POST.get("id", "")
        IID = request.POST.get("id", "")

        #create new risk or issue                                                                                                                          
        if request.POST.get("risk_or_issue", "") == "issue":
            new_issue = Issue(title=Title, category=RI_Category.objects.get(ri_category=Category), severity=Health.objects.get(health=Severity), comment=Comment, project_id=Project_id, 
                              open_date=Open_date, close_date=Close_date, assign_to=Assigned_to, next_step=Next_step, external_dependencies=External_dependencies, issue_id=IID, newest=True)
            new_issue.save()
        if request.POST.get("risk_or_issue", "") == "risk":
            new_risk = Risk(title=Title, category=RI_Category.objects.get(ri_category=Category), severity=Health.objects.get(health=Severity), probability=Level.objects.get(level=Probability), comment=Comment, project_id=Project_id, 
                            open_date=Open_date, close_date=Close_date, assign_to=Assigned_to, next_step=Next_step, external_dependencies=External_dependencies, risk_id=RID, newest=True)
            new_risk.save()
    
    project_id = Project.objects.filter(project_id=project).latest('timestamp').pk
    risk = Risk.objects.filter(project_id=project).filter(newest=True)
    issue = Issue.objects.filter(project_id=project).filter(newest=True)
    p = Project.objects.get(pk=project_id)
    risk_num = risk.count()
    issue_num = issue.count()

    context_instance=RequestContext(request,{
            'p' : p,
            'risk' : risk,
            'issue' : issue,
            'rnum' : risk_num,
            'inum' : issue_num,
        })

    return render_to_response('Models/ritable.html', context_instance)
예제 #2
0
파일: views.py 프로젝트: 13accus/PMbook
def projects(request, project):
    
    #If a new issue has been added, it refreshes the page. In doing so, it adds
    #a new issue. 
    if request.POST.get("type", "")  == "issue":
        Title = request.POST.get("title", "")
        Category = request.POST.get("category", "")
        Severity = request.POST.get("severity", "")
        Comment = request.POST.get("comment", "")
        Open_date = request.POST.get("opendate", "")
        Assigned_to = request.POST.get("assignedto", "")
        Next_step = request.POST.get("next_step", "")
        External_dependencies = request.POST.get("externdepend", "")
        Project_id  = request.POST.get("project_id", "")
        IID = request.POST.get("num", "")
        
        new_issue = Issue(title=Title, category=RI_Category.objects.get(ri_category=Category), 
                        severity=Health.objects.get(health=Severity), comment=Comment,
                        project_id=Project_id, open_date=Open_date, close_date="9999-12-12", 
                        assign_to=Assigned_to, next_step=Next_step, 
                        external_dependencies=External_dependencies, issue_id=IID, newest=True)
        new_issue.save()

    #If a new milestone has been added, it refreshes the page. In doing so,
    #it adds a new milestone. 
    if request.POST.get("type", "")  == "milestone": 
        Title = request.POST.get("title", "")
        Comment = request.POST.get("description", "")
        Project_id  = request.POST.get("project_id", "")
        STATUS = request.POST.get("severity", "")
        Baseline_date = request.POST.get("basedate", "")
        Target_date = request.POST.get("targetdate", "")
        Mile_type = request.POST.get("miletype", "")
        ID = request.POST.get("num", "")
        
    #create new milestone                                                                                                                                                                                    
        new_milestone = Milestone(title=Title, comment=Comment, project_id=Project_id,
                                 status = Status.objects.get(status=STATUS),baseline_date=Baseline_date, 
                                 target_date=Target_date,  mile_type=Mile_type, milestone_id=ID, newest=True)
        new_milestone.save()


    #If a new note has been added, it refreshes the page. In doing so, it adds
    #a new note.     
    if request.POST.get("type", "")  == "note":                                                                                                                                                              
        Title = request.POST.get("title", "")
        Comment = request.POST.get("text", "")
        Project_id  = request.POST.get("project_id", "")
        Date = request.POST.get("date", "")
        ID = request.POST.get("num", "")

    #create new note                                                                                                                                                                                                      
        new_note = Note(title=Title, comment=Comment, project_id=Project_id, date=Date, note_id=ID, newest=True)
        new_note.save()


    #If a new risk has been added, it refreshes the page. In doing so, it adds
    #a new risk. 
    if request.POST.get("type", "")  == "risk":                                                                                                                                                             
        Title = request.POST.get("title", "")
        Category = request.POST.get("category", "")
        Severity = request.POST.get("severity", "")
        Probability = request.POST.get("probability", "")
        Comment = request.POST.get("comment", "")
        Open_date = request.POST.get("opendate", "")
        Assigned_to = request.POST.get("assignedto", "")
        Next_step = request.POST.get("next_step", "")
        External_dependencies = request.POST.get("externdepend", "")
        Project_id  = request.POST.get("project_id", "")
        RID = request.POST.get("num", "")

        new_risk = Risk(title=Title, category=RI_Category.objects.get(ri_category=Category), 
                        probability=Level.objects.get(level=Probability), severity=Health.objects.get(health=Severity), 
                        comment=Comment, project_id=Project_id, open_date=Open_date, close_date="9999-12-12", 
                        assigned_to=Assigned_to, next_step=Next_step, external_dependencies=External_dependencies, risk_id=RID, newest=True)
        new_risk.save()
        

    project_id = Project.objects.filter(project_id=project).latest('timestamp').pk
    p = Project.objects.get(pk=project_id)
    
    #Get issue objects and orders them by date
    issues = Issue.objects.filter(project_id=project).filter(newest=True).order_by('-timestamp')
    issues_recent = issues.filter(timestamp__gt= timezone.now() - datetime.timedelta(days=1))
    
    #Get milestone objects and orders them by date
    milestone = Milestone.objects.filter(project_id=project).filter(newest=True).order_by('-timestamp')
    milestone_recent = milestone.filter(timestamp__gt= timezone.now() - datetime.timedelta(days=1))

    #Get note objects and orders them by date
    note = Note.objects.filter(project_id=project).filter(newest=True).order_by('-timestamp')
    note_recent = note.filter(timestamp__gt= timezone.now() - datetime.timedelta(days=1))

    #Get risk objects and orders them by date
    risk = Risk.objects.filter(project_id=project).filter(newest=True).order_by('-timestamp')
    risk_recent = risk.filter(timestamp__gt= timezone.now() - datetime.timedelta(days=1))

    #Get role objects
    personnel = Personnel.objects.filter(project_id=project).filter(active=True)


    #Get number of items
    issue_num = issues.count()
    milestone_num = milestone.count()
    note_num = note.count()
    risk_num = risk.count()

    #Change status of project if the status is changed from the profile page
    if request.POST.get("status", "") != "":
        status = request.POST.get("status", "")
        p.status = Status.objects.get(status=status)
        p.save()

    gstatus = Status.objects.get(status="Active - Green")
    ystatus = Status.objects.get(status="Active - Yellow")
    rstatus = Status.objects.get(status="Active - Red")
    
    #Gets list of Gate Review dates and similar milestones
    mile_type = Milestone.objects.filter(project_id=p.project_id).exclude(mile_type="Other")
    
    # List of all ri_categories
    category = RI_Category.objects.all()
    
    #  compliance = category.get(ri_category="compliance")
    context_instance=RequestContext(request,
                      {'issues' : issues,
                       'p' : p,
                       'milestone' : milestone,
                       'note' : note,
                       'risk' : risk,
                       'personnel' : personnel,
                       'issues_recent' : issues_recent,
                       'milestone_recent' : milestone_recent,
                       'note_recent' : note_recent,
                       'risk_recent' : risk_recent,
                       'milestone_num' : milestone_num,
                       'note_num' : note_num,
                       'risk_num' : risk_num,
                       'issue_num' : issue_num,
                       'gstatus' : gstatus,
                       'ystatus' : ystatus,
                       'rstatus' : rstatus,
                       'mile_type' : mile_type,
                       'compliance' : category.get(ri_category="Compliance"), 
                       'cost' : category.get(ri_category="Cost"),
                       'dependency' : category.get(ri_category="Dependency"),
                       'info_assurance' :category.get(ri_category="Info Assurance"),
                       'organizational' :category.get(ri_category="Organizational"),
                       'privacy' :category.get(ri_category="Privacy"),
                       'resources' :category.get(ri_category="Resources"),
                       'schedule' :category.get(ri_category="Schedule"),
                       'security' : category.get(ri_category="Security"),
                       'strategic' :category.get(ri_category="Strategic"),
                       'scope' :category.get(ri_category="Scope"),
                       'technical' :category.get(ri_category="Technical"),
                       
                       })

    return render_to_response('Models/profile.html', context_instance)