From e731249cb5691a82b922c492b508da698fb3f00f Mon Sep 17 00:00:00 2001 From: ayishanishana21 Date: Tue, 22 Sep 2026 12:21:53 +0530 Subject: [PATCH 1/3] certificate template changes --- events/certificates.py | 89 ++++++++++++++++++++++++++++++++++++++---- events/views.py | 45 ++++++++++++++------- events/viewsv2.py | 23 ++++++++++- 3 files changed, 132 insertions(+), 25 deletions(-) diff --git a/events/certificates.py b/events/certificates.py index fc4a0d826..d4e628329 100644 --- a/events/certificates.py +++ b/events/certificates.py @@ -1,5 +1,5 @@ from django.conf import settings -from spoken.config import EDUPYRAMIDS_CERTIFICATE_DATE +from spoken.config import EDUPYRAMIDS_CERTIFICATE_DATE,WGF_INSTITUTIONS import re import os @@ -20,7 +20,44 @@ 'fdp_test': 'fdp-test-certificate_edupyramids.pdf', } -def get_cert_template(event_date, cert_type): +WGF = { + 'stp': 'Blank-Certificate_edupyramids_wgf.pdf', +} + +def is_wgf_institution(academic_code): + return academic_code in WGF_INSTITUTIONS + + +def get_participation_certificate_title(academic_code,normal_title_y,wgf_title_y): + """ + Returns participation certificate title and title position. + """ + if academic_code in WGF_INSTITUTIONS: + certificate_title = "Certificate of Participation" + title_y = wgf_title_y + else: + certificate_title = "Participation Certificate" + title_y = normal_title_y + + return certificate_title, title_y + + +def get_completion_certificate_title(academic_code,normal_title_y,wgf_title_y,foss_name): + """ + Returns completion certificate title and title position. + """ + if academic_code in WGF_INSTITUTIONS: + certificate_title = "Course Completion Certificate" + title_y = wgf_title_y + else: + certificate_title = ("Certificate for the Completion of
"+ foss_name+ " Training") + title_y = normal_title_y + + return certificate_title, title_y + +def get_cert_template(event_date, cert_type, academic_code=None): + if academic_code in WGF_INSTITUTIONS: + return os.path.join(settings.MEDIA_ROOT, WGF['stp']) if event_date < EDUPYRAMIDS_CERTIFICATE_DATE: return os.path.join(settings.MEDIA_ROOT, SPK[cert_type]) return os.path.join(settings.MEDIA_ROOT, EDUPYRAMIDS[cert_type]) @@ -31,14 +68,14 @@ def get_training_certificate(ta): return training certificate template path ta : TrainingAttend obj """ - + academic_code = ta.training.training_planner.academic.academic_code if ta.training.department.id == FDP: cert_type = 'fdp' elif ta.training.training_planner.academic.institution_type_id == CSC: cert_type = 'csc' else: cert_type = 'stp' - return get_cert_template(ta.training.training_start_date, cert_type) + return get_cert_template(ta.training.training_start_date, cert_type, academic_code) def get_test_certificate(ta): @@ -46,13 +83,15 @@ def get_test_certificate(ta): return test certificate template path ta : TestAttendance obj """ + + academic_code = ta.test.academic.academic_code if ta.test.training.department.id == FDP: cert_type = 'fdp_test' elif ta.test.academic.institution_type_id == CSC: cert_type = 'csc' else: cert_type = 'stp' - return get_cert_template(ta.test.tdate, cert_type) + return get_cert_template(ta.test.tdate, cert_type, academic_code) def get_signature(event_date): @@ -71,9 +110,25 @@ def get_training_cert_text(ta): """ name = f"{ta.student.user.first_name} {ta.student.user.last_name}" foss = ta.training.course.foss.foss + + academic = ta.training.training_planner.academic + academic_code = academic.academic_code + institution_name = ta.training.training_planner.academic.institution_name organization = get_organization(ta.training.training_start_date) - + org_course_material = "EduPyramids, SINE, IIT Bombay" + org_training = "This training is offered through SWAYAM Plus by EduPyramids, SINE, IIT Bombay" + + if is_wgf_institution(academic_code): + text = ( + f"This is to certify that {name} has participated in the " + f"{foss} training, offered by " + f"EduPyramids, SINE, IIT Bombay." + f"

" + f"A comprehensive set of topics pertaining to " + f"{foss} was covered in the training." + ) + return text semsplit = re.split('-|, ',ta.training.training_planner.get_semester()) sem_start = semsplit[0]+semsplit[2] @@ -102,12 +157,30 @@ def get_test_cert_text(test, mdluser, credits=''): name = f"{mdluser.firstname} {mdluser.lastname}" foss = test.foss.foss test_date = test.tdate.strftime("%d-%m-%Y") - + academic = test.academic + academic_code = academic.academic_code institution = test.academic.institution_name organization = get_organization(test.training.training_start_date) organizer = f"{test.organiser.user.first_name} {test.organiser.user.last_name}" invigilator = f"{test.invigilator.user.first_name} {test.invigilator.user.last_name}" - text_end = f"This training is offered by {organization}" + text_end = f"{org_training}" + + # WGF completion certificate text + if is_wgf_institution(academic_code): + text = ( + f"This is to certify that {name} has successfully " + f"completed the course {foss}, offered by " + f"EduPyramids, SINE, IIT Bombay." + f"

" + f"Passing an online exam conducted remotely by EduPyramids " + f"is a prerequisite to complete this course. " + f"WHEELS Global Foundation organised the invigilation " + f"of this exam." + f"

" + f"{credits}" + ) + return text + #paragraphe if test.training.department.id == FDP: diff --git a/events/views.py b/events/views.py index 9e649416a..572ed598f 100644 --- a/events/views.py +++ b/events/views.py @@ -7,6 +7,7 @@ from rq.job import Job from rq.exceptions import NoSuchJobError from cron import REDIS_CLIENT +from spoken.config import WGF_INSTITUTIONS def get_batches(request): school_id = request.GET.get('school_id') @@ -2492,19 +2493,24 @@ def test_participant_ceritificate(request, wid, participant_id): p.wrap(700, 200) p.drawOn(imgDoc, 3 * cm, 6.5 * cm) - #paragraphe - text = "Certificate for the Completion of
"+w.foss.foss+" Training" + # Certificate title + academic_code = w.academic.academic_code + certificate_title, title_y = get_completion_certificate_title( + academic_code=academic_code, + normal_title_y=17 * cm, + wgf_title_y=14.2 * cm, + foss_name=w.foss.foss + ) centered = ParagraphStyle(name = 'centered', fontSize = 25, leading = 25, alignment = 1, spaceAfter = 15) - p = Paragraph(text, centered) + p = Paragraph(certificate_title, centered) p.wrap(500,20) - p.drawOn(imgDoc, 6.2 * cm, 17 * cm) - + p.drawOn(imgDoc, 6.2 * cm, title_y) imgDoc.save() @@ -2592,18 +2598,27 @@ def test_participant_ceritificate_all(request, testid): p.wrap(700, 200) p.drawOn(imgDoc, 3 * cm, 6.5 * cm) - #paragraphe - text = "Certificate for Completion of
"+w.foss.foss+" Training" + academic_code = w.academic.academic_code - centered = ParagraphStyle(name = 'centered', - fontSize = 25, - leading = 25, - alignment = 1, - spaceAfter = 15) + certificate_title, title_y = get_completion_certificate_title( + academic_code=academic_code, + normal_title_y=17 * cm, + wgf_title_y=14.2 * cm, + foss_name=w.foss.foss + ) - p = Paragraph(text, centered) - p.wrap(500,20) - p.drawOn(imgDoc, 6.2 * cm, 17 * cm) + centered = ParagraphStyle( + name='certificate_title', + fontSize=25, + leading=25, + alignment=1, + spaceAfter=0 + ) + + p = Paragraph(certificate_title, centered) + p.wrap(600, 100) + p.drawOn(imgDoc,6.2 * cm,title_y) + imgDoc.save() template_path = get_test_certificate(ta) page = PdfFileReader(open(template_path,"rb")).getPage(0) diff --git a/events/viewsv2.py b/events/viewsv2.py index 0d9cda08c..969096496 100755 --- a/events/viewsv2.py +++ b/events/viewsv2.py @@ -85,6 +85,7 @@ from cms.management.commands.populate_subscription_data import update_subscription, get_users_from_acad from spoken.config import BASIC_LEVEL_INSTITUTIONS +from spoken.config import WGF_INSTITUTIONS class JSONResponseMixin(object): @@ -948,7 +949,16 @@ def training_certificate(self, ta): # Title imgDoc.setFont('Helvetica', 35, leading=None) - imgDoc.drawCentredString(405, 470, "Certificate of Participation") + + academic_code = ta.training.training_planner.academic.academic_code + + certificate_title, title_y = get_participation_certificate_title( + academic_code=academic_code, + normal_title_y=470, + wgf_title_y=400 + ) + + imgDoc.drawCentredString(405, title_y, certificate_title) #date if ta.training.department.id != 169: @@ -3314,7 +3324,16 @@ def get(self, request, *args, **kwargs): # Title imgDoc.setFont('Helvetica', 35, leading=None) - imgDoc.drawCentredString(405, 480, "Certificate of Participation") + + academic_code = ta.training.training_planner.academic.academic_code + + certificate_title, title_y = get_participation_certificate_title( + academic_code=academic_code, + normal_title_y=480, + wgf_title_y=410 + ) + + imgDoc.drawCentredString(405, title_y, certificate_title) #date if ta.training.department.id != 169: From 47098a14ccb3dc5959c5eb3dc6171ef1df835920 Mon Sep 17 00:00:00 2001 From: ayishanishana21 Date: Tue, 22 Sep 2026 21:49:38 +0530 Subject: [PATCH 2/3] fixed org_training error --- events/certificates.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/events/certificates.py b/events/certificates.py index d4e628329..39207514a 100644 --- a/events/certificates.py +++ b/events/certificates.py @@ -160,7 +160,9 @@ def get_test_cert_text(test, mdluser, credits=''): academic = test.academic academic_code = academic.academic_code institution = test.academic.institution_name - organization = get_organization(test.training.training_start_date) + # organization = get_organization(test.training.training_start_date) + org_course_material = "EduPyramids, SINE, IIT Bombay" + org_training = "This training is offered through SWAYAM Plus by EduPyramids, SINE, IIT Bombay" organizer = f"{test.organiser.user.first_name} {test.organiser.user.last_name}" invigilator = f"{test.invigilator.user.first_name} {test.invigilator.user.last_name}" text_end = f"{org_training}" @@ -184,9 +186,9 @@ def get_test_cert_text(test, mdluser, credits=''): #paragraphe if test.training.department.id == FDP: - text = f"This is to certify that {name} has successfully completed {foss} test on {test_date} organized at {institution} by {organizer} with course material provided by {organization}. Passing an online exam, conducted remotely from IIT Bombay, is a pre-requisite for completing this Faculty Development Programme.

{invigilator} at {institution} invigilated this examination. {text_end}.



{credits}" - elif test.academic.institution_type_id == CSC: # CHECK #TODO - text = f"This is to certify that {name} has successfully completed {foss} test organized at {institution} by {organizer} with course material provided by {organization}. Passing an online exam, conducted remotely from IIT Bombay, is a pre-requisite for completing this training. {invigilator} at {institution} invigilated this examination.
This training is offered by the Spoken Tutorial Project, IIT Bombay, funded by National Mission on Education through ICT, Ministry of Education, Govt., of India." + text = f"This is to certify that {name} has successfully completed {foss} test on {test_date} organized at {institution} by {organizer} with course material provided by {org_course_material}. Passing an online exam, conducted remotely from IIT Bombay, is a pre-requisite for completing this Faculty Development Programme.

{invigilator} at {institution} invigilated this examination. {text_end}.



{credits}" + elif test.academic.institution_type_id == CSC: # CHECK + text = f"This is to certify that {name} has successfully completed {foss} test organized at {institution} by {organizer} with course material provided by {org_course_material}. Passing an online exam, conducted remotely from IIT Bombay, is a pre-requisite for completing this training. {invigilator} at {institution} invigilated this examination.
This training is offered by the Spoken Tutorial Project, IIT Bombay, funded by National Mission on Education through ICT, Ministry of Education, Govt., of India." else: - text = f"This is to certify that {name} has successfully completed {foss} test organized at {institution} by {organizer} with course material provided by {organization}. Passing an online exam, conducted remotely from IIT Bombay, is a pre-requisite for completing this training.

{invigilator} from {institution} invigilated this examination. {text_end}.



{credits}" + text = f"This is to certify that {name} has successfully completed {foss} test organized at {institution} by {organizer} with course material provided by {org_course_material}. Passing an online exam, conducted remotely from IIT Bombay, is a pre-requisite for completing this training.

{invigilator} from {institution} invigilated this examination. {text_end}.



{credits}" return text \ No newline at end of file From c1e262ff71199cb9add6218313b348e79670ab7d Mon Sep 17 00:00:00 2001 From: ayishanishana21 Date: Wed, 23 Sep 2026 10:26:29 +0530 Subject: [PATCH 3/3] title condition added in the certificate --- events/certificates.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/events/certificates.py b/events/certificates.py index 39207514a..e3916d56d 100644 --- a/events/certificates.py +++ b/events/certificates.py @@ -33,10 +33,11 @@ def get_participation_certificate_title(academic_code,normal_title_y,wgf_title_y Returns participation certificate title and title position. """ if academic_code in WGF_INSTITUTIONS: - certificate_title = "Certificate of Participation" + certificate_title = "Participation Certificate" title_y = wgf_title_y else: - certificate_title = "Participation Certificate" + certificate_title = "Certificate of Participation" + title_y = normal_title_y return certificate_title, title_y