Untitled
class ProgamExportResource(resources.ModelResource): # Export fields application_pdf_template = i_e_fields.Field( column_name='application_pdf_template', attribute='application_pdf_template', widget=APTFieldWidget() ) offer_letter_template = i_e_fields.Field( column_name='offer_letter_template', attribute='offer_letter_template', widget=OLTFieldWidget() ) # Import fields eligibility_criteria = i_e_fields.Field( column_name='eligibility_criteria', attribute='eligibility_criteria' ) degree_type = i_e_fields.Field( column_name='degree_type', attribute='degree_type' ) class Meta: model = Program # Fields available for export fields = ( 'program_type', 'program_code', 'program_name', 'form_title', 'alternative_program_code', 'application_pdf_template', 'offer_letter_template', 'collaborating_organization', 'active_for_applicaton_flag', 'document_submission_flag', 'active_for_admission_flag', 'show_on_page_flag', 'serial_number_on_page', 'show_to_fee_wvr_appl_flag', 'work_exp_check_req', 'mentor_id_req', 'min_work_exp_in_months', 'hr_cont_req', 'is_eduvanz_emi_enable', 'is_ezcred_emi_enable', 'is_propelld_emi_enable', 'eduvanz_location', 'propelld', 'propelld_course_id', 'enable_pre_selection_flag', 'gq_emi_enable_flag', 'gq_plan_id', 'current_and_prior_employment_details_flag', 'payu_enable_flag', 'av_emi_enable_flag', 'av_course_code' ) # Fields available for import import_id_fields = ('id',) # Fields used to identify records during import import_fields = ('id', 'program_code', 'program_name', 'eligibility_criteria', 'degree_type') export_order = fields def before_import_row(self, row, **kwargs): """ Hook to validate or modify data before importing each row. """ # Add custom validation for degree_type degree_type = row.get('degree_type') valid_types = dict(Program.DEGREE_TYPE_CHOICES).keys() if degree_type not in valid_types: raise ValueError(f"Invalid degree type: {degree_type}")
Leave a Comment