def patch(self):
     """Plan Document Update"""
     if apply_patch(self.request, src=self.request.context.serialize()):
         update_file_content_type(self.request)
         self.LOGGER.info('Updated plan document {}'.format(self.request.context.id),
                     extra=context_unpack(self.request, {'MESSAGE_ID': 'plan_document_patch'}))
         return {'data': self.request.context.serialize("view")}
    def patch(self):
        """Plan Edit (partial)

        For example here is how procuring entity can change name:

        .. sourcecode:: http

            PATCH /plans/62179f8f94a246239268750a6eb0e53f HTTP/1.1
            Host: example.com
            Accept: application/json

            {
                "data": {
                    "procuringEntity": {
                        "identifier": {
                            "legalName": "ДП Державне Уравління Справами11"
                        },
                        "name": "ДУС"
                    },
                    "budget": {
                        "project": {
                            "name": "proj_name",
                            "id": "proj_id"
                        },
                        "amount": 10020,
                        "amountNet": 22222,
                        "id": "budget_id",
                        "description": "budget_description"
                    }
                }
            }

        And here is the response to be expected:

        .. sourcecode:: http

            HTTP/1.0 200 OK
            Content-Type: application/json

        """
        plan = self.request.validated['plan']

        data = self.request.validated['data']
        apply_patch(self.request, src=self.request.validated['plan_src'])
        LOGGER.info('Updated plan {}'.format(plan.id),
                    extra=context_unpack(self.request, {'MESSAGE_ID': 'plan_patch'}))
        return {'data': plan.serialize('view')}
    def patch(self):
        """Plan Edit (partial)

        For example here is how procuring entity can change name:

        .. sourcecode:: http

            PATCH /plans/62179f8f94a246239268750a6eb0e53f HTTP/1.1
            Host: example.com
            Accept: application/json

            {
                "data": {
                    "procuringEntity": {
                        "identifier": {
                            "legalName": "ДП Державне Уравління Справами11"
                        },
                        "name": "ДУС"
                    },
                    "budget": {
                        "project": {
                            "name": "proj_name",
                            "id": "proj_id"
                        },
                        "amount": 10020,
                        "amountNet": 22222,
                        "id": "budget_id",
                        "description": "budget_description"
                    }
                }
            }

        And here is the response to be expected:

        .. sourcecode:: http

            HTTP/1.0 200 OK
            Content-Type: application/json

        """
        plan = self.request.validated['plan']
        apply_patch(self.request, src=self.request.validated['plan_src'])
        LOGGER.info('Updated plan {}'.format(plan.id),
                    extra=context_unpack(self.request,
                                         {'MESSAGE_ID': 'plan_patch'}))
        return {'data': plan.serialize('view')}
 def patch(self):
     """Plan Document Update"""
     if apply_patch(self.request, src=self.request.context.serialize()):
         update_file_content_type(self.request)
         self.LOGGER.info(
             "Updated plan document {}".format(self.request.context.id),
             extra=context_unpack(self.request, {"MESSAGE_ID": "plan_document_patch"}),
         )
         return {"data": self.request.context.serialize("view")}
Example #5
0
File: plan.py Project: lttga/op2
    def patch(self):
        """Plan Edit (partial)

        For example here is how procuring entity can change name:

        .. sourcecode:: http

            PATCH /plans/62179f8f94a246239268750a6eb0e53f HTTP/1.1
            Host: example.com
            Accept: application/json

            {
                "data": {
                    "procuringEntity": {
                        "identifier": {
                            "legalName": "ДП Державне Уравління Справами11"
                        },
                        "name": "ДУС"
                    },
                    "budget": {
                        "project": {
                            "name": "proj_name",
                            "id": "proj_id"
                        },
                        "amount": 10020,
                        "amountNet": 22222,
                        "id": "budget_id",
                        "description": "budget_description"
                    }
                }
            }

        And here is the response to be expected:

        .. sourcecode:: http

            HTTP/1.0 200 OK
            Content-Type: application/json

        """
        plan = self.request.validated["plan"]
        src_data = plan.serialize("plain")
        if apply_patch(self.request,
                       src=self.request.validated["plan_src"],
                       save=False):
            self._check_field_change_events(src_data, plan)
            save_plan(self.request)
            LOGGER.info("Updated plan {}".format(plan.id),
                        extra=context_unpack(self.request,
                                             {"MESSAGE_ID": "plan_patch"}))
        return {"data": plan.serialize("view")}
Example #6
0
    def patch(self):
        plan = self.request.validated['plan']
        milestone = self.request.context
        status = milestone.status
        prev_due_date = milestone.dueDate
        description = milestone.description

        if apply_patch(self.request, src=self.request.context.serialize(), save=False):
            plan.dateModified = milestone.dateModified = get_now()
            plan.modified = False
            if status != milestone.status:  # Allowed status changes: scheduled -> met/notMet
                if (
                        status == Milestone.STATUS_SCHEDULED
                        and milestone.status in (Milestone.STATUS_MET, Milestone.STATUS_NOT_MET)
                ):
                    if milestone.status == Milestone.STATUS_MET:
                        milestone.dateMet = milestone.dateModified
                else:
                    raise_operation_error(
                        self.request,
                        "Can't update milestone status from '{}' to '{}'".format(status, milestone.status)
                    )

            if prev_due_date != milestone.dueDate and status != Milestone.STATUS_SCHEDULED:
                raise_operation_error(
                    self.request,
                    "Can't update dueDate at '{}' milestone status".format(status)
                )

            if (
                description != milestone.description and
                status not in (Milestone.STATUS_SCHEDULED, Milestone.STATUS_MET)
            ):
                raise_operation_error(
                    self.request,
                    "Can't update description at '{}' milestone status".format(status)
                )

            save_plan(self.request)
            self.LOGGER.info('Updated plan milestone {}'.format(self.request.context.id),
                             extra=context_unpack(self.request, {'MESSAGE_ID': 'plan_milestone_patch'}))

        return {'data': self.request.context.serialize("view")}
Example #7
0
 def patch(self):
     """Plan Document Update"""
     if apply_patch(self.request, src=self.request.context.serialize()):
         update_file_content_type(self.request)
         self._patch_document_log()
         return {"data": self.request.context.serialize("view")}
 def apply(self, request, **kwargs):
     return apply_patch(request, **kwargs)