예제 #1
0
def add_engineering_day(request, project_number, wbs_id):

        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
        work_item = WorkItem.objects.get(id=wbs_id)
                
        if request.method == 'POST':
                form = EngineeringDayForm(request.POST)
                if form.is_valid():
                        t = form.save(commit=False)     
                        logging.debug('''resource => %s, work_date => %s, day_type => %s''' % ( t.resource, t.work_date, t.day_type ))
                        
                        available_resources = get_resources_for_engineering_day(request, project_number, wbs_id, t.work_date.strftime("%Y"), t.work_date.strftime("%m"), t.work_date.strftime("%d"), t.day_type, as_json=False)
                        logging.debug('''Resource ID is: %s''' % t.resource.id )
                        logging.debug('''Available resources are: %s''' % available_resources )
                        if t.resource.id not in [ r['pk'] for r in available_resources ]:
                                logging.debug('''User has tried to book %s on %s when he hasn't got the correct skillset''' % ( t.resource, t.work_date ))
                                return HttpResponse( handle_generic_error("Sorry - this resource hasn't got the skillset to work on this task"))

                        if EngineeringDay.objects.filter(work_date=t.work_date, resource=t.resource, day_type__in=[ t.day_type, 2]).count() > 0:
                                logging.debug('''User has tried to book %s on %s when he has existing engineering days booked''' % ( t.resource, t.work_date ))
                                return HttpResponse( handle_generic_error("Sorry - this resource is already booked at this time."))
                                
                        
                        
                        t.save()
                        work_item.engineering_days.add(t)
                        work_item.save()
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
예제 #2
0
def edit_work_item(request, project_number, wbs_id):
        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
        work_item = WorkItem.objects.get(id=wbs_id)

        # Give the user the correct form - WBSForm for a project admin (has write access to project) or WBSUserForm for a readonly user
        form_type = 'WBSUserForm'
        for group in request.user.groups.all():
                if group in project.write_acl.all():
                        form_type = 'WBSForm'

        if request.method == 'POST':
                form = eval(form_type)(project, request.POST, instance=work_item)
                if form.is_valid():
                        t = form.save(commit=False)
                        t.author = request.user

                        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'), work_item.history )

                        t.save()
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
예제 #3
0
def delete_work_item(request, project_number, wbs_id):
        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
        work_item = WorkItem.objects.get(id=wbs_id)

        project.work_items.remove(work_item)
        project.save()
        return HttpResponse( return_json_success() )
예제 #4
0
def add_checkpoint_report(request, project_number):

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

        if request.method == 'POST':
                form = DialogExecutiveSummary(request.POST)
                if form.is_valid():
                        t = form.save()
                        project.executive_summary.add(t)
                        project.save()
                        request.user.message_set.create(message='''Checkpoint Report added''')
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
예제 #5
0
    def update(self, request, project_number):
        """ Update the project """

        log.debug("PUT request from user %s for project number %s" % ( request.user, project_number ))
        proj = Project.objects.get(project_number=project_number)
        log.debug("Fetched object from database %s" % proj)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing PUT request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        form = EditPID(request.POST, instance=proj)
        if form.is_valid():
            t = form.save()
            if request.POST.get('team_managers_placeholder'):
                for id in request.POST['team_managers_placeholder'].split(','):
                    t.team_managers.add(id)
            log.debug('Saving %s back to database' % t)
            t.save()
            return t
        else:
            resp = rc.BAD_REQUEST
            resp.write(form.errors)
            log.debug('Validation errors with %s' % t)
            t.save()
            return resp
