11import logging
2- import tempfile
32import os
43from typing import List
54from PIL import Image , ImageDraw , ImageFont
6- from io import BytesIO
75from models .participant import Participant
6+ from config import config
87from certified_builder .utils .fetch_file_certificate import fetch_file_certificate
98from certified_builder .certificates_on_solana import CertificatesOnSolana
109from certified_builder .make_qrcode import MakeQRCode
@@ -33,6 +32,7 @@ def build_certificates(self, participants: List[Participant]):
3332 # Cache for background and logo if they are the same for all participants
3433 certificate_template = None
3534 logo = None
35+ logo_tech_floripa = None
3636
3737 # Check if all participants share the same background and logo
3838 if participants :
@@ -46,6 +46,9 @@ def build_certificates(self, participants: List[Participant]):
4646 if all_same_logo :
4747 logo = self ._download_image (first_participant .certificate .logo )
4848
49+ if not logo_tech_floripa :
50+ logo_tech_floripa = self ._download_image (config .TECH_FLORIPA_LOGO_URL )
51+
4952 for participant in participants :
5053 try :
5154 # Register certificate on Solana, with returned data extract url for verification
@@ -57,7 +60,7 @@ def build_certificates(self, participants: List[Participant]):
5760 "certificate_code" : participant .formated_validation_code ()
5861 }
5962 )
60-
63+
6164 # alteração: agora usamos a função renomeada que apenas extrai o explorer_url
6265 participant .authenticity_verification_url = extract_solana_explorer_url (solana_response = solana_response )
6366
@@ -71,7 +74,7 @@ def build_certificates(self, participants: List[Participant]):
7174 logo = self ._download_image (participant .certificate .logo )
7275
7376 # Generate and save certificate
74- certificate_generated = self .generate_certificate (participant , certificate_template , logo )
77+ certificate_generated = self .generate_certificate (participant , certificate_template , logo , logo_tech_floripa )
7578 certificate_path = self .save_certificate (certificate_generated , participant )
7679
7780 results .append ({
@@ -121,7 +124,7 @@ def _ensure_valid_rgba(self, img: Image) -> Image:
121124 new_img .paste (img .convert ('RGB' ), (0 , 0 ))
122125 return new_img
123126
124- def generate_certificate (self , participant : Participant , certificate_template : Image , logo : Image ):
127+ def generate_certificate (self , participant : Participant , certificate_template : Image , logo : Image , logo_tech_floripa : Image ):
125128 """Generate a certificate for a participant."""
126129 try :
127130 # Ensure images have valid transparency channels
@@ -145,9 +148,10 @@ def generate_certificate(self, participant: Participant, certificate_template: I
145148 # Fallback without using the logo as its own mask
146149 overlay .paste (logo , (50 , 50 ))
147150
148-
151+ url_qr_code = f" { config . TECH_FLORIPA_CERTIFICATE_VALIDATE_URL } ?validate_code= { participant . formated_validation_code () } "
149152 qrcode_size = (150 , 150 )
150- qr_code_image_io = MakeQRCode .generate_qr_code (participant .authenticity_verification_url )
153+ logger .info (f"URL do QR code: { url_qr_code } para o certificado de { participant .name_completed ()} " )
154+ qr_code_image_io = MakeQRCode .generate_qr_code (url_qr_code , logo_tech_floripa = logo_tech_floripa )
151155 qr_code_image = Image .open (qr_code_image_io ).convert ("RGBA" )
152156 # comentário: para manter o QR nítido, usamos NEAREST ao redimensionar
153157 if qr_code_image .size != qrcode_size :
0 commit comments