Пример #1
0
def editRFPC(request, projectNumber, rfpcSlug):

    project = Project.objects.get(projectNumber=projectNumber)
    rfpc = RequestForChange.objects.get(slug=rfpcSlug)
    if request.method == 'POST':
        form = RFPCForm(request.POST, instance=rfpc)
        if form.is_valid():
            t = form.save()
            t.save()
            request.user.message_set.create(message='''RFPC %s Edited''' %
                                            t.slug)
            for change in form.changed_data:
                if change != 'slug':
                    updateLog(
                        request, projectNumber, '%s changed to %s' %
                        (change, eval('''t.%s''' % change)))
            return HttpResponseRedirect('/Projects/%s/RFPC' %
                                        project.projectNumber)
        else:
            pass
    else:
        form = RFPCForm(instance=rfpc)
    return render_to_response('change_management/edit-rfpc.html', {
        'form': form,
        'project': project,
        'rfpc': rfpc
    },
                              context_instance=RequestContext(request))
Пример #2
0
def add_risk(request, project_number):

    # Some security - only allow users to view objects they are allowed to via read_acl
    project = get_object_or_404(Project, project_number=project_number)
    check_project_read_acl(
        project, request.user
    )  # Will return Http404 if user isn't allowed to view project

    if request.method == 'POST':
        form = RiskForm(request.POST)
        if form.is_valid():
            t = form.save(commit=False)
            t.risk_number = '''RISK-%s-%s''' % (
                request.user.username[:2].upper(), time.strftime("%Y%m%d%H%M"))
            t.rating = _calculate_risk(t.probability, t.impact)
            t.save()
            project.risks.add(t)
            project.save()
            request.user.message_set.create(message='''Risk %s Registered''' %
                                            t.risk_number)
            updateLog(request, project.project_number,
                      '''Risk %s Registered''' % t.risk_number)
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #3
0
def edit_deliverable(request, project_number, deliverable_id):

    project = Project.objects.get(project_number=project_number)
    deliverable = Deliverable.objects.get(id=deliverable_id)
    if request.method == "POST":
        form = DeliverableForm(request.POST, instance=deliverable)
        if form.is_valid():
            t = form.save()
            t.save()
            request.user.message_set.create(message="""Deliverable %s Edited""" % t.id)
            for change in form.changed_data:
                updateLog(request, project_number, """%s changed to %s""" % (change, eval("""t.%s""" % change)))
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #4
0
def edit_lesson(request, project_number, lesson_id):

        project = Project.objects.get(project_number=project_number)
        lesson = LessonLearnt.objects.get(id=lesson_id)
        if request.method == 'POST':
                form = LessonForm(request.POST, instance=lesson)
                if form.is_valid():
                        t = form.save()
                        t.save()
                        request.user.message_set.create(message='''Lesson %s Edited''' % t.id)
                        for change in form.changed_data:
                                updateLog(request, project_number, '%s changed to %s' % ( change, eval('''t.%s''' % change)))
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
Пример #5
0
def add_lesson(request, project_number):

        project = Project.objects.get(project_number=project_number)
        lessons = LessonLearnt.objects.filter(project=project)
        if request.method == 'POST':
                form = LessonForm(request.POST)
                if form.is_valid():
                        t = form.save()
                        t.save()
                        project.lessons_learnt.add(t)
                        project.save()
                        request.user.message_set.create(message='''Lesson %s Registered''' % t.id)
                        updateLog(request, project_number, '''Lesson %s Registered''' % t.id)
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
Пример #6
0
def add_issue(request, project_number):

        project = Project.objects.get(project_number=project_number)
        if request.method == 'POST':
                form = IssueForm(request.POST)
                if form.is_valid():
                        t = form.save(commit=False)
                        t.author = request.user
                        t.save()
                        project.issues.add(t)
                        project.save()
                        request.user.message_set.create(message='''Issue %s Registered''' % t.id)
                        updateLog(request, project_number, '''Issue %s Registered''' % t.id)
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
Пример #7
0
def add_deliverable(request, project_number):

    # Some security - only allow users to view objects they are allowed to via read_acl
    project = get_object_or_404(Project, project_number=project_number)
    check_project_read_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
    if request.method == "POST":
        form = DeliverableForm(request.POST)
        if form.is_valid():
            t = form.save()
            t.save()
            project.deliverables.add(t)
            project.save()
            request.user.message_set.create(message="""Deliverable %s Registered""" % t.id)
            updateLog(request, project_number, """Deliverable %s Registered""" % t.id)
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #8
0
def editRFPC(request, projectNumber, rfpcSlug):

	project = Project.objects.get(projectNumber=projectNumber)
	rfpc = RequestForChange.objects.get(slug=rfpcSlug)
	if request.method == 'POST':
		form = RFPCForm(request.POST, instance=rfpc)
		if form.is_valid():
			t = form.save()
			t.save()
			request.user.message_set.create(message='''RFPC %s Edited''' % t.slug)
			for change in form.changed_data:
				if change != 'slug': updateLog(request, projectNumber, '%s changed to %s' % ( change, eval('''t.%s''' % change)))
			return HttpResponseRedirect('/Projects/%s/RFPC' % project.projectNumber)
		else:
			pass
	else:
		form = RFPCForm(instance=rfpc)
	return render_to_response('change_management/edit-rfpc.html', { 'form': form, 'project': project, 'rfpc': rfpc }, context_instance=RequestContext(request))
