コード例 #1
0
ファイル: stories.py プロジェクト: chunkaihuang/Final_Project
def new_story(request, projectID):
    story = Story()
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user, project=project)
    if request.method == 'POST':
        form = StoryForm(request.POST,project=project)
        if form.is_valid():
# <<<<<<< HEAD
            formset = TaskFormSet(request.POST, instance=story)
            if formset.is_valid():
                story = mdl_story.create_story(project, request.POST)
                story = form.save(commit=False)
                formset.instance=story
                formset.save()
                # return redirect('/req/projects/' + projectID)
                # return empty string and do the redirect stuff in front-end
                return HttpResponse('')

# =======
            # story = mdl_story.create_story(project, request.POST)
            # story = form.save(commit=False)
            # if not 'next' in request.POST:
            #     return redirect('/req/projectdetail/' + projectID)
            # else:
            #     next = request.POST['next']
            #     return redirect(next)
# >>>>>>> newfeature-additerationdetail
    else:
        form = StoryForm(project=project)
        formset = TaskFormSet(instance=story)
        formset.extra = 1
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user, project=project)    
    context = {'title' : 'New User Story',
               'form' : form,
               'project': project,
               'association': association,
# <<<<<<< HEAD
#                # 'formset' : formset,
#                'action' : '/req/newstory/' + projectID , 
#                'button_desc' : 'Create User Story',
#                 }
#     return render(request, 'StorySummary.html', context )
# =======
               'formset' : formset,
               'initTasks' : 0,
               'numTasks' : 1,
               'action' : '/req/newstory/' + projectID , 
               'button_desc' : 'Create User Story' }
    return render(request, 'StorySummary.html', context )
コード例 #2
0
def upload_attachment(request, projectID):

    if 'file' not in request.FILES:
        raise IOError("Missing file")
    if request.FILES['file'].size > 10 * 1024 * 1024:
        raise IOError("File too large")

    form = FileForm(request.POST, request.FILES)

    if (form.is_valid()):

        #set up parameters for database insert
        fileObj = request.FILES['file']
        projID = project_api.get_project(projectID)
        fname = fileObj.name
        fileUUID = str(uuid.uuid4())

        #rename file object to have UUID as name to avoid conflicts when retrieving files
        fileObj.name = fileUUID

        f = ProjectFile(file=fileObj,
                        project=projID,
                        name=fname,
                        uuid=fileUUID)
        f.save()
    return redirect(request.POST['referer'])
コード例 #3
0
def iteration(request, projectID, iterationID):
    if project_api.can_user_access_project(request.user.id, projectID):
        projects = project_api.get_projects_for_user(request.user.id)
        project = project_api.get_project(projectID)
        if project == None:
            return redirect('/req/projects')
        association = UserAssociation.objects.get(user=request.user,
                                                  project=project)
        iterations = project_api.get_iterations_for_project(project)
        iteration = project_api.get_iteration(iterationID)
        if iteration != None:
            stories = project_api.get_stories_for_iteration(iteration)
        else:
            stories = project_api.get_stories_with_no_iteration(project)
        context = {
            'projects': projects,
            'project': project,
            'association': association,
            'iterations': iterations,
            'iteration': iteration,
            'stories': stories,
            'owns_project':
            project_api.user_owns_project(request.user, project)
        }
        if iteration == None:
            context['isIceBox'] = True
        return render(request, 'IterationDetail.html', context)
    else:
        # return HttpResponse("You cannot access project " + proj)
        return redirect('/req/projects')
コード例 #4
0
def userStory_list(request):
        projectID = request.GET.get('projectid','')
        serializer_context = {
            'request': request,
        }
        if projectID == '':
            stories = aStory.objects.all()                               
            serializer = userStorySerializer(stories,context=serializer_context, many=True)
            return Response(serializer.data)
    
        project = project_api.get_project(projectID)    
        if request.method == 'GET':
            if projectID == None:
                stories = aStory.objects.all()                               
                serializer = userStorySerializer(stories,context=serializer_context, many=True)
                return JSONResponse(serializer.data)
            #stories = aStory.get_stories_for_project(project
            stories = aStory.objects.filter(project_id=project.id)                               
            serializer = userStorySerializer(stories,context=serializer_context, many=True)
            return JSONResponse(serializer.data)
        elif request.method == 'POST':
            data = JSONParser().parse(request)
            serializer = userStorySerializer(data=data)
            if serializer.is_valid():
                serializer.save()
                return JSONResponse(serializer.data, status=201)
            return JSONResponse(serializer.data, status=400)
コード例 #5
0
def list_users_in_project(request, projectID):
    project = project_api.get_project(projectID)
    if project is None:
        return redirect('/req/projects')
    association = UserAssociation.objects.get(user=request.user,
                                              project=project)
    users = project.users.all()
    pmusers = User.objects.filter(
        project__id=project.id,
        userassociation__role=user_association.ROLE_OWNER)
    devusers = User.objects.filter(
        project__id=project.id,
        userassociation__role=user_association.ROLE_DEVELOPER)
    cliusers = User.objects.filter(
        project__id=project.id,
        userassociation__role=user_association.ROLE_CLIENT)

    context = {
        'project': project,
        'association': association,
        'users': users,
        'pmusers': pmusers,
        'devusers': devusers,
        'cliusers': cliusers,
        'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT),
    }
    return render(request, 'UserList.html', context)
コード例 #6
0
def delete_project(request, projectID):
    project = project_api.get_project(projectID)
    if project is None:
        # return redirect('/req/projects')
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    if request.method == 'POST':
        project_api.delete_project(project)
        # return redirect('/req/projects')
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    else:
        form = ProjectForm(instance=project)

    context = {
        'projects': project_api.get_projects_for_user(request.user.id),
        'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT),
        'title': 'Delete Project',
        'confirm_message':
        'This is an unrevert procedure ! You will lose all information about this project !',
        'form': form,
        'action': '/req/deleteproject/' + projectID,
        'button_desc': 'Delete Project'
    }
    return render(request, 'ProjectSummary.html', context)
