fix: added default product image, removed empty tables prints, fixed barcode output
This commit is contained in:
@@ -1027,7 +1027,14 @@ class DealService(BaseService):
|
|||||||
general_services_total = sum((service.price * service.quantity for service in deal.services))
|
general_services_total = sum((service.price * service.quantity for service in deal.services))
|
||||||
product_services_totals = await self._get_product_services_totals(deal)
|
product_services_totals = await self._get_product_services_totals(deal)
|
||||||
template = ENV.get_template("deal.html")
|
template = ENV.get_template("deal.html")
|
||||||
product_images = await fetch_images([product.product.images[0].image_url for product in deal.products])
|
|
||||||
|
product_urls: List[Optional[str]] = []
|
||||||
|
for product in deal.products:
|
||||||
|
if len(product.product.images) > 0:
|
||||||
|
product_urls.append(product.product.images[0].image_url)
|
||||||
|
else:
|
||||||
|
product_urls.append(None)
|
||||||
|
product_images = await fetch_images(product_urls)
|
||||||
|
|
||||||
result = template.render({
|
result = template.render({
|
||||||
"general_services_total": general_services_total,
|
"general_services_total": general_services_total,
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ hr {
|
|||||||
|
|
||||||
.small-text {
|
.small-text {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.medium-text {
|
.medium-text {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.large-text {
|
.large-text {
|
||||||
@@ -150,8 +150,9 @@ table tfoot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.barcode-container {
|
.barcode-container {
|
||||||
margin: 15px 0 -5px 385px;
|
margin: 15px 0 -5px 355px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
white-space: nowrap;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,11 +1,14 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple, Optional
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
|
|
||||||
async def fetch_image(url: str) -> str:
|
async def fetch_image(url: Optional[str]) -> str:
|
||||||
|
if not url:
|
||||||
|
return ""
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(url) as response:
|
async with session.get(url) as response:
|
||||||
if response.status == 200:
|
if response.status == 200:
|
||||||
@@ -15,6 +18,6 @@ async def fetch_image(url: str) -> str:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
async def fetch_images(urls: List[str]) -> Tuple[str]:
|
async def fetch_images(urls: List[Optional[str]]) -> Tuple[str]:
|
||||||
tasks = [fetch_image(url) for url in urls]
|
tasks = [fetch_image(url) for url in urls]
|
||||||
return await asyncio.gather(*tasks)
|
return await asyncio.gather(*tasks)
|
||||||
|
|||||||
Reference in New Issue
Block a user