def patch(self):
     apply_patch(self.request)
     self.LOGGER.info(
         'Updated liability {}'.format(self.request.context.id),
         extra=context_unpack(self.request,
                              {'MESSAGE_ID': 'liability_patch'}))
     return {'data': self.request.context.serialize('view')}
 def patch(self):
     appeal = self.request.context
     monitoring = self.request.validated['monitoring']
     apply_patch(self.request, src=appeal.serialize())
     self.LOGGER.info('Updated appeal {}'.format(monitoring.id),
                      extra=context_unpack(self.request,
                                           {'MESSAGE_ID': 'appeal_patch'}))
     return {'data': appeal.serialize('view')}
 def patch(self):
     """
     Post a party resolution
     """
     apply_patch(self.request)
     self.LOGGER.info('Updated party {}'.format(self.request.context.id),
                      extra=context_unpack(self.request,
                                           {'MESSAGE_ID': 'party_patch'}))
     return {'data': self.request.context.serialize('view')}
예제 #4
0
    def put(self):
        appeal = self.request.validated['appeal']
        set_author(appeal.documents, self.request, 'author')
        upload_objects_documents(self.request, appeal)
        appeal.datePublished = appeal.dateCreated

        apply_patch(self.request, data=dict(appeal=appeal))
        self.LOGGER.info('Updated appeal {}'.format(self.request.context.id),
                         extra=context_unpack(self.request, {'MESSAGE_ID': 'appeal_put'}))
        return {'data': appeal.serialize('view')}
 def put(self):
     elimination = self.request.validated['eliminationreport']
     elimination.datePublished = elimination.dateCreated
     set_author(elimination.documents, self.request, 'author')
     upload_objects_documents(self.request, elimination)
     apply_patch(self.request,
                 data=dict(eliminationReport=elimination),
                 date_modified=elimination.dateCreated)
     self.LOGGER.info(
         'Updated elimination {}'.format(self.request.context.id),
         extra=context_unpack(self.request,
                              {'MESSAGE_ID': 'elimination_put'}))
     return {'data': elimination.serialize('view')}
예제 #6
0
 def patch(self):
     """
     Monitoring Document Update
     """
     document = self.request.context
     if apply_patch(self.request, update_context_date=True):
         self.LOGGER.info('Updated {} monitoring document {}'.format(
             self.document_type, document.id),
                          extra=context_unpack(
                              self.request,
                              {'MESSAGE_ID': 'monitoring_document_patch'},
                              {'DOCUMENT_ID': document.id}))
         return {'data': self.request.context.serialize('view')}
예제 #7
0
    def patch(self):
        monitoring = self.request.validated['monitoring']
        monitoring_old_status = monitoring.status
        elimination_resolution = monitoring.eliminationResolution

        apply_patch(self.request,
                    save=False,
                    src=self.request.validated['monitoring_src'])

        now = get_now()
        if monitoring_old_status == DRAFT_STATUS and monitoring.status == ACTIVE_STATUS:
            set_author(monitoring.decision.documents, self.request, 'author')
            accelerator = get_monitoring_accelerator(self.context)
            monitoring.monitoringPeriod = generate_period(
                now, MONITORING_TIME, accelerator)
            monitoring.decision.datePublished = now
            monitoring.endDate = calculate_normalized_business_date(
                now, MONITORING_TIME, accelerator)
        elif monitoring_old_status == ACTIVE_STATUS and monitoring.status == ADDRESSED_STATUS:
            set_author(monitoring.conclusion.documents, self.request, 'author')
            accelerator = get_monitoring_accelerator(self.context)
            monitoring.conclusion.datePublished = now
            monitoring.eliminationPeriod = generate_period(
                now, ELIMINATION_PERIOD_TIME, accelerator)
        elif monitoring_old_status == ACTIVE_STATUS and monitoring.status == DECLINED_STATUS:
            accelerator = get_monitoring_accelerator(self.context)
            monitoring.eliminationPeriod = generate_period(
                now, ELIMINATION_PERIOD_NO_VIOLATIONS_TIME, accelerator)
            monitoring.conclusion.datePublished = now
        elif any([
                monitoring_old_status == DRAFT_STATUS
                and monitoring.status == CANCELLED_STATUS,
                monitoring_old_status == ACTIVE_STATUS
                and monitoring.status == STOPPED_STATUS,
                monitoring_old_status == DECLINED_STATUS
                and monitoring.status == STOPPED_STATUS,
                monitoring_old_status == ADDRESSED_STATUS
                and monitoring.status == STOPPED_STATUS
        ]):
            set_author(monitoring.cancellation.documents, self.request,
                       'author')
            monitoring.cancellation.datePublished = now

        if not elimination_resolution and monitoring.eliminationResolution:
            validate_posting_elimination_resolution(self.request)
            monitoring.eliminationResolution.datePublished = monitoring.eliminationResolution.dateCreated

        # download (change urls of) documents for Decision, Conclusion, etc.
        raw_data = self.request.json.get("data", {})
        for key in raw_data.keys():
            if hasattr(getattr(monitoring, key, None),
                       "documents") and "documents" in raw_data[key]:
                upload_objects_documents(self.request,
                                         getattr(monitoring, key),
                                         key=key)

        save_monitoring(self.request, date_modified=now)
        LOGGER.info('Updated monitoring {}'.format(monitoring.id),
                    extra=context_unpack(self.request,
                                         {'MESSAGE_ID': 'monitoring_patch'}))
        return {'data': monitoring.serialize('view')}