コード例 #7
0
def list_users_in_project(request, projectID):
    project = project_api.get_project(projectID)
    if project is None:
        return redirect('/req/projects')
    association = UserAssociation.objects.get(
        user=request.user,
        project=project)
    users = project.users.all()
    pmusers = User.objects.filter(
        project__id=project.id,
        userassociation__role=user_association.ROLE_OWNER)
    devusers = User.objects.filter(
        project__id=project.id,
        userassociation__role=user_association.ROLE_DEVELOPER)
    cliusers = User.objects.filter(
        project__id=project.id,
        userassociation__role=user_association.ROLE_CLIENT)

    context = {
        'project': project,
        'association': association,
        'users': users,
        'pmusers': pmusers,
        'devusers': devusers,
        'cliusers': cliusers,
        'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT),
    }
    return render(request, 'UserList.html', context)
コード例 #8
0
ファイル: iterations.py プロジェクト: jaredmael/Final_Project
def iteration(request, projectID, iterationID):
    if project_api.can_user_access_project(request.user.id, projectID):
        projects = project_api.get_projects_for_user(request.user.id)
        project = project_api.get_project(projectID)
        if project == None:
            return redirect('/req/projects')
        association = UserAssociation.objects.get(user=request.user, project=project)
        iterations = project_api.get_iterations_for_project(project)
        iteration = project_api.get_iteration(iterationID)
        if iteration != None:
            stories = project_api.get_stories_for_iteration(iteration)
        else:
            stories = project_api.get_stories_with_no_iteration(project)
        context = {'projects' : projects,
                   'project' : project,
                   'association' : association,
                   'iterations' : iterations,
                   'iteration' : iteration,
                   'stories' : stories,
                   'owns_project' : project_api.user_owns_project(request.user,project)
                   }
        if iteration == None:
            context['isIceBox'] = True
        return render(request, 'IterationDetail.html', context)
    else:
        # return HttpResponse("You cannot access project " + proj)
        return redirect('/req/projects')
コード例 #9
0
def upload_attachment(request, projectID):
    
    if 'file' not in request.FILES:
        raise IOError("Missing file")
    if request.FILES['file'].size > 10*1024*1024:
        raise IOError("File too large")

    form = FileForm(request.POST, request.FILES)
    
    if(form.is_valid()):
        
        #set up parameters for database insert
        fileObj = request.FILES['file']
        projID = project_api.get_project(projectID)
        fname = fileObj.name
        fileUUID = str(uuid.uuid4())
        
        #rename file object to have UUID as name to avoid conflicts when retrieving files
        fileObj.name=fileUUID
        
        f = ProjectFile(file=fileObj,
                        project=projID,
                        name=fname,
                        uuid=fileUUID)
        f.save()
    return redirect(request.POST['referer'])
コード例 #10
0
def backlog(request, projectID, iterationID):
    if project_api.can_user_access_project(request.user.id, projectID):
        projects = project_api.get_projects_for_user(request.user.id)
        project = project_api.get_project(projectID)
        if project is None:
            return redirect('/req/projects')
        association = UserAssociation.objects.get(
            user=request.user,
            project=project)
        iterations = project_api.get_iterations_for_project(project)
        iteration = project_api.get_iteration(iterationID)
        priorities = Story.PRIORITY_CHOICES
        if iteration is not None:
            stories = project_api.get_stories_for_iteration(iteration)
        else:
            stories = project_api.get_stories_with_no_iteration(project)
        context = {'projects': projects,
                   'project': project,
                   'priorities': priorities,
                   'association': association,
                   'iterations': iterations,
                   'iteration': iteration,
                   'stories': stories,
                   'owns_project': project_api.user_owns_project(request.user, project)
                   }
        return render(request, 'BacklogDetail.html', context)
    else:
        # return HttpResponse("You cannot access project " + proj)
        return redirect('/req/projects')
コード例 #11
0
def backlog(request, projectID, iterationID):
    if project_api.can_user_access_project(request.user.id, projectID):
        projects = project_api.get_projects_for_user(request.user.id)
        project = project_api.get_project(projectID)
        if project is None:
            return redirect('/req/projects')
        association = UserAssociation.objects.get(user=request.user,
                                                  project=project)
        iterations = project_api.get_iterations_for_project(project)
        iteration = project_api.get_iteration(iterationID)
        priorities = Story.PRIORITY_CHOICES
        if iteration is not None:
            stories = project_api.get_stories_for_iteration(iteration)
        else:
            stories = project_api.get_stories_with_no_iteration(project)
        context = {
            'projects': projects,
            'project': project,
            'priorities': priorities,
            'association': association,
            'iterations': iterations,
            'iteration': iteration,
            'stories': stories,
            'owns_project':
            project_api.user_owns_project(request.user, project)
        }
        return render(request, 'BacklogDetail.html', context)
    else:
        # return HttpResponse("You cannot access project " + proj)
        return redirect('/req/projects')
コード例 #12
0
def process_pdf(doc, ProjectID, args):
    try:
        story = []
        styles = get_style_dic()

        project = project_api.get_project(ProjectID)
        make_Project_Statement(story, project)
        add_Line(story)

        story.append(Paragraph("IceBox", styles['iterTitle']))
        make_Stories_Statement(
            story, project_api.get_stories_with_no_iteration(project), args)
        story.append(Paragraph("", styles['iterSpace']))

        iterations = project_api.get_iterations_for_project(project)
        for iteration in iterations:
            make_Iteration_Statement(story, iteration, args)
            make_Stories_Statement(
                story, project_api.get_stories_for_iteration(iteration), args)
            story.append(Paragraph("", styles['iterSpace']))

        if args['pie_chart']:
            story.append(Paragraph("&nbsp;", styles['bigSpace']))
            story.append(
                Paragraph("Stories Number In Iterations", styles['iterTitle']))
            draw_Pie(story, ProjectID)

        doc.build(story)
    except Exception as e:
        return "None8"