예제 #6
0
def add_project_stage(request, project_number):

        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
        
        if request.method == 'POST':
                form = WBSProjectStage(request.POST)
                if form.is_valid():
                        t = form.save(commit=False)
                        t.stage = '''%s - %s''' % ( t.stage_number, t.stage )
                        t.save()
                        project.stage_plan.add(t)
                        project.save()
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
예제 #7
0
def add_work_item(request, project_number):
        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
        if request.method == 'POST':
                form = WBSForm(project, request.POST)
                if form.is_valid():
                        t = form.save(commit=False)
                        number_of_items = WorkItem.objects.filter(active=True, project__id=project.id).count()
                        t.wbs_number = number_of_items + 1      
                        t.author = request.user
                        t.save()
                        project.work_items.add(t)
                        project.save()
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
예제 #8
0
    def update(self, request, project_number, issue_id):
        """ Update the issue """

        log.debug("PUT request from user %s for issue id %s" % ( request.user, issue_id))
        proj = Project.objects.get(project_number=project_number)
        issue = Issue.objects.get(id=issue_id)
        log.debug("Fetched object from database %s" % issue)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing PUT request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        form = IssueForm(request.POST, instance=issue)
        if form.is_valid():
            t = form.save(commit=False)
            if request.POST['update'] != '':                        
                if not 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 )
            log.debug('Saving %s back to database' % t)
            t.save()
            return t
        else:
            resp = rc.BAD_REQUEST
            resp.write(form.errors)
            log.debug('Validation errors with %s' % t)
            t.save()
            return resp
예제 #9
0
def reorder_wbs(request, project_number):
    project = get_object_or_404(Project, project_number=project_number)
    check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
    new_order = request.POST['work_item_order']

    logging.debug('''New order = %s''' % new_order )
    new_order_list = [ ]
    for id in new_order.split(','):
        new_order_list.append(id)

    i = 1
    for id in new_order_list:
        if id != '':
            wbs = WorkItem.objects.get(id=id)
            wbs.wbs_number = i
            wbs.save()
            i += 1
    return HttpResponse( return_json_success())
예제 #10
0
def edit_project(request, project_number, form_type):

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

        if request.method == 'POST':
                form = eval(form_type)(request.POST, instance=project)
                if form.is_valid():
                        t = form.save()
                        for id in request.POST['team_managers_placeholder'].split(','):
                                t.team_managers.add(id)
                        t.save()
                        request.user.message_set.create(message='''Project %s Edited''' % t.project_number)
                        for change in form.changed_data:
                                updateLog(request, t.project_number, '%s Updated' % change)
                        return HttpResponse( return_json_success() )
                else:
                        return HttpResponse( handle_form_errors(form.errors))
예제 #11
0
def edit_project(request, project_number, form_type):

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

    if request.method == 'POST':
        form = eval(form_type)(request.POST, instance=project)
        if form.is_valid():
            t = form.save()
            for id in request.POST['team_managers_placeholder'].split(','):
                t.team_managers.add(id)
            t.save()
            request.user.message_set.create(message='''Project %s Edited''' %
                                            t.project_number)
            for change in form.changed_data:
                updateLog(request, t.project_number, '%s Updated' % change)
            return HttpResponse(return_json_success())
        else:
            return HttpResponse(handle_form_errors(form.errors))
예제 #12
0
    def delete(self, request, project_number):
        """ Put the project into archived state, not actually delete it """

        log.debug("DELETE request from user %s for project number %s" % ( request.user, project_number ))
        proj = Project.objects.get(project_number=project_number)
        log.debug("Fetched object from database %s" % proj)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        proj.project_status = 5
        proj.save()
        log.debug("Archived project %s" % proj)
        return rc.ALL_OK