Пример #9
0
def addRFPC(request, projectNumber):

	project = Project.objects.get(projectNumber=projectNumber)
	if request.method == 'POST':
		form = RFPCForm(request.POST)
		if form.is_valid():
			t = form.save()
			t.save()
			project.rfpc.add(t)
			project.save()
			request.user.message_set.create(message='''RFPC %s Registered''' % t.slug)
			updateLog(request, projectNumber, 'RFPC %s Registered' % t.slug)
			return HttpResponseRedirect('/Projects/%s/RFPC' % project.projectNumber)
		else:
			pass
	else:
		form = RFPCForm()
	return render_to_response('change_management/view-rfpcs.html', { 'form': form, 'project': project }, context_instance=RequestContext(request))
Пример #10
0
def add_issue(request, project_number):

    project = Project.objects.get(project_number=project_number)
    if request.method == 'POST':
        form = IssueForm(request.POST)
        if form.is_valid():
            t = form.save(commit=False)
            t.author = request.user
            t.save()
            project.issues.add(t)
            project.save()
            request.user.message_set.create(message='''Issue %s Registered''' %
                                            t.id)
            updateLog(request, project_number,
                      '''Issue %s Registered''' % t.id)
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #11
0
def add_lesson(request, project_number):

    project = Project.objects.get(project_number=project_number)
    lessons = LessonLearnt.objects.filter(project=project)
    if request.method == 'POST':
        form = LessonForm(request.POST)
        if form.is_valid():
            t = form.save()
            t.save()
            project.lessons_learnt.add(t)
            project.save()
            request.user.message_set.create(
                message='''Lesson %s Registered''' % t.id)
            updateLog(request, project_number,
                      '''Lesson %s Registered''' % t.id)
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #12
0
def edit_lesson(request, project_number, lesson_id):

    project = Project.objects.get(project_number=project_number)
    lesson = LessonLearnt.objects.get(id=lesson_id)
    if request.method == 'POST':
        form = LessonForm(request.POST, instance=lesson)
        if form.is_valid():
            t = form.save()
            t.save()
            request.user.message_set.create(message='''Lesson %s Edited''' %
                                            t.id)
            for change in form.changed_data:
                updateLog(
                    request, project_number,
                    '%s changed to %s' % (change, eval('''t.%s''' % change)))
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #13
0
def add_risk(request, project_number):

        # Some security - only allow users to view objects they are allowed to via read_acl
        project = get_object_or_404(Project, project_number=project_number)
        check_project_read_acl(project, request.user)   # Will return Http404 if user isn't allowed to view project

        if request.method == 'POST':
                form = RiskForm(request.POST)
                if form.is_valid():
                        t = form.save(commit=False)
                        t.risk_number = '''RISK-%s-%s''' % (request.user.username[:2].upper(), time.strftime("%Y%m%d%H%M"))
                        t.rating = _calculate_risk(t.probability, t.impact)
                        t.save()
                        project.risks.add(t)
                        project.save()
                        request.user.message_set.create(message='''Risk %s Registered''' % t.risk_number)
                        updateLog(request, project.project_number, '''Risk %s Registered''' % t.risk_number)
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
Пример #14
0
def add_deliverable(request, project_number):

    # Some security - only allow users to view objects they are allowed to via read_acl
    project = get_object_or_404(Project, project_number=project_number)
    check_project_read_acl(
        project, request.user
    )  # Will return Http404 if user isn't allowed to view project
    if request.method == 'POST':
        form = DeliverableForm(request.POST)
        if form.is_valid():
            t = form.save()
            t.save()
            project.deliverables.add(t)
            project.save()
            request.user.message_set.create(
                message='''Deliverable %s Registered''' % t.id)
            updateLog(request, project_number,
                      '''Deliverable %s Registered''' % t.id)
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #15
0
def edit_issue(request, project_number, issue_id):

    project = Project.objects.get(project_number=project_number)
    issue = Issue.objects.get(id=issue_id)
    if request.method == 'POST':
        form = IssueEditForm(request.POST, instance=issue)
        if form.is_valid():
            t = form.save(commit=False)
            if request.POST['update'] != '':                        
                if request.user.get_full_name() == '':
                    update_name = request.user.username
                else:
                    update_name = request.user.get_full_name()
                    t.history = '''\n\n------Updated by %s on %s------\n\n%s\n\n%s''' % ( update_name, time.strftime("%Y-%m-%d %H:%M"),
                    form.cleaned_data.get('update'), issue.history )
            t.save()
            request.user.message_set.create(message='''Issue %s Edited''' % t.id)
            for change in form.changed_data:
                updateLog(request, project_number, 'Issue %s updated' % ( t.id ))
            return HttpResponse( return_json_success() )
        else:
            return HttpResponse( handle_form_errors(form.errors))