コード例 #13
0
def delete_story(request, projectID, storyID):
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user,
                                              project=project)
    story = models.story.get_story(storyID)
    if story is None:
        # return redirect('/req/projectdetail/' + projectID)
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    if request.method == 'POST':
        story.delete()
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')

        # if not 'next' in request.POST:
        #     return redirect('/req/projectdetail/' + projectID)
        # else:
        #     next = request.POST['next']
        #     return redirect(next)
    else:
        form = StoryForm(instance=story, project=project)

    context = {
        'title': 'Delete User Story',
        'confirm_message':
        'This is an irreversible procedure ! You will lose all information about this user story !',
        'project': project,
        'association': association,
        'form': form,
        'action': '/req/deletestory/' + projectID + '/' + storyID,
        'button_desc': 'Delete User Story'
    }

    return render(request, 'StorySummary.html', context)
コード例 #14
0
def process_pdf(doc, ProjectID, args):
    try:
        story = []
        styles = get_style_dic()

        project = project_api.get_project(ProjectID)
        make_Project_Statement(story, project)
        add_Line(story)

        story.append(Paragraph("IceBox", styles['iterTitle']))
        make_Stories_Statement(story, project_api.get_stories_with_no_iteration(project), args)
        story.append(Paragraph("", styles['iterSpace']))

        iterations = project_api.get_iterations_for_project(project)
        for iteration in iterations:
            make_Iteration_Statement(story, iteration, args)
            make_Stories_Statement(story, project_api.get_stories_for_iteration(iteration), args)
            story.append(Paragraph("", styles['iterSpace']))

        if args['pie_chart']:
            story.append(Paragraph("&nbsp;", styles['bigSpace']))
            story.append(Paragraph("Stories Number In Iterations", styles['iterTitle']))
            draw_Pie(story, ProjectID)

        doc.build(story)
    except Exception as e:
        return "None8"
コード例 #15
0
ファイル: stories.py プロジェクト: ayodele1/Final_Project
def delete_story(request, projectID, storyID):
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(
        user=request.user,
        project=project)
    story = models.story.get_story(storyID)
    if story is None:
        # return redirect('/req/projectdetail/' + projectID)
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    if request.method == 'POST':
        story.delete()
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')

        # if not 'next' in request.POST:
        #     return redirect('/req/projectdetail/' + projectID)
        # else:
        #     next = request.POST['next']
        #     return redirect(next)
    else:
        form = StoryForm(instance=story, project=project)

    context = {'title': 'Delete User Story',
               'confirm_message': 'This is an irreversible procedure ! You will lose all information about this user story !',
               'project': project,
               'association': association,
               'form': form,
               'action': '/req/deletestory/' + projectID + '/' + storyID,
               'button_desc': 'Delete User Story'}

    return render(request, 'StorySummary.html', context)
コード例 #16
0
def new_story(request, projectID):
    # story = Story()
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user,
                                              project=project)
    if request.method == 'POST':
        form = StoryForm(request.POST, project=project)
        if form.is_valid():
            # <<<<<<< HEAD
            # formset = TaskFormSet(request.POST, instance=story)
            # if formset.is_valid():
            #     story = models.story.create_story(request.user,
            #                                       project_api.get_project(projectID),
            #                                       request.POST)
            #     formset.instance=story
            #     formset.save()
            #     return redirect('/req/projects/' + projectID)
            # =======
            story = mdl_story.create_story(project, request.POST)
            story = form.save(commit=False)
            if not 'next' in request.POST:
                return redirect('/req/projectdetail/' + projectID)
            else:
                next = request.POST['next']
                return redirect(next)


# >>>>>>> newfeature-additerationdetail
    else:
        form = StoryForm(project=project)
        # formset = TaskFormSet(instance=story)
        # formset.extra = 1
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user,
                                              project=project)
    context = {
        'title': 'New User Story',
        'form': form,
        # 'formset' : formset,
        'project': project,
        'association': association,
        'action': '/req/newstory/' + projectID,
        'button_desc': 'Create User Story',
    }
    return render(request, 'StorySummary.html', context)
コード例 #17
0
def list_iterations_for_project(request, projectID):
    project = project_api.get_project(projectID)
    iterations = mdl_iteration.get_iterations_for_project(project)
    context = {
        'project': project,
        'iterations': iterations,
        'owns_project': project_api.user_owns_project(request.user, project),
    }
    return render(request, 'SideBarIters.html', context)
コード例 #18
0
def list_iterations_for_project(request, projectID):
    project = project_api.get_project(projectID)
    iterations = mdl_iteration.get_iterations_for_project(project)
    context = {
        'project': project,
        'iterations': iterations,
        'owns_project': project_api.user_owns_project(request.user, project),
    }
    return render(request, 'SideBarIters.html', context)
コード例 #19
0
 def userStories(self,request, userName, projectID):
     serializer_context = {
         'request': request,
     }
     
     if userName is not None and projectID is not None:
         project = project_api.get_project(projectID)
         queryset = project_api.get_stories_for_projects(project)
         serializer = userStorySerializer(queryset,context=serializer_context, many=True)
     return Response(serializer.data)