예제 #13
0
    def create(self, request, project_number):
        """ Create a new Deliverable """

        log.debug("POST request from user %s to create a new deliverable" % request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        # Go ahead and create the deliverable....
        form = DeliverableForm(request.POST)
        t = form.save()
        proj.deliverables.add(t)
        proj.save()
        return t
예제 #14
0
    def delete(self, request, project_number, eday_id):
        """ Disassociate the day from the project, not actually delete it """

        log.debug("DELETE request from user %s for engineering day %s" % ( request.user, eday_id ))
        proj = Project.objects.get(project_number=project_number)
        stage = ProjectStage.objects.get(id=stageplan_id)
        log.debug("Fetched object from database %s" % stage)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for project stage %s from user %s" % ( stageplan_id, request.user ))
            return rc.FORBIDDEN

        proj.stage_plan.remove(stage)
        proj.save()
        log.debug("Deleted project stage %s" % stage)
        return rc.ALL_OK
예제 #15
0
    def delete(self, request, project_number, risk_number):
        """ Disassociate the issue from the project, not actually delete it """

        log.debug("DELETE request from user %s for issue id %s" % ( request.user, issue_id))
        proj = Project.objects.get(project_number=project_number)
        issue = Issue.objects.get(id=issue_id)
        log.debug("Fetched object from database %s" % issue)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for risk %s from user %s" % ( risk_number, request.user ))
            return rc.FORBIDDEN

        proj.issues.remove(issue)
        proj.save()
        log.debug("Deleted issue %s" % issue)
        return rc.ALL_OK
예제 #16
0
    def create(self, request, project_number, wbs_id):
        """ Create a new Engineering Day """

        log.debug("POST request from user %s to create a new engineering day" % request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        # Go ahead and create the engineering day....
        form = EngineeringDayForm(request.POST)
        t = form.save()
        wbs.engineering_days.add(t)
        wbs.save()
        return t
예제 #17
0
    def delete(self, request, project_number, deliverable_id):
        """ Disassociate the deliverable from the project, not actually delete it """

        log.debug("DELETE request from user %s for deliverable %s" % ( request.user, deliverable_id ))
        proj = Project.objects.get(project_number=project_number)
        deliverable = Deliverable.objects.get(id=deliverable_id)
        log.debug("Fetched object from database %s" % deliverable)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for deliverable %s from user %s" % ( deliverable_id, request.user ))
            return rc.FORBIDDEN

        proj.deliverables.remove(deliverable)
        proj.save()
        log.debug("Deleted deliverable %s" % deliverable)
        return rc.ALL_OK
예제 #18
0
    def create(self, request, project_number):
        """ Create a new Work Item """

        log.debug("POST request from user %s to create a new work item" % request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        # Go ahead and create the work item....
        form = WBSForm(request.POST)
        t = form.save()
        proj.work_items.add(t)
        proj.save()
        return t
예제 #19
0
    def delete(self, request, project_number, wbs_id):
        """ Disassociate the work item from the project, not actually delete it """

        log.debug("DELETE request from user %s for work item %s" % ( request.user, wbs_id ))
        proj = Project.objects.get(project_number=project_number)
        wbs = WorkItem.objects.get(id=wbs_id)
        log.debug("Fetched object from database %s" % wbs)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for deliverable %s from user %s" % ( deliverable_id, request.user ))
            return rc.FORBIDDEN

        proj.work_items.remove(wbs)
        proj.save()
        log.debug("Deleted work item %s" % wbs)
        return rc.ALL_OK
예제 #20
0
    def create(self, request, project_number):
        """ Create a new Project Stage """

        log.debug("POST request from user %s to create a new project stage" % request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        # Go ahead and create the project stage....
        form = WBSProjectStage(request.POST)
        t = form.save()
        proj.stage_plan.add(t)
        proj.save()
        return t
    def delete(self, request, project_number, risk_number):
        """ Disassociate the risk from the project, not actually delete it """

        log.debug("DELETE request from user %s for risk number %s" % ( request.user, risk_number ))
        proj = Project.objects.get(project_number=project_number)
        risk = Risk.objects.get(risk_number=risk_number)
        log.debug("Fetched object from database %s" % risk)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for risk %s from user %s" % ( risk_number, request.user ))
            return rc.FORBIDDEN

        proj.risks.remove(risk)
        proj.save()
        log.debug("Deleted risk %s" % risk)
        return rc.ALL_OK
    def delete(self, request, project_number, lesson_id):
        """ Disassociate the lesson from the project, not actually delete it """

        log.debug("DELETE request from user %s for lesson %s" % ( request.user, lesson_id ))
        proj = Project.objects.get(project_number=project_number)
        lesson = LessonLearnt.objects.get(id=lesson_id)
        log.debug("Fetched object from database %s" % lesson)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for lesson %s from user %s" % ( lesson_id, request.user ))
            return rc.FORBIDDEN

        proj.lessons.remove(lesson)
        proj.save()
        log.debug("Deleted lesson %s" % lesson)
        return rc.ALL_OK
    def create(self, request, project_number):
        """ Create a new Lesson """

        log.debug("POST request from user %s to create a new lesson" % request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        # Go ahead and create the lesson....
        form = LessonForm(request.POST)
        t = form.save()
        proj.lessons.add(t)
        proj.save()
        return t
예제 #24
0
    def create(self, request, project_number):
        """ Create a new Issue """

        log.debug("POST request from user %s to create a new issue" % request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        # Go ahead and create the issue....
        form = IssueForm(request.POST)
        t = form.save(commit=False)
        t.save()
        proj.issues.add(t)
        proj.save()
        return t
예제 #25
0
    def delete(self, request, project_number):
        """ Put the project into archived state, not actually delete it """

        log.debug("DELETE request from user %s for project number %s" %
                  (request.user, project_number))
        proj = Project.objects.get(project_number=project_number)
        log.debug("Fetched object from database %s" % proj)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing DELETE request for project %s from user %s" %
                      (project_number, request.user))
            return rc.FORBIDDEN

        proj.project_status = 5
        proj.save()
        log.debug("Archived project %s" % proj)
        return rc.ALL_OK
예제 #26
0
    def create(self, request, project_number):
        """ Create a new Project Stage """

        log.debug("POST request from user %s to create a new project stage" %
                  request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" %
                      (project_number, request.user))
            return rc.FORBIDDEN

        # Go ahead and create the project stage....
        form = WBSProjectStage(request.POST)
        t = form.save()
        proj.stage_plan.add(t)
        proj.save()
        return t
예제 #27
0
    def create(self, request, project_number, wbs_id):
        """ Create a new Engineering Day """

        log.debug("POST request from user %s to create a new engineering day" %
                  request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" %
                      (project_number, request.user))
            return rc.FORBIDDEN

        # Go ahead and create the engineering day....
        form = EngineeringDayForm(request.POST)
        t = form.save()
        wbs.engineering_days.add(t)
        wbs.save()
        return t
예제 #28
0
    def delete(self, request, project_number, wbs_id):
        """ Disassociate the work item from the project, not actually delete it """

        log.debug("DELETE request from user %s for work item %s" %
                  (request.user, wbs_id))
        proj = Project.objects.get(project_number=project_number)
        wbs = WorkItem.objects.get(id=wbs_id)
        log.debug("Fetched object from database %s" % wbs)

        if not check_project_write_acl(proj, request.user):
            log.debug(
                "Refusing DELETE request for deliverable %s from user %s" %
                (deliverable_id, request.user))
            return rc.FORBIDDEN

        proj.work_items.remove(wbs)
        proj.save()
        log.debug("Deleted work item %s" % wbs)
        return rc.ALL_OK
예제 #29
0
    def delete(self, request, project_number, deliverable_id):
        """ Disassociate the deliverable from the project, not actually delete it """

        log.debug("DELETE request from user %s for deliverable %s" %
                  (request.user, deliverable_id))
        proj = Project.objects.get(project_number=project_number)
        deliverable = Deliverable.objects.get(id=deliverable_id)
        log.debug("Fetched object from database %s" % deliverable)

        if not check_project_write_acl(proj, request.user):
            log.debug(
                "Refusing DELETE request for deliverable %s from user %s" %
                (deliverable_id, request.user))
            return rc.FORBIDDEN

        proj.deliverables.remove(deliverable)
        proj.save()
        log.debug("Deleted deliverable %s" % deliverable)
        return rc.ALL_OK
    def create(self, request, project_number):
        """ Create a new Risk """

        log.debug("POST request from user %s to create a new risk" % request.user)
        proj = Project.objects.get(project_number=project_number)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing POST request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        # Go ahead and create the risk....
        form = RiskForm(request.POST)
        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()
        proj.risks.add(t)
        proj.save()
        return t
예제 #31
0
    def delete(self, request, project_number, eday_id):
        """ Disassociate the day from the project, not actually delete it """

        log.debug("DELETE request from user %s for engineering day %s" %
                  (request.user, eday_id))
        proj = Project.objects.get(project_number=project_number)
        stage = ProjectStage.objects.get(id=stageplan_id)
        log.debug("Fetched object from database %s" % stage)

        if not check_project_write_acl(proj, request.user):
            log.debug(
                "Refusing DELETE request for project stage %s from user %s" %
                (stageplan_id, request.user))
            return rc.FORBIDDEN

        proj.stage_plan.remove(stage)
        proj.save()
        log.debug("Deleted project stage %s" % stage)
        return rc.ALL_OK
    def update(self, request, project_number, lesson_id):
        """ Update the lesson """

        log.debug("PUT request from user %s for lesson %s" % ( request.user, lesson_id ))
        proj = Project.objects.get(project_number=project_number)
        lesson = LessonLearnt.objects.get(id=lesson_id)
        log.debug("Fetched object from database %s" % lesson)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing PUT request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        form = LessonForm(request.POST, instance=lesson)
        if form.is_valid():
            t = form.save()
            log.debug('Saving %s back to database' % t)
            return t
        else:
            resp = rc.BAD_REQUEST
            resp.write(form.errors)
            log.debug('Validation errors with %s' % t)
            return resp
예제 #33
0
    def update(self, request, project_number, stageplan_id):
        """ Update the Project Stage """

        log.debug("PUT request from user %s for project stage %s" % ( request.user, stageplan_id))
        proj = Project.objects.get(project_number=project_number)
        stage = ProjectStage.objects.get(id=stageplan_id)
        log.debug("Fetched object from database %s" % stage)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing PUT request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        form = WBSProjectStage(request.POST, instance=stage)
        if form.is_valid():
            log.debug('Saving %s back to database' % t)
            t = form.save()
            return t
        else:
            resp = rc.BAD_REQUEST
            resp.write(form.errors)
            log.debug('Validation errors with %s' % t)
            return resp
예제 #34
0
    def update(self, request, project_number, deliverable_id):
        """ Update the deliverable """

        log.debug("PUT request from user %s for deliverable %s" % ( request.user, deliverable_id ))
        proj = Project.objects.get(project_number=project_number)
        deliverable = Deliverable.objects.get(id=deliverable_id)
        log.debug("Fetched object from database %s" % deliverable)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing PUT request for project %s from user %s" % ( project_number, request.user ))
            return rc.FORBIDDEN

        form = DeliverableForm(request.POST, instance=deliverable)
        if form.is_valid():
            t = form.save()
            log.debug('Saving %s back to database' % t)
            return t
        else:
            resp = rc.BAD_REQUEST
            resp.write(form.errors)
            log.debug('Validation errors with %s' % t)
            return resp
예제 #35
0
    def update(self, request, project_number, stageplan_id):
        """ Update the Project Stage """

        log.debug("PUT request from user %s for project stage %s" %
                  (request.user, stageplan_id))
        proj = Project.objects.get(project_number=project_number)
        stage = ProjectStage.objects.get(id=stageplan_id)
        log.debug("Fetched object from database %s" % stage)

        if not check_project_write_acl(proj, request.user):
            log.debug("Refusing PUT request for project %s from user %s" %
                      (project_number, request.user))
            return rc.FORBIDDEN

        form = WBSProjectStage(request.POST, instance=stage)
        if form.is_valid():
            log.debug('Saving %s back to database' % t)
            t = form.save()
            return t
        else:
            resp = rc.BAD_REQUEST
            resp.write(form.errors)
            log.debug('Validation errors with %s' % t)
            return resp
예제 #36
0
def view_project_phases(request, project_number):
        # Some security - only allow users to view objects they are allowed to via write_acl
        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to write to project
        return HttpResponse( serializers.serialize('json', ProjectPhase.objects.filter(work_items__project=project)))
예제 #37
0
def view_checkpoint_reports(request, project_number):   
        # Some security - only allow users to view objects they are allowed to via write_acl
        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to write to project
        return HttpResponse( serializers.serialize('json', project.executive_summary.all(), relations={'author': {'fields': ('username',), 'extras': ('get_full_name',)}}, display=['type']))
예제 #38
0
def view_stage_plan(request, project_number):

        project = get_object_or_404(Project, project_number=project_number)
        check_project_write_acl(project, request.user)  # Will return Http404 if user isn't allowed to view project
        return HttpResponse( serializers.serialize('json', project.stage_plan.all()))