blockchain changes certficate

This commit is contained in:
Ubuntu 2024-08-08 11:07:22 +00:00
parent b08f4a111e
commit a2a64bac87
2 changed files with 9 additions and 6 deletions

View File

@ -15,9 +15,10 @@ basepath = BasePath()
# from .utils import render_to_pdf # from .utils import render_to_pdf
def certificateGenrate(name,file_from,Hash,projectname="NAN",matic=0): def certificateGenrate(name,file_from,Hash,projectname="NAN",matic="0"):
main = Certificate.objects.filter(user_name="MyNextFilm") main = Certificate.objects.filter(user_name="MyNextFilm")
matic = int(matic)
matic = matic/10**18
if main: if main:
main1 = Certificate.objects.get(user_name="MyNextFilm") main1 = Certificate.objects.get(user_name="MyNextFilm")
ids = main1.id # blockchain_obj = UserCredentialsForBlockchain.objects.get(user=request.user) ids = main1.id # blockchain_obj = UserCredentialsForBlockchain.objects.get(user=request.user)
@ -36,22 +37,24 @@ def certificateGenrate(name,file_from,Hash,projectname="NAN",matic=0):
"date": date.today(), "date": date.today(),
"hash": Hash, "hash": Hash,
"id": ids, "id": ids,
'Matic':matic, 'Matic':"{:.4f}".format(matic),
'File_name':projectname, 'File_name':projectname,
"basepath":basepath,
} }
template = get_template( template = get_template(
f'{basepath}/lpp/templates/lpp/blockchainCertificate.html') f'{basepath}/lpp/templates/lpp/blockchainCertificate.html')
html = template.render(context) html = template.render(context)
options = { options = {
'page-size': 'A4', 'page-size': 'A5',
'zoom': 3.5,
'margin-top': '0.0in', 'margin-top': '0.0in',
'margin-right': '0.0in', 'margin-right': '0.0in',
'margin-bottom': '0.0in', 'margin-bottom': '0.0in',
'margin-left': '0.0in', 'margin-left': '0.0in',
'enable-local-file-access': '' 'enable-local-file-access': '',
} }
pdfkit.from_string( pdfkit.from_string(
html, f'{basepath}/lpp/certificate/certificate.pdf', options=options,verbose=True) html, f'{basepath}/lpp/certificate/certificate.pdf', options=options)
return f'{basepath}/lpp/certificate/certificate.pdf' return f'{basepath}/lpp/certificate/certificate.pdf'
# certificateGenrate("pravesh yadav","PPT Conversiom", "qwefgfdsdfgdsdcvxs") # certificateGenrate("pravesh yadav","PPT Conversiom", "qwefgfdsdfgdsdcvxs")