コード例 #20
0
def new_story(request, projectID):
    story = Story()
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user,
                                              project=project)
    if request.method == 'POST':
        form = StoryForm(request.POST, project=project)
        if form.is_valid():
            # <<<<<<< HEAD
            story = form.save(commit=False)
            formset = TaskFormSet(request.POST, instance=story)
            if formset.is_valid():
                story = mdl_story.create_story(project, request.POST)
                formset.instance = story
                formset.save()
                # return redirect('/req/projects/' + projectID)
                # return empty string and do the redirect stuff in front-end
                return HttpResponse('')
        else:
            formset = TaskFormSet(request.POST, instance=story)
            # formset.extra = 1
# =======
# story = mdl_story.create_story(project, request.POST)
# story = form.save(commit=False)
# if not 'next' in request.POST:
#     return redirect('/req/projectdetail/' + projectID)
# else:
#     next = request.POST['next']
#     return redirect(next)
# >>>>>>> newfeature-additerationdetail
    else:
        form = StoryForm(project=project)
        formset = TaskFormSet(instance=story)
        formset.extra = 1
    # project = project_api.get_project(projectID)
    # association = UserAssociation.objects.get(user=request.user, project=project)
    context = {
        'title': 'New User Story',
        'form': form,
        'project': project,
        'association': association,
        # <<<<<<< HEAD
        #                # 'formset' : formset,
        #                'action' : '/req/newstory/' + projectID ,
        #                'button_desc' : 'Create User Story',
        #                 }
        #     return render(request, 'StorySummary.html', context )
        # =======
        'formset': formset,
        'initTasks': formset.initial_form_count(),
        'numTasks': formset.total_form_count(),
        'action': '/req/newstory/' + projectID,
        'button_desc': 'Create User Story'
    }
    return render(request, 'StorySummary.html', context)
コード例 #21
0
def get_story_name_list(ProjectID):
    name = ['icebox']
    try:
        project = project_api.get_project(ProjectID)
        iterations = project_api.get_iterations_for_project(project)
        for iteration in iterations:
            name.append(iteration.title)

        return name
    except Exception as e:
        return "None7"
コード例 #22
0
def get_story_name_list(ProjectID):
    name = ['icebox']
    try:
        project = project_api.get_project(ProjectID)
        iterations = project_api.get_iterations_for_project(project)
        for iteration in iterations:
            name.append(iteration.title)

        return name
    except Exception as e:
        return "None7"
def change_user_role(request, projectID, userID):
    # Gets the project, user and role whose IDs have been passed to this view (the role by POST) and passes them on to
    # the project_api method of the same name.
    p = project_api.get_project(projectID)
    user = User.objects.get(id=userID)

    # Get the role that was sent via the dropdown in the form.
    retrieved_role = (request.POST).get('user_role')
    # print retrieved_role # to console for debugging
    project_api.change_user_role(p, user, retrieved_role)
    return redirect('/requirements/projectdetail/' + projectID)
コード例 #24
0
def change_user_role(request, projectID, userID):
    # Gets the project, user and role whose IDs have been passed to this view (the role
    # by POST) and passes them on to the project_api method of the same name.
    project = project_api.get_project(projectID)
    user = User.objects.get(id=userID)
    # print user.username #debug

    # Get the role that was sent via the dropdown in the form.
    retrieved_role = (request.POST).get('user_role')
    # print retrieved_role # to console for debugging
    project_api.change_user_role(project, user, retrieved_role)
    return redirect('/req/projectdetail/' + projectID)
コード例 #25
0
ファイル: stories.py プロジェクト: jaredmael/RequireTracker
def new_story(request, projectID):
    # story = Story()
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user, project=project)
    if request.method == 'POST':
        form = StoryForm(request.POST,project=project)
        if form.is_valid():
# <<<<<<< HEAD
            # formset = TaskFormSet(request.POST, instance=story)
            # if formset.is_valid():
            #     story = models.story.create_story(request.user, 
            #                                       project_api.get_project(projectID), 
            #                                       request.POST)
            #     formset.instance=story
            #     formset.save()
            #     return redirect('/req/projects/' + projectID)
# =======
            story = mdl_story.create_story(project, request.POST)
            story = form.save(commit=False)
            if not 'next' in request.POST:
                return redirect('/req/projectdetail/' + projectID)
            else:
                next = request.POST['next']
                return redirect(next)
# >>>>>>> newfeature-additerationdetail
    else:
        form = StoryForm(project=project)
        # formset = TaskFormSet(instance=story)
        # formset.extra = 1
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user, project=project)    
    context = {'title' : 'New User Story',
               'form' : form,
               # 'formset' : formset,
               'project': project,
               'association': association,
               'action' : '/req/newstory/' + projectID , 
               'button_desc' : 'Create User Story',
                }
    return render(request, 'StorySummary.html', context )
コード例 #26
0
def edit_story(request, projectID, storyID):
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user,
                                              project=project)
    story = mdl_story.get_story(storyID)
    if story is None:
        # return redirect('/req/projectdetail/' + projectID)
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    if request.method == 'POST':
        form = StoryForm(request.POST, instance=story, project=project)
        if form.is_valid():
            # <<<<<<< HEAD
            story = form.save(commit=False)
            formset = TaskFormSet(request.POST, instance=story)

            if formset.is_valid():
                story.save()
                # formset.instance=story
                formset.save()
                # return redirect('/req/projects/' + projectID)
                # return empty string and do the redirect stuff in front-end
                return HttpResponse('')

        else:
            formset = TaskFormSet(request.POST, instance=story)
    else:

        form = StoryForm(instance=story, project=project)
        formset = TaskFormSet(instance=story)
        numTasks = initTasks = mdl_task.get_tasks_for_story(
            story).count()  # story.task_set.count()
        if numTasks == 0:
            numTasks = 1
        else:
            numTasks = numTasks + 1
        formset.extra = 1

    context = {
        'title': 'Edit User Story',
        'project': project,
        'association': association,
        'title': 'Edit User Story',
        'form': form,
        'formset': formset,
        'initTasks': formset.initial_form_count(),
        'numTasks': formset.total_form_count(),
        'action': '/req/editstory/' + projectID + '/' + storyID,
        'button_desc': 'Save Changes'
    }

    return render(request, 'StorySummary.html', context)
