Beispiel #1
0
def factory_org_model(org_info: dict = TestOrgInfo.org1,
                      org_type_info: dict = TestOrgTypeInfo.test_type,
                      org_status_info: dict = TestOrgStatusInfo.test_status,
                      payment_type_info: dict = TestPaymentTypeInfo.test_type,
                      user_id=None):
    """Produce a templated org model."""
    org_type = OrgTypeModel.get_default_type()
    if org_type_info['code'] != TestOrgTypeInfo.implicit['code']:
        org_type = OrgTypeModel(code=org_type_info['code'], desc=org_type_info['desc'])
        org_type.save()

    org_status = OrgStatusModel(code=org_status_info['code'], desc=org_status_info['desc'])
    org_status.save()

    preferred_payment = PaymentTypeModel(code=payment_type_info['code'], desc=payment_type_info['desc'])
    preferred_payment.save()

    org = OrgModel(name=org_info['name'])
    org.org_type = org_type
    org.org_status = org_status
    org.preferred_payment = preferred_payment
    org.created_by_id = user_id
    org.save()

    return org
Beispiel #2
0
def factory_org_model(org_info: dict = TestOrgInfo.org1,
                      org_type_info: dict = None,
                      org_status_info: dict = None,
                      user_id=None,
                      bcol_info: dict = TestBCOLInfo.bcol1):
    """Produce a templated org model."""
    org_type = OrgTypeModel.get_default_type()
    if org_type_info and org_type_info['code'] != TestOrgTypeInfo.implicit[
            'code']:
        org_type = OrgTypeModel(code=org_type_info['code'],
                                description=org_type_info['desc'])
        org_type.save()

    if org_status_info is not None:
        org_status = OrgStatusModel(code=org_status_info['code'],
                                    description=org_status_info['desc'])
        org_status.save()
    else:
        org_status = OrgStatusModel.get_default_status()

    org = OrgModel(name=org_info['name'])
    org.org_type = org_type
    org.access_type = org_info.get('accessType', '')
    org.org_status = org_status
    org.created_by_id = user_id
    org.bcol_account_id = bcol_info.get('bcol_account_id', '')
    org.bcol_user_id = bcol_info.get('bcol_user_id', '')
    org.save()

    return org
Beispiel #3
0
def factory_org_model(name):
    """Produce a templated org model."""
    org_type = OrgTypeModel(code='TEST', desc='Test')
    org_type.save()

    org_status = OrgStatusModel(code='TEST', desc='Test')
    org_status.save()

    preferred_payment = PaymentTypeModel(code='TEST', desc='Test')
    preferred_payment.save()

    org = OrgModel(name=name)
    org.org_type = org_type
    org.org_status = org_status
    org.preferred_payment = preferred_payment
    org.save()

    return org
Beispiel #4
0
def factory_org_model(org_info: dict = TestOrgInfo.org1,
                      org_type_info: dict = TestOrgTypeInfo.test_type,
                      org_status_info: dict = TestOrgStatusInfo.test_status,
                      payment_type_info: dict = TestPaymentTypeInfo.test_type,
                      user_id=None,
                      bcol_info: dict = TestBCOLInfo.bcol1):
    """Produce a templated org model."""
    org_type = OrgTypeModel.get_default_type()
    if org_type_info['code'] != TestOrgTypeInfo.implicit['code']:
        org_type = OrgTypeModel(code=org_type_info['code'],
                                desc=org_type_info['desc'])
        org_type.save()

    if org_status_info:
        org_status = OrgStatusModel(code=org_status_info['code'],
                                    desc=org_status_info['desc'])
        org_status.save()
    else:
        org_status = OrgStatusModel.get_default_status()

    if payment_type_info:
        preferred_payment = PaymentTypeModel(code=payment_type_info['code'],
                                             desc=payment_type_info['desc'])
        preferred_payment.save()
    else:
        preferred_payment = PaymentTypeModel.get_default_payment_type()

    org = OrgModel(name=org_info['name'])
    org.org_type = org_type
    org.access_type = org_info.get('accessType', '')
    org.org_status = org_status
    org.created_by_id = user_id
    org.bcol_account_id = bcol_info.get('bcol_account_id', '')
    org.bcol_user_id = bcol_info.get('bcol_user_id', '')
    org.save()

    org.bcol_account_id = bcol_info['bcol_account_id']

    return org