Пример #16
0
def edit_issue(request, project_number, issue_id):

    project = Project.objects.get(project_number=project_number)
    issue = Issue.objects.get(id=issue_id)
    if request.method == 'POST':
        form = IssueEditForm(request.POST, instance=issue)
        if form.is_valid():
            t = form.save(commit=False)
            if request.POST['update'] != '':
                if request.user.get_full_name() == '':
                    update_name = request.user.username
                else:
                    update_name = request.user.get_full_name()
                    t.history = '''\n\n------Updated by %s on %s------\n\n%s\n\n%s''' % (
                        update_name, time.strftime("%Y-%m-%d %H:%M"),
                        form.cleaned_data.get('update'), issue.history)
            t.save()
            request.user.message_set.create(message='''Issue %s Edited''' %
                                            t.id)
            for change in form.changed_data:
                updateLog(request, project_number, 'Issue %s updated' % (t.id))
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
Пример #17
0
def addRFPC(request, projectNumber):

    project = Project.objects.get(projectNumber=projectNumber)
    if request.method == 'POST':
        form = RFPCForm(request.POST)
        if form.is_valid():
            t = form.save()
            t.save()
            project.rfpc.add(t)
            project.save()
            request.user.message_set.create(message='''RFPC %s Registered''' %
                                            t.slug)
            updateLog(request, projectNumber, 'RFPC %s Registered' % t.slug)
            return HttpResponseRedirect('/Projects/%s/RFPC' %
                                        project.projectNumber)
        else:
            pass
    else:
        form = RFPCForm()
    return render_to_response('change_management/view-rfpcs.html', {
        'form': form,
        'project': project
    },
                              context_instance=RequestContext(request))