コード例 #27
0
def edit_story(request, projectID, storyID):
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(
        user=request.user,
        project=project)
    story = mdl_story.get_story(storyID)
    if story is None:
        # return redirect('/req/projectdetail/' + projectID)
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    if request.method == 'POST':
        form = StoryForm(request.POST, instance=story, project=project)
        if form.is_valid():
            # <<<<<<< HEAD
            story = form.save(commit=False)
            formset = TaskFormSet(request.POST, instance=story)

            if formset.is_valid():
                story.save()
                # formset.instance=story
                formset.save()
                # return redirect('/req/projects/' + projectID)
                # return empty string and do the redirect stuff in front-end
                return HttpResponse('')

        else:
            formset = TaskFormSet(request.POST, instance=story)
    else:

        form = StoryForm(instance=story, project=project)
        formset = TaskFormSet(instance=story)
        numTasks = initTasks = mdl_task.get_tasks_for_story(
            story).count()  # story.task_set.count()
        if numTasks == 0:
            numTasks = 1
        else:
            numTasks = numTasks + 1
        formset.extra = 1


    context = {'title': 'Edit User Story',
               'project': project,
               'association': association,
               'title': 'Edit User Story',
               'form': form,
               'formset': formset,
               'initTasks': formset.initial_form_count(),
               'numTasks': formset.total_form_count(),
               'action': '/req/editstory/' + projectID + '/' + storyID,
               'button_desc': 'Save Changes'}

    return render(request, 'StorySummary.html', context)
コード例 #28
0
def list_iterations_for_project_with_selection(request, projectID, iterationID):
    project = project_api.get_project(projectID)
    iterations = mdl_iteration.get_iterations_for_project(project)
    iteration = mdl_iteration.get_iteration(iterationID)
    context = {
        'project' : project,
        'iterations' : iterations,
        'iteration' : iteration,
        'owns_project' : project_api.user_owns_project(request.user,project),
    }
    if iteration == None:
        context['isIceBox'] = True
    return render(request, 'SideBarIters.html', context)
コード例 #29
0
ファイル: projects.py プロジェクト: jaredmael/Final_Project
def upload_attachment(request, projectID):

    if 'file' not in request.FILES:
        raise IOError("Missing file")
    if request.FILES['file'].size > 1100000:
        raise IOError("File too large")
        
    form = FileForm(request.POST, request.FILES)
    if(form.is_valid()):
        file = request.FILES['file']
        f = ProjectFile(project = project_api.get_project(projectID), file = file, name = file.name)
        f.save()
    return redirect(request.POST['referer'])
コード例 #30
0
def upload_attachment(request, projectID):

    if 'file' not in request.FILES:
        raise IOError("Missing file")
    if request.FILES['file'].size > 1100000:
        raise IOError("File too large")
        
    form = FileForm(request.POST, request.FILES)
    if(form.is_valid()):
        file = request.FILES['file']
        f = ProjectFile(project = project_api.get_project(projectID), file = file, name = file.name)
        f.save()
    return redirect(request.POST['referer'])
コード例 #31
0
def list_iterations_for_project_with_selection(request, projectID,
                                               iterationID):
    project = project_api.get_project(projectID)
    iterations = mdl_iteration.get_iterations_for_project(project)
    iteration = mdl_iteration.get_iteration(iterationID)
    context = {
        'project': project,
        'iterations': iterations,
        'iteration': iteration,
        'owns_project': project_api.user_owns_project(request.user, project),
    }
    if iteration == None:
        context['isIceBox'] = True
    return render(request, 'SideBarIters.html', context)
コード例 #32
0
def edit_story(request, projectID, storyID):
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user,
                                              project=project)
    story = mdl_story.get_story(storyID)
    if story == None: return redirect('/req/projectdetail/' + projectID)
    if request.method == 'POST':
        form = StoryForm(request.POST, instance=story, project=project)
        if form.is_valid():
            # <<<<<<< HEAD
            # story = form.save(commit=False)
            # formset = TaskFormSet(request.POST, instance=story)

            # if formset.is_valid():
            #     story.save()
            #     formset.save()
            #     return redirect('/req/projects/' + projectID)
            # =======
            story = form.save(commit=True)
            if not 'next' in request.POST:
                return redirect('/req/projectdetail/' + projectID)
            else:
                next = request.POST['next']
                return redirect(next)


# >>>>>>> newfeature-additerationdetail
    else:
        form = StoryForm(instance=story, project=project)
        # formset = TaskFormSet(instance=story)
        # if story.task_set.count() == 0: formset.extra = 1

        # test that association and permissions are working
        # print "UserID "+str(request.user.id)+" and ProjectID "+projectID+" and storyID "+storyID
        # can_edit_hours = association.get_permission("EditHours") # should become unnecessary
        # str_edit_hours = str(can_edit_hours)
        # print "In association of user and project, permission EditHours is "+str_edit_hours

    context = {
        'title': 'Edit User Story',
        'project': project,
        'association': association,
        'title': 'Edit User Story',
        'form': form,
        # 'formset' : formset,
        'action': '/req/editstory/' + projectID + '/' + storyID,
        'button_desc': 'Save Changes'
    }

    return render(request, 'StorySummary.html', context)
コード例 #33
0
def get_story_count_list(ProjectID):
    count = []
    try:
        project = project_api.get_project(ProjectID)

        count.append(project_api.get_stories_with_no_iteration(project).count())

        iterations = project_api.get_iterations_for_project(project)
        for iteration in iterations:
            count.append(project_api.get_stories_for_iteration(iteration).count())

        return count
    except Exception as e:
        return "None6"
