def remove_thumb( model_with_thumb: Model, image_index: int, ) -> None: object_storage.delete_public_object( bucket="thumbs", object_id=model_with_thumb.get_thumb_storage_id(image_index), )
def validate(model: Model, api_errors: ApiErrors) -> ApiErrors: if model.isDigital and model.is_offline_only(): api_errors.add_error( "url", f"Une offre de type {model.get_label_from_type_string()} ne peut pas être numérique" ) return api_errors
def _save_same_thumb_from_thumb_count_to_index(pc_object: Model, thumb_index: int, image_as_bytes: bytes): if pc_object.thumbCount is None: # handle unsaved object pc_object.thumbCount = 0 if thumb_index <= pc_object.thumbCount: # replace existing thumb create_thumb(pc_object, image_as_bytes, thumb_index) else: # add new thumb for index in range(pc_object.thumbCount, thumb_index): create_thumb(pc_object, image_as_bytes, index) pc_object.thumbCount += 1
def create_thumb( model_with_thumb: Model, image_as_bytes: bytes, image_index: int, crop_params: tuple = None, ) -> None: image_as_bytes = standardize_image(image_as_bytes, crop_params) object_storage.store_public_object( bucket=settings.BASE_BUCKET_NAME, object_id=model_with_thumb.get_thumb_storage_id(image_index), blob=image_as_bytes, content_type="image/jpeg", )
def create_thumb( model_with_thumb: Model, image_as_bytes: bytes, image_index: int, crop_params: tuple = None, symlink_path: str = None, use_v2: bool = False, ) -> None: if use_v2: image_as_bytes = standardize_image_v2(image_as_bytes, crop_params) else: image_as_bytes = standardize_image(image_as_bytes, crop_params) object_storage.store_public_object( bucket="thumbs", object_id=model_with_thumb.get_thumb_storage_id(image_index), blob=image_as_bytes, content_type="image/jpeg", symlink_path=symlink_path, )
def fill_object_attributes(self, pc_object: Model): pc_object.name = "New Product" pc_object.type = str(ThingType.LIVRE_EDITION)
def fill_object_attributes(self, pc_object: Model): pc_object.name = "New Product" pc_object.subcategoryId = subcategories.LIVRE_PAPIER.id