Example #1
0
    def perform_update(self, serializer):
        user = self.request.user

        document = serializer.save()
        DocumentService.create_history(document)

        DocumentService.send_notification(document, user)
Example #2
0
    def update_status_and_send_notifications(attachment):
        """Update document status and send notifications is it is required"""
        not_run_files = DocumentFileAttachment.objects.filter(
            document=attachment.document,
            security_scan_status='NOT RUN',
            is_removed=False)
        in_progress_files = DocumentFileAttachment.objects.filter(
            document=attachment.document,
            security_scan_status='IN PROGRESS',
            is_removed=False)
        failed_files = DocumentFileAttachment.objects.filter(
            document=attachment.document,
            security_scan_status='FAIL',
            is_removed=False)

        if len(not_run_files) > 0 or len(in_progress_files) > 0:
            # The verdict is not in yet
            return

        user = attachment.document.update_user
        if user is None:
            user = attachment.document.create_user

        if len(failed_files) > 0:
            attachment.document.status = DocumentStatus.objects.get(
                status="Security Scan Failed")
            attachment.document.save()

        elif attachment.document.status.status == "Pending Submission":
            submitted_status = DocumentStatus.objects.get(status="Submitted")
            attachment.document.status = submitted_status

            attachment.document.save()

        DocumentService.send_notification(attachment.document, user)
Example #3
0
    def perform_create(self, serializer):
        user = self.request.user
        document = serializer.save()
        DocumentService.create_history(document)

        if document.status.status != 'Draft':
            document.status = DocumentStatus.objects.get(
                status='Pending Submission')
            document.save()

        DocumentService.send_notification(document, user)
Example #4
0
    def perform_update(self, serializer):
        user = self.request.user

        document = serializer.save()
        DocumentService.create_history(document)
        files = document.attachments.filter(security_scan_status='NOT RUN')

        if files and document.status.status == 'Submitted':
            document.status = DocumentStatus.objects.get(
                status='Pending Submission')
            document.save()

            for file in files:
                SecurityScan.send_scan_request(file)

        DocumentService.send_notification(document, user)