From dc01f894f7d67c8f7bf261231048fa413c99cb3c Mon Sep 17 00:00:00 2001 From: Seth Ladygo Date: Wed, 19 Feb 2020 13:07:23 -0800 Subject: [PATCH] send_locally_feed.py: use profile images --- procat2/management/commands/send_locally_feed.py | 4 +++- products/models.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/procat2/management/commands/send_locally_feed.py b/procat2/management/commands/send_locally_feed.py index 8bce843..2f34925 100644 --- a/procat2/management/commands/send_locally_feed.py +++ b/procat2/management/commands/send_locally_feed.py @@ -116,7 +116,9 @@ class Command(BaseCommand): def image_url(self, material): - paths = ProductImage.get_all_image_urls(material, ProductImageFormat.MED_JPG, True) + views = ['P', 'P2', 'PLA', 'FRONT'] # only want side views + paths = ProductImage.get_all_image_urls(material, ProductImageFormat.MED_JPG, + view_types=views, full_url=True) if len(paths) > 0: return paths[0] else: diff --git a/products/models.py b/products/models.py index 7e46113..102a900 100644 --- a/products/models.py +++ b/products/models.py @@ -92,9 +92,9 @@ class ProductImage: # return path @staticmethod - def get_all_image_paths(sap, image_format): + def get_all_image_paths(sap, image_format, view_types=VIEW_TYPES): paths = [] - for view in ProductImage.VIEW_TYPES: + for view in view_types: path = os.path.join(ProductImage.THUMB_DIR, '{}_{}-{}'.format(sap, view, image_format.value)) if os.path.isfile(path): @@ -108,8 +108,8 @@ class ProductImage: # return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL) @staticmethod - def get_all_image_urls(sap, image_format, full_url=False): - paths = ProductImage.get_all_image_paths(sap, image_format) + def get_all_image_urls(sap, image_format, view_types=VIEW_TYPES, full_url=False): + paths = ProductImage.get_all_image_paths(sap, image_format, view_types) url_prefix = ProductImage.THUMB_URL if full_url: url_prefix = f'https://{settings.PUBLIC_WEB_HOST}{url_prefix}'