quickinfo: show all images for a material
This commit is contained in:
@ -60,19 +60,34 @@ class ProductImage:
|
|||||||
'T', 'TL', 'PACK', 'F', 'B', 'INT', 'ALT_INT', 'FLR',
|
'T', 'TL', 'PACK', 'F', 'B', 'INT', 'ALT_INT', 'FLR',
|
||||||
'FRONT', 'BACK']
|
'FRONT', 'BACK']
|
||||||
|
|
||||||
|
# @staticmethod
|
||||||
|
# def get_image_path(sap, image_format):
|
||||||
|
# for view in ProductImage.VIEW_TYPES:
|
||||||
|
# path = os.path.join(ProductImage.THUMB_DIR,
|
||||||
|
# '{}_{}-{}'.format(sap, view, image_format.value))
|
||||||
|
# if os.path.isfile(path):
|
||||||
|
# return path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_image_path(sap, image_format):
|
def get_all_image_paths(sap, image_format):
|
||||||
|
paths = []
|
||||||
for view in ProductImage.VIEW_TYPES:
|
for view in ProductImage.VIEW_TYPES:
|
||||||
path = os.path.join(ProductImage.THUMB_DIR,
|
path = os.path.join(ProductImage.THUMB_DIR,
|
||||||
'{}_{}-{}'.format(sap, view, image_format.value))
|
'{}_{}-{}'.format(sap, view, image_format.value))
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
return path
|
paths.append(path)
|
||||||
|
return paths
|
||||||
|
|
||||||
|
# @staticmethod
|
||||||
|
# def get_image_url(sap, image_format):
|
||||||
|
# path = ProductImage.get_image_path(sap, image_format)
|
||||||
|
# if path:
|
||||||
|
# return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_image_url(sap, image_format):
|
def get_all_image_urls(sap, image_format):
|
||||||
path = ProductImage.get_image_path(sap, image_format)
|
paths = ProductImage.get_all_image_paths(sap, image_format)
|
||||||
if path:
|
return [p.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL) for p in paths]
|
||||||
return path.replace(ProductImage.THUMB_DIR, ProductImage.THUMB_URL)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ def result(request):
|
|||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
context['prod'] = None
|
context['prod'] = None
|
||||||
|
|
||||||
context['image'] = ProductImage.get_image_url(id, ProductImageFormat.MED_JPG)
|
context['images'] = ProductImage.get_all_image_urls(id, ProductImageFormat.MED_JPG)
|
||||||
|
|
||||||
return render(request, 'quickinfo/result.html', context)
|
return render(request, 'quickinfo/result.html', context)
|
||||||
|
|
||||||
|
|||||||
@ -9,18 +9,22 @@
|
|||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
height: 100%;
|
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
background-color: #535353;
|
background-color: #535353;
|
||||||
}
|
}
|
||||||
#both {
|
#both {
|
||||||
width: 400px;
|
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
box-shadow: 8px 8px 12px 0 rgba(0, 0, 0, 0.3);
|
box-shadow: 8px 8px 12px 0 rgba(0, 0, 0, 0.3);
|
||||||
position: relative;
|
position: relative;
|
||||||
|
margin: 0 auto;
|
||||||
|
width: -webkit-fit-content;
|
||||||
|
width: -moz-fit-content;
|
||||||
|
width: fit-content;
|
||||||
}
|
}
|
||||||
#image {
|
#image {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
|
width: 250px;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
#data {
|
#data {
|
||||||
border-top: 4px solid hsl(52, 100%, 50%);
|
border-top: 4px solid hsl(52, 100%, 50%);
|
||||||
@ -62,9 +66,13 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="both">
|
<div id="both">
|
||||||
<img class="logo" src="/static/img/keen_logo.svg" width="90">
|
<img class="logo" src="/static/img/keen_logo.svg" width="90">
|
||||||
{% if image %}
|
{% if images %}
|
||||||
<div id="image">
|
<div id="images">
|
||||||
<a href="{{ image }}"><img src="{{ image }}"/></a>
|
{% for image in images %}
|
||||||
|
<div id="image">
|
||||||
|
<a href="{{ image }}"><img src="{{ image }}"/></a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="notfound">Image not found</p>
|
<p class="notfound">Image not found</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user