コード例 #1
0
def create_offerer(
    address: str = None,
    city: str = "Montreuil",
    date_created: datetime = datetime.utcnow(),
    date_modified_at_last_provider: datetime = None,
    idx: int = None,
    id_at_providers: str = None,
    is_active: bool = True,
    last_provider_id: int = None,
    name: str = "Test Offerer",
    postal_code: str = "93100",
    siren: Optional[str] = "123456789",
    thumb_count: int = 0,
    validation_token: str = None,
    date_validated: datetime = None,
) -> Offerer:
    offerer = Offerer()
    offerer.address = address
    offerer.city = city
    offerer.dateCreated = date_created
    offerer.dateModifiedAtLastProvider = date_modified_at_last_provider
    offerer.id = idx
    offerer.idAtProviders = id_at_providers
    offerer.isActive = is_active
    offerer.lastProviderId = last_provider_id
    offerer.name = name
    offerer.postalCode = postal_code
    offerer.siren = siren
    offerer.thumbCount = thumb_count
    offerer.validationToken = validation_token
    offerer.dateValidated = date_validated

    return offerer
コード例 #2
0
def create_offerer_from_csv(row: dict) -> Offerer:
    offerer = Offerer()
    offerer.name = row["nom_structure"] if row["nom_structure"] else row["Name"]
    offerer.siren = row["SIREN"]
    offerer.address = _get_address_from_row(row)
    offerer.postalCode = _get_postal_code(row)
    offerer.city = row["City"]

    return offerer
コード例 #3
0
ファイル: api.py プロジェクト: pass-culture/pass-culture-api
def create_offerer(user: User, offerer_informations: CreateOffererQueryModel):
    offerer = find_offerer_by_siren(offerer_informations.siren)

    if offerer is not None:
        user_offerer = offerer.grant_access(user)
        user_offerer.generate_validation_token()
        repository.save(user_offerer)

    else:
        offerer = Offerer()
        offerer.address = offerer_informations.address
        offerer.city = offerer_informations.city
        offerer.name = offerer_informations.name
        offerer.postalCode = offerer_informations.postalCode
        offerer.siren = offerer_informations.siren
        offerer.generate_validation_token()
        digital_venue = create_digital_venue(offerer)
        user_offerer = offerer.grant_access(user)
        repository.save(offerer, digital_venue, user_offerer)

    _send_to_pc_admin_offerer_to_validate_email(offerer, user_offerer)

    return user_offerer