refractored code, renamed columns in pdf attachment

This commit is contained in:
karthik murakonda 2022-05-03 01:41:00 +05:30
parent 8c474e5c45
commit 0a63fb0030
2 changed files with 10 additions and 7 deletions

View File

@ -121,6 +121,12 @@ STUDENT_LIST = "student_list"
STUDENT_ID = "student_id"
STUDENT_SELECTED = "student_selected"
EXCLUDE_IN_PDF = ['id', 'is_company_details_pdf', 'offer_accepted', 'is_description_pdf',
'is_compensation_details_pdf', 'is_selection_procedure_details_pdf',
'email_verified', 'created_at']
SPECIAL_FORMAT_IN_PDF = ['website', 'company_details_pdf_names', 'description_pdf_names', 'compensation_details_pdf_names',
'selection_procedure_pdf_names']
COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT = "Notification Submitted - {id} - Career Development Cell, IIT Dharwad"
STUDENT_APPLICATION_STATUS_TEMPLATE_SUBJECT = 'Application Status : {company_name} - {id}'
STUDENT_APPLICATION_SUBMITTED_TEMPLATE_SUBJECT = 'CDC - Application Submitted - {company_name}'

View File

@ -276,24 +276,21 @@ def verify_recaptcha(request):
def opening_description_table_html(opening):
details = model_to_dict(opening, fields=[field.name for field in Placement._meta.fields],
exclude=['id', 'is_company_details_pdf', 'offer_accepted', 'is_description_pdf',
'is_compensation_details_pdf', 'is_selection_procedure_details_pdf',
'email_verified'])
exclude=EXCLUDE_IN_PDF)
keys = list(details.keys())
newdetails = {}
for key in keys:
if isinstance(details[key], list):
details[key] = {"details": details[key], "type": ["list"]}
if key in ['website', 'company_details_pdf_names', 'description_pdf_names', 'compensation_details_pdf_names',
'selection_procedure_pdf_names']:
if key in SPECIAL_FORMAT_IN_PDF:
if key == 'website':
details[key] = {"details": details[key], "type": ["link"]}
else:
details[key] = {"details": details[key]["details"], "type": ["list", "link"],
"link": PDF_FILES_SERVING_ENDPOINT + opening.id + "/"}
new_key = key.replace('_', ' ')
if key.endswith(' names'):
new_key = key[:-6]
if new_key.endswith(' names'):
new_key = new_key[:-6]
new_key = new_key.capitalize()
newdetails[new_key] = details[key]
imagepath = os.path.abspath('./templates/image.png')