def to_dict(self):
     verification_dict = {
         "verification_id": self.verification_id,
         "org_uuid": self.org_uuid,
         "status": self.status,
         "comments": self.comment_dict_list(),
         "created_at": "",
         "updated_at": ""
     }
     if self.created_at is not None:
         verification_dict["created_at"] = datetime_to_string(self.created_at)
     if self.updated_at is not None:
         verification_dict["updated_at"] = datetime_to_string(self.updated_at)
     return verification_dict
 def to_response(self):
     member_dict = {
         "username": self.username,
         "address": self.address,
         "status": self.status,
         "role": self.role,
         "invited_on": "",
         "updated_on": ""
     }
     if self.invited_on is not None:
         member_dict["invited_on"] = datetime_to_string(self.invited_on)
     if self.updated_on is not None:
         member_dict["updated_on"] = datetime_to_string(self.updated_on)
     return member_dict
    def to_response(self):
        state_dict = {
            "state": self.__state,
            "updated_on": "",
            "updated_by": self.__updated_by,
            "reviewed_by": self.__reviewed_by,
            "reviewed_on": "",
        }

        if self.__updated_on is not None:
            state_dict["updated_on"] = datetime_to_string(self.__updated_on)
        if self.__reviewed_on is not None:
            state_dict["reviewed_on"] = datetime_to_string(self.__reviewed_on)

        return state_dict
 def to_dict(self):
     verification_dict = {
         "verification_id": self.__verification_id,
         "username": self.__username,
         "status": self.__status,
         "comments": self.comment_dict_list(),
         "created_at": "",
         "updated_at": ""
     }
     if self.__created_at is not None:
         verification_dict["created_at"] = datetime_to_string(
             self.__created_at)
     if self.__updated_at is not None:
         verification_dict["updated_at"] = datetime_to_string(
             self.__updated_at)
     return verification_dict
 def to_response(self):
     response_dict = {
         "id": self.id,
         "type": self.type,
         "entity_id": self.entity_id,
         "status": self.status,
         "requestee": self.requestee,
         "reject_reason": self.reject_reason,
         "created_at": "",
         "updated_at": ""
     }
     if self.created_at is not None:
         response_dict["created_at"] = datetime_to_string(self.created_at)
     if self.updated_at is not None:
         response_dict["updated_at"] = datetime_to_string(self.updated_at)
     return response_dict
Exemple #6
0
    def to_dict(self):
        state_dict = {
            "state": self.__state,
            "transaction_hash": self.__transaction_hash,
            "wallet_address": self.__wallet_address,
            "created_by": self.__created_by,
            "created_on": "",
            "updated_on": "",
            "updated_by": self.__updated_by,
            "reviewed_by": self.__reviewed_by,
            "reviewed_on": "",
        }

        if self.__updated_on is not None:
            state_dict["updated_on"] = datetime_to_string(self.__updated_on)
        if self.__reviewed_on is not None:
            state_dict["reviewed_on"] = datetime_to_string(self.__reviewed_on)
        if self.__created_on is not None:
            state_dict["created_on"] = datetime_to_string(self.__created_on)

        return state_dict
 def test_individual_organization_review(self, mock_boto, mock_ipfs):
     from registry.application.services.slack_chat_operation import SlackChatOperation
     username = "******"
     org_id = "test_org_id"
     org_uuid = "test_org_uuid"
     registration_type = "type"
     registration_id = "123"
     current_time = datetime.now()
     org_repo.add_organization(
         DomainOrganization(org_uuid, org_id, f"org_{org_id}", OrganizationType.INDIVIDUAL.value, ORIGIN, "",
                            "", "", [], {}, "", "", [], [], [], [], registration_type=registration_type,
                            registration_id=registration_id), username, OrganizationStatus.ONBOARDING.value)
     SlackChatOperation("admin", "").process_approval_comment(
         "organization", "APPROVED", "here is the comment", {"org_id": "test_org_id"})
     organization = org_repo.get_org_for_org_uuid(org_uuid)
     comments = organization.org_state.comments
     if len(comments) != 1:
         assert False
     self.assertEqual("admin", comments[0].created_by)
     self.assertEqual("here is the comment", comments[0].comment)
     self.assertEqual(datetime_to_string(current_time), comments[0].created_at)
 def add_comment(self, comment, username):
     self.__comments.append(
         Comment(comment, username, datetime_to_string(datetime.utcnow())))
Exemple #9
0
    def process_approval_comment(self, approval_type, state, comment, params):
        if approval_type == "organization":
            org = OrganizationPublisherRepository().get_org_for_org_id(
                org_id=params["org_id"])
            if org.org_state.state in [
                    OrganizationStatus.APPROVAL_PENDING.value,
                    OrganizationStatus.ONBOARDING.value
            ]:
                if org.org_type == OrganizationType.ORGANIZATION.value:
                    self.callback_verification_service(
                        org.uuid,
                        getattr(OrganizationStatus, state).value,
                        self._username, comment)
                elif org.org_type == OrganizationType.INDIVIDUAL.value:
                    OrganizationPublisherRepository(
                    ).update_organization_status(
                        org.uuid,
                        getattr(OrganizationStatus, state).value,
                        self._username,
                        Comment(comment, self._username,
                                datetime_to_string(datetime.now())))

        elif approval_type == "service":
            org_uuid, service = ServicePublisherRepository(). \
                get_service_for_given_service_id_and_org_id(org_id=params["org_id"], service_id=params["service_id"])
            if service.service_state.state == ServiceStatus.APPROVAL_PENDING.value:
                ServicePublisherRepository().save_service(
                    username=self._username,
                    service=service,
                    state=getattr(ServiceStatus, state).value)
                service_comments = ServiceComment(
                    org_uuid=service.org_uuid,
                    service_uuid=service.uuid,
                    support_type=ServiceSupportType.SERVICE_APPROVAL.value,
                    user_type=UserType.SERVICE_APPROVER.value,
                    commented_by=self._username,
                    comment=comment)
                ServicePublisherRepository().save_service_comments(
                    service_comment=service_comments)
                slack_msg = f"Reviews for service with {service.service_id} is successfully submitted."
                # send_slack_notification(slack_msg=slack_msg, slack_url=SLACK_APPROVAL_CHANNEL_URL,
                #                         slack_channel="ai-approvals")
                recipients = [
                    contributor.get("email_id", "")
                    for contributor in service.contributors
                ]
                if not recipients:
                    logger.info(
                        f"Unable to find service contributors for service {service.service_id} under {params['org_id']}"
                    )
                    return
                notification_subject = f"Your service {service.service_id} is reviewed"
                notification_message = f"Your service {service.service_id} under {params['org_id']} is reviewed"
                send_email_notification(
                    recipients=recipients,
                    notification_subject=notification_subject,
                    notification_message=notification_message,
                    notification_arn=NOTIFICATION_ARN,
                    boto_util=boto_util)
            else:
                logger.info("Service state is not valid.")
        else:
            logger.info("Approval type is not valid")