コード例 #34
0
ファイル: projects.py プロジェクト: jaredmael/RequireTracker
def edit_project(request, projectID):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = ProjectForm(request.POST, instance=project)
        if form.is_valid():
            project = form.save(commit=True)
            return redirect('/req/projects')
    else:
        form = ProjectForm(instance=project)
        
    context = {'projects' : project_api.get_projects_for_user(request.user.id),
               'canOwnProject' : request.user.has_perm(PERMISSION_OWN_PROJECT),
               'title' : 'Edit Project',
               'form' : form, 'action' : '/req/editproject/' + projectID, 'desc' : 'Save Changes'}
    return render(request, 'ProjectSummary.html', context )
コード例 #35
0
ファイル: projects.py プロジェクト: jaredmael/Final_Project
def project(request, projectID):
    project = project_api.get_project(projectID)
    if project == None: return redirect('/req/projects')

    iterations = mdl_iteration.get_iterations_for_project(project)
    association = UserAssociation.objects.get(user=request.user, project=project)

    context = {'projects' : project_api.get_projects_for_user(request.user.id),
               'project' : project,
               'stories' : mdl_story.get_stories_for_project(project),
               'iterations' : iterations,
               'association' : association,
               'canOwnProject' : request.user.has_perm(PERMISSION_OWN_PROJECT),
               }
    return render(request, 'ProjectDetail.html', context)
コード例 #36
0
def project(request, projectID):
    project = project_api.get_project(projectID)
    if project == None: return redirect('/req/projects')

    iterations = mdl_iteration.get_iterations_for_project(project)
    association = UserAssociation.objects.get(user=request.user, project=project)

    context = {'projects' : project_api.get_projects_for_user(request.user.id),
               'project' : project,
               'stories' : mdl_story.get_stories_for_project(project),
               'iterations' : iterations,
               'association' : association,
               'canOwnProject' : request.user.has_perm(PERMISSION_OWN_PROJECT),
               }
    return render(request, 'ProjectDetail.html', context)
コード例 #37
0
def manage_user_association(request, projectID, userID):
    form = SelectAccessLevelForm()
    the_project = project_api.get_project(projectID)
    the_user = User.objects.get(id=userID)
    association = UserAssociation.objects.get(user=the_user, project=the_project)
    role = association.role

    context = {
        'title': 'Change User Access Level',
        'form' : form,
        'project' : the_project,
        'user' : the_user,
        'role' : role,
    }
    return render(request, 'ManageUserAssociation.html', context)
def manage_user_association(request, projectID, userID):
    form = SelectAccessLevelForm()
    p = project_api.get_project(projectID)
    the_user = User.objects.get(id=userID)
    association = UserAssociation.objects.get(user=the_user, project=p)
    role = association.role

    context = {
        'title': 'Change User Access Level',
        'form': form,
        'project': p,
        'user': the_user,
        'role': role,
    }
    return render(request, 'ManageUserAssociation.html', context)
コード例 #39
0
def get_story_count_list(ProjectID):
    count = []
    try:
        project = project_api.get_project(ProjectID)

        count.append(
            project_api.get_stories_with_no_iteration(project).count())

        iterations = project_api.get_iterations_for_project(project)
        for iteration in iterations:
            count.append(
                project_api.get_stories_for_iteration(iteration).count())

        return count
    except Exception as e:
        return "None6"
コード例 #40
0
ファイル: projects.py プロジェクト: jaredmael/Final_Project
def edit_project(request, projectID):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = ProjectForm(request.POST, instance=project)
        if form.is_valid():
            project = form.save(commit=True)
            # return redirect('/req/projects')
            # return empty string and do the redirect stuff in front-end
            return HttpResponse('')
    else:
        form = ProjectForm(instance=project)
        
    context = {'projects' : project_api.get_projects_for_user(request.user.id),
               'canOwnProject' : request.user.has_perm(PERMISSION_OWN_PROJECT),
               'title' : 'Edit Project',
               'form' : form, 'action' : '/req/editproject/' + projectID, 'button_desc' : 'Save Changes'}
    return render(request, 'ProjectSummary.html', context )
コード例 #41
0
def new_iteration(request, projectID):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = IterationForm(request.POST)
        if form.is_valid():
            mdl_iteration.create_iteration(project, request.POST)
            form.save(commit=False)
            return redirect('/req/projectdetail/' + projectID)
    else:
        form = IterationForm()
    context = {
        'title': 'Create New Iteration',
        'action': '/req/newiteration/' + projectID,
        'form': form,
        'button_desc': 'Create'
    }
    return render(request, 'IterationSummary.html', context)
コード例 #42
0
ファイル: projects.py プロジェクト: jaredmael/RequireTracker
def delete_project(request, projectID):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        # form = NewProjectForm(request.POST, instance=project)
        # if form.is_valid():
        #     project = form.save(commit=False)
        models.project_api.delete_project(project.id)
        return redirect('/projects')
    else:
        form = ProjectForm(instance=project)
        
    context = {'projects' : project_api.get_projects_for_user(request.user.id),
               'canOwnProject' : request.user.has_perm(PERMISSION_OWN_PROJECT),
               'title' : 'Delete Project',
               'confirm_message' : 'This is an unrevert procedure ! You will lose all information about this project !',
               'form' : form, 'action' : '/req/deleteproject/' + projectID , 'desc' : 'Delete Project' }
    return render(request, 'ProjectSummary.html', context )
コード例 #43
0
def new_comment(request, storyID, projectID):
    if request.method == 'POST':
        form = AddCommentForm(request.POST)
        if form.is_valid():
            project = project_api.get_project(projectID)
            story = story.get_story(storyID)
            story_comment = models.story_comment.create_story_comment(request.user, story, request.POST)
            story_comment = form.save(commit=False)
            return redirect('/project/' + projectID)
    else:
        form = AddCommentForm()
        
    context = {'title' : 'New Story Comment',
               'form' : form, 
               'action' : '/newcomment/' + storyID , 
               'desc' : 'Create Story Comment' }
    return render(request, 'CommentForm.html', context )
