fix: added default product image, removed empty tables prints, fixed barcode output

This commit is contained in:
2024-09-23 01:24:43 +04:00
parent 973351a3af
commit 52681f3f61
4 changed files with 88 additions and 62 deletions

View File

@@ -1027,7 +1027,14 @@ class DealService(BaseService):
general_services_total = sum((service.price * service.quantity for service in deal.services))
product_services_totals = await self._get_product_services_totals(deal)
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({
"general_services_total": general_services_total,

View File

@@ -39,12 +39,12 @@ hr {
.small-text {
font-size: 12px;
margin-bottom: 5px;
margin-bottom: 4px;
}
.medium-text {
font-size: 15px;
margin-bottom: 5px;
margin-bottom: 6px;
}
.large-text {
@@ -150,8 +150,9 @@ table tfoot {
}
.barcode-container {
margin: 15px 0 -5px 385px;
margin: 15px 0 -5px 355px;
display: flex;
white-space: nowrap;
flex-direction: column;
align-items: center;
}

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,14 @@
import asyncio
import base64
from typing import List, Tuple
from typing import List, Tuple, Optional
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 session.get(url) as response:
if response.status == 200:
@@ -15,6 +18,6 @@ async def fetch_image(url: str) -> str:
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]
return await asyncio.gather(*tasks)