Пример #1
0
def to_rejected_model(beneficiary_pre_subscription: BeneficiaryPreSubscription, detail: str) -> BeneficiaryImport:
    beneficiary_import = BeneficiaryImport()

    beneficiary_import.applicationId = beneficiary_pre_subscription.application_id
    beneficiary_import.sourceId = beneficiary_pre_subscription.source_id
    beneficiary_import.source = beneficiary_pre_subscription.source
    beneficiary_import.setStatus(status=ImportStatus.REJECTED, detail=detail)

    return beneficiary_import
Пример #2
0
def attach_beneficiary_import_details(
        beneficiary: User,
        beneficiary_pre_subscription: BeneficiaryPreSubscription) -> None:
    beneficiary_import = BeneficiaryImport()

    beneficiary_import.applicationId = beneficiary_pre_subscription.application_id
    beneficiary_import.sourceId = beneficiary_pre_subscription.source_id
    beneficiary_import.source = beneficiary_pre_subscription.source
    beneficiary_import.setStatus(status=ImportStatus.CREATED)

    beneficiary.beneficiaryImports = [beneficiary_import]
Пример #3
0
def attach_beneficiary_import_details(
    beneficiary: User,
    beneficiary_pre_subscription: BeneficiaryPreSubscription,
    status: ImportStatus = ImportStatus.CREATED,
) -> None:
    beneficiary_import = BeneficiaryImport.query.filter_by(
        applicationId=beneficiary_pre_subscription.application_id,
        sourceId=beneficiary_pre_subscription.source_id,
        source=beneficiary_pre_subscription.source,
        beneficiary=beneficiary,
    ).one_or_none()
    if not beneficiary_import:
        beneficiary_import = BeneficiaryImport()

        beneficiary_import.applicationId = beneficiary_pre_subscription.application_id
        beneficiary_import.sourceId = beneficiary_pre_subscription.source_id
        beneficiary_import.source = beneficiary_pre_subscription.source
        beneficiary_import.beneficiary = beneficiary

    beneficiary_import.setStatus(status=status)
    beneficiary_import.beneficiary = beneficiary

    repository.save(beneficiary_import)
Пример #4
0
def create_beneficiary_import(
    application_id: int = 99,
    date: datetime = datetime.utcnow(),
    detail: str = None,
    idx: int = None,
    source_id: int = settings.DMS_OLD_ENROLLMENT_PROCEDURE_ID,
    source: str = BeneficiaryImportSources.demarches_simplifiees.value,
    status: ImportStatus = ImportStatus.CREATED,
    user: User = None,
) -> BeneficiaryImport:
    import_status = BeneficiaryImportStatus()
    import_status.date = date
    import_status.detail = detail
    import_status.status = status

    beneficiary_import = BeneficiaryImport()
    beneficiary_import.id = idx
    beneficiary_import.beneficiary = user
    beneficiary_import.applicationId = application_id
    beneficiary_import.sourceId = source_id
    beneficiary_import.source = source
    beneficiary_import.statuses = [import_status]

    return beneficiary_import