コード例 #44
0
def new_iteration(request, projectID):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = IterationForm(request.POST)
        if form.is_valid():
            mdl_iteration.create_iteration(project,request.POST)
            form.save(commit=False)
            return redirect('/req/projectdetail/' + projectID)
    else:
        form = IterationForm()
    context = {
        'title': 'Create New Iteration',
        'action': '/req/newiteration/' + projectID,
        'form': form,
        'button_desc': 'Create'
    }
    return render(request, 'IterationSummary.html', context)
コード例 #45
0
ファイル: stories.py プロジェクト: jaredmael/RequireTracker
def edit_story(request, projectID, storyID):
    project = project_api.get_project(projectID)
    association = UserAssociation.objects.get(user=request.user, project=project)
    story = mdl_story.get_story(storyID)
    if story == None: return redirect('/req/projectdetail/' + projectID)
    if request.method == 'POST':
        form = StoryForm(request.POST, instance=story, project=project)
        if form.is_valid():
# <<<<<<< HEAD
            # story = form.save(commit=False)
            # formset = TaskFormSet(request.POST, instance=story)
            
            # if formset.is_valid():
            #     story.save()
            #     formset.save()
            #     return redirect('/req/projects/' + projectID)
# =======
            story = form.save(commit=True)
            if not 'next' in request.POST:
                return redirect('/req/projectdetail/' + projectID)
            else:
                next = request.POST['next']
                return redirect(next)
# >>>>>>> newfeature-additerationdetail
    else:
        form = StoryForm(instance=story, project=project)
        # formset = TaskFormSet(instance=story)
        # if story.task_set.count() == 0: formset.extra = 1

        # test that association and permissions are working
        # print "UserID "+str(request.user.id)+" and ProjectID "+projectID+" and storyID "+storyID
        # can_edit_hours = association.get_permission("EditHours") # should become unnecessary
        # str_edit_hours = str(can_edit_hours)
        # print "In association of user and project, permission EditHours is "+str_edit_hours
        
    context = {'title' : 'Edit User Story',
               'project' : project,
               'association' : association,
               'title' : 'Edit User Story',
               'form' : form, 
               # 'formset' : formset,
               'action' : '/req/editstory/' + projectID + '/' + storyID, 
               'button_desc' : 'Save Changes'}
    
    return render(request, 'StorySummary.html', context )
コード例 #46
0
def delete_iteration(request,projectID,iterationID):
    project = project_api.get_project(projectID)
    iteration = mdl_iteration.get_iteration(iterationID)
    if project == None or iteration == None or iteration.project != project:
        return redirect('/req/projectdetail/' + projectID)
    if request.method == "POST":
        iteration.delete()
        return redirect('/req/projectdetail/' + projectID)
    else:
        form = IterationForm(instance=iteration)
    context = {
        'title': 'Edit Iteration',
        'confirm_message': 'This is an irreversible procedure ! You will lose all information about this iteration and stories it contains !',
        'action': '/req/deleteiteration/' + projectID + '/' + iterationID,
        'form': form,
        'button_desc': 'Delete'
    }
    return render(request, 'IterationSummary.html', context)
コード例 #47
0
def delete_iteration(request, projectID, iterationID):
    project = project_api.get_project(projectID)
    iteration = mdl_iteration.get_iteration(iterationID)
    if project == None or iteration == None or iteration.project != project:
        return redirect('/req/projectdetail/' + projectID)
    if request.method == "POST":
        iteration.delete()
        return redirect('/req/projectdetail/' + projectID)
    else:
        form = IterationForm(instance=iteration)
    context = {
        'title': 'Edit Iteration',
        'confirm_message':
        'This is an irreversible procedure ! You will lose all information about this iteration and stories it contains !',
        'action': '/req/deleteiteration/' + projectID + '/' + iterationID,
        'form': form,
        'button_desc': 'Delete'
    }
    return render(request, 'IterationSummary.html', context)
コード例 #48
0
def edit_iteration(request,projectID,iterationID):
    project = project_api.get_project(projectID)
    iteration = mdl_iteration.get_iteration(iterationID)
    if project == None or iteration == None or iteration.project != project:
        return redirect('/req/projectdetail/' + projectID)
    if request.method == "POST":
        form = IterationForm(request.POST, instance=iteration)
        if form.is_valid():
            form.save(commit=True)
            return redirect('/req/projects/' + projectID)
    else:
        form = IterationForm(instance=iteration)
    context = {
        'title': 'Edit Iteration',
        'action': '/req/edititeration/' + projectID + '/' + iterationID,
        'form': form,
        'button_desc': 'Save Changes'
    }
    return render(request, 'IterationSummary.html', context)
コード例 #49
0
def edit_iteration(request, projectID, iterationID):
    project = project_api.get_project(projectID)
    iteration = mdl_iteration.get_iteration(iterationID)
    if project == None or iteration == None or iteration.project != project:
        return redirect('/req/projectdetail/' + projectID)
    if request.method == "POST":
        form = IterationForm(request.POST, instance=iteration)
        if form.is_valid():
            form.save(commit=True)
            return redirect('/req/projects/' + projectID)
    else:
        form = IterationForm(instance=iteration)
    context = {
        'title': 'Edit Iteration',
        'action': '/req/edititeration/' + projectID + '/' + iterationID,
        'form': form,
        'button_desc': 'Save Changes'
    }
    return render(request, 'IterationSummary.html', context)
