예제 #1
0
def create_product_with_thing_type(
    thing_name: str = "Test Book",
    thing_type: ThingType = ThingType.LIVRE_EDITION,
    author_name: str = "Test Author",
    is_national: bool = False,
    id_at_providers: str = None,
    idx: int = None,
    is_digital: bool = False,
    is_gcu_compatible: bool = True,
    is_offline_only: bool = False,
    date_modified_at_last_provider: datetime = None,
    last_provider_id: int = None,
    media_urls: Iterable[str] = ("test/urls", ),
    description: str = None,
    thumb_count: int = 1,
    url: str = None,
    owning_offerer: Offerer = None,
    extra_data: Dict = None,
) -> Product:
    product = Product()
    product.id = idx
    product.type = str(thing_type)
    product.name = thing_name
    product.description = description
    if extra_data:
        product.extraData = extra_data
    else:
        product.extraData = {"author": author_name}
    product.isNational = is_national
    if id_at_providers is None:
        id_at_providers = "".join(random.choices(string.digits, k=13))
    product.dateModifiedAtLastProvider = date_modified_at_last_provider
    product.lastProviderId = last_provider_id
    product.idAtProviders = id_at_providers
    product.isGcuCompatible = is_gcu_compatible
    product.mediaUrls = media_urls
    product.thumbCount = thumb_count
    product.url = url
    product.owningOfferer = owning_offerer
    product.description = description
    if is_digital:
        product.url = "fake/url"
    if is_offline_only:
        product.type = str(ThingType.CINEMA_ABO)

    return product
예제 #2
0
    def fill_object_attributes(self, product: Product):
        product.name = trim_with_elipsis(self.product_infos["titre"], 140)
        product.datePublished = read_things_date(
            self.product_infos["date_parution"])
        product.type = self.product_type
        product.extraData = self.product_extra_data.copy()
        product.extraData.update(get_extra_data_from_infos(self.product_infos))

        if self.product_infos["url_extrait_pdf"] != "":
            if product.mediaUrls is None:
                product.mediaUrls = []

            product.mediaUrls.append(self.product_infos["url_extrait_pdf"])
    def fill_object_attributes(self, product: Product):
        product.name = trim_with_elipsis(self.product_infos["titre"], 140)
        product.datePublished = read_things_date(
            self.product_infos["date_parution"])
        subcategory = subcategories.ALL_SUBCATEGORIES_DICT[
            self.product_subcategory_id]
        product.subcategoryId = subcategory.id
        product.extraData = self.product_extra_data.copy()
        product.extraData.update(get_extra_data_from_infos(self.product_infos))

        if self.product_infos["url_extrait_pdf"] != "":
            if product.mediaUrls is None:
                product.mediaUrls = []

            product.mediaUrls.append(self.product_infos["url_extrait_pdf"])
예제 #4
0
    def fill_product_attributes(self, allocine_product: Product):
        allocine_product.name = self.movie_information["title"]
        allocine_product.type = str(EventType.CINEMA)
        allocine_product.thumbCount = 0
        if "description" in self.movie_information:
            allocine_product.description = self.movie_information[
                "description"]
        if "duration" in self.movie_information:
            allocine_product.durationMinutes = self.movie_information[
                "duration"]
        if not allocine_product.extraData:
            allocine_product.extraData = {}
        if "visa" in self.movie_information:
            allocine_product.extraData["visa"] = self.movie_information["visa"]
        if "stageDirector" in self.movie_information:
            allocine_product.extraData[
                "stageDirector"] = self.movie_information["stageDirector"]

        is_new_product_to_insert = allocine_product.id is None

        if is_new_product_to_insert:
            allocine_product.id = get_next_product_id_from_database()
        self.last_product_id = allocine_product.id