Exemple #1
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)
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)
Exemple #3
0
def list(request):
	form = NewTaskForm()
	formset = TaskFormSet()
	
	if request.method == "POST":
		if (request.POST['button'] == 'Update!'):
			formset = TaskFormSet(request.POST)
			if formset.is_valid():
				formset.save()
				formset = TaskFormSet()
		else:
			form = NewTaskForm(request.POST)
			if form.is_valid():
				form.save()
				# make sure to return use a clean form for the resulting page
				form = NewTaskForm()

	elif request.method != 'GET':
		raise PermissionDenied('Only GET and POST methods are allowed')

	return render(request, 'todolist/list-view.html', {
    	'tasks': Task.objects.all(),
    	'form': form,
    	'formset': formset
    })
Exemple #4
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('')
# =======
            # story = form.save(commit=True)

            # if not 'next' in request.POST:
            #     return redirect('/req/projectdetail/' + projectID)
            # else:
            #     next = request.POST['next']
            #     return redirect(next)
        else:
            formset = TaskFormSet(request.POST, instance=story)
# >>>>>>> newfeature-additerationdetail
    else:
        # <<<<<<< HEAD
        #         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
        # =======
        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

# >>>>>>> newfeature-TasksFormset

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

    return render(request, 'StorySummary.html', context)
Exemple #5
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('')
# =======
# story = form.save(commit=True)

# if not 'next' in request.POST:
#     return redirect('/req/projectdetail/' + projectID)
# else:
#     next = request.POST['next']
#     return redirect(next)
        else:
            formset = TaskFormSet(request.POST, instance=story)
# >>>>>>> newfeature-additerationdetail
    else:
        # <<<<<<< HEAD
        #         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
        # =======
        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


# >>>>>>> newfeature-TasksFormset

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

    return render(request, 'StorySummary.html', context)
Exemple #6
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)
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)
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():
            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 empty string and do the redirect stuff in front-end
                return HttpResponse('')
        else:
            formset = TaskFormSet(request.POST, instance=story)
    else:
        form = StoryForm(project=project)
        formset = TaskFormSet(instance=story)
        formset.extra = 1
    context = {
        'title': 'New User Story',
        'form': form,
        'project': project,
        'association': association,

        'formset': formset,
        'initTasks': formset.initial_form_count(),
        'numTasks': formset.total_form_count(),
        'action': '/requirements/newstory/' + projectID,
        'button_desc': 'Create User Story'
    }
    return render(request, 'StorySummary.html', context)