コード例 #50
0
def new_iteration(request, projectID):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = IterationForm(request.POST)
        if form.is_valid():
            mdl_iteration.create_iteration(project, request.POST)
            form.save(commit=False)
            # return redirect('/requirements/projectdetail/' + projectID)
            # return empty string and do the redirect stuff in front-end
            return HttpResponse('')
    else:
        form = IterationForm()
    context = {
        'title': 'Create New Iteration',
        'action': '/requirements/newiteration/' + projectID,
        'form': form,
        'button_desc': 'Create',
    }
    return render(request, 'IterationSummary.html', context)
def remove_user_from_project(request, projectID, username):
    p = project_api.get_project(projectID)
    if request.method == 'POST':
        form = SelectAccessLevelForm()
        project_api.remove_user_from_project(projectID, username)
    else:
        form = SelectAccessLevelForm()
    users = p.users.all()
    users = users.exclude(username=request.user.username)

    context = {
        'title': 'Remove User from Project',
        'form': form,
        'project': p,
        'users': users,
        'confirm_message': 'This is an unrevert procedure ! This user will lose the permission to access this project !',
    }

    return render(request, 'UserSummary.html', context)
コード例 #52
0
def remove_user_from_project(request, projectID, username):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = SelectAccessLevelForm()
        project_api.remove_user_from_project(projectID, username)
    else:
        form = SelectAccessLevelForm()
    users = project.users.all()
    users = users.exclude(username=request.user.username)

    context = {
        'title': 'Remove User from Project',
        'form': form,
        'project': project,
        'users': users,
        'confirm_message': 'This is an unrevert procedure ! This user will lose the permission to access this project !',
    }

    return render(request, 'UserSummary.html', context)
コード例 #53
0
def new_comment(request, storyID, projectID):
    if request.method == 'POST':
        form = AddCommentForm(request.POST)
        if form.is_valid():
            project = project_api.get_project(projectID)
            story = story.get_story(storyID)
            story_comment = models.story_comment.create_story_comment(
                request.user, story, request.POST)
            story_comment = form.save(commit=False)
            return redirect('/project/' + projectID)
    else:
        form = AddCommentForm()

    context = {
        'title': 'New Story Comment',
        'form': form,
        'action': '/newcomment/' + storyID,
        'desc': 'Create Story Comment'
    }
    return render(request, 'CommentForm.html', context)
コード例 #54
0
def delete_project(request, projectID):
    project = project_api.get_project(projectID)
    if project is None:
        # return redirect('/req/projects')
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    if request.method == 'POST':
        project_api.delete_project(project)
        # return redirect('/req/projects')
        # return empty string and do the redirect stuff in front-end
        return HttpResponse('')
    else:
        form = ProjectForm(instance=project)

    context = {'projects': project_api.get_projects_for_user(request.user.id),
               'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT),
               'title': 'Delete Project',
               'confirm_message': 'This is an unrevert procedure ! You will lose all information about this project !',
               'form': form, 'action': '/req/deleteproject/' + projectID, 'button_desc': 'Delete Project'}
    return render(request, 'ProjectSummary.html', context)
コード例 #55
0
ファイル: stories.py プロジェクト: jaredmael/RequireTracker
def delete_story(request, projectID, storyID):
    project = project_api.get_project(projectID)
    story = models.story.get_story(storyID)
    if story == None: return redirect('/req/projectdetail/' + projectID)
    if request.method == 'POST':
        story.delete()
        if not 'next' in request.POST:
            return redirect('/req/projectdetail/' + projectID)
        else:
            next = request.POST['next']
            return redirect(next)
    else:
        form = StoryForm(instance=story, project=project)

    context = {'title' : 'Delete User Story',
               'confirm_message' : 'This is an irreversible procedure ! You will lose all information about this user story !',
               'form' : form, 
               'action' : '/req/deletestory/' + projectID + '/' + storyID, 
               'button_desc' : 'Delete User Story' }
    
    return render(request, 'StorySummary.html', context )
コード例 #56
0
def add_user_to_project(request, projectID, username):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = SelectAccessLevelForm(request.POST)
        if form.is_valid():
            user_role = (request.POST).get('user_role', '')
            project_api.add_user_to_project(projectID, username, user_role)
    else:
        form = SelectAccessLevelForm()

    users = user_manager.getActiveUsers()
    for puser in project.users.all():
        users = users.exclude(username=puser.username)
    context = {
        'title': 'Add User to Project',
        'form': form,
        'project': project,
        'users': users,
    }

    return render(request, 'UserSummary.html', context)
コード例 #57
0
def add_user_to_project(request, projectID, username):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        form = SelectAccessLevelForm(request.POST)
        if form.is_valid():
            user_role = (request.POST).get('user_role', '')
            project_api.add_user_to_project(projectID, username, user_role)
    else:
        form = SelectAccessLevelForm()

    users = user_manager.getActiveUsers()
    for puser in project.users.all():
        users = users.exclude(username=puser.username)
    context = {
        'title': 'Add User to Project',
        'form': form,
        'project': project,
        'users': users,
    }

    return render(request, 'UserSummary.html', context)
コード例 #58
0
ファイル: projects.py プロジェクト: jaredmael/RequireTracker
def delete_project(request, projectID):
    project = project_api.get_project(projectID)
    if request.method == 'POST':
        # form = NewProjectForm(request.POST, instance=project)
        # if form.is_valid():
        #     project = form.save(commit=False)
        models.project_api.delete_project(project.id)
        return redirect('/projects')
    else:
        form = ProjectForm(instance=project)

    context = {
        'projects': project_api.get_projects_for_user(request.user.id),
        'canOwnProject': request.user.has_perm(PERMISSION_OWN_PROJECT),
        'title': 'Delete Project',
        'confirm_message':
        'This is an unrevert procedure ! You will lose all information about this project !',
        'form': form,
        'action': '/req/deleteproject/' + projectID,
        'desc': 'Delete Project'
    }
    return render(request, 'ProjectSummary.html', context)