Skip to content

Commit

Permalink
feat: taxi form data in exec-ed ingestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-D-Akbar committed Oct 7, 2024
1 parent 1262d9f commit 45d63f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions course_discovery/apps/course_metadata/data_loaders/csv_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,18 @@ def process_meta_information(self, meta_title, meta_description, meta_keywords):
'keywords': [keyword.strip() for keyword in meta_keywords.split(',')] if meta_keywords else []
}

def process_taxi_form_information(self, form_id, post_submit_url):
"""
Return a dict containing processed product taxi form information.
"""
if not any([form_id, post_submit_url]):
return {}

return {
'form_id': form_id,
'post_submit_url': post_submit_url,
}

def get_additional_metadata_dict(self, data, type_slug):
"""
Return the appropriate additional metadata dict representation, skipping the keys that are not
Expand All @@ -871,6 +883,9 @@ def get_additional_metadata_dict(self, data, type_slug):
if type_slug not in [CourseType.EXECUTIVE_EDUCATION_2U, CourseType.BOOTCAMP_2U]:
return {}

taxi_form = self.process_taxi_form_information(
data.get('taxi_form_id', ''), data.get('post_submit_url', '')
)
additional_metadata = {
'external_url': data['redirect_url'],
'external_identifier': data['external_identifier'],
Expand Down Expand Up @@ -915,4 +930,6 @@ def get_additional_metadata_dict(self, data, type_slug):
)})
if external_course_marketing_type in dict(ExternalCourseMarketingType.choices):
additional_metadata.update({'external_course_marketing_type': external_course_marketing_type})
if taxi_form:
additional_metadata.update({'taxi_form': taxi_form})
return additional_metadata
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Command(BaseCommand):
'lead_capture_form_url', 'certificate_header', 'certificate_text', 'stat1', 'stat1_text', 'stat2',
'stat2_text', 'organic_url', 'organization_short_code_override', 'organization_logo_override', 'variant_id',
'meta_title', 'meta_description', 'meta_keywords', 'slug', 'external_course_marketing_type', 'restriction_type',
'fixed_price_usd',
'fixed_price_usd', 'taxi_form_id', 'post_submit_url'
]

# Mapping English and Spanish languages to IETF equivalent variants
Expand Down Expand Up @@ -381,4 +381,6 @@ def get_transformed_data(self, partially_filled_csv_dict, product_dict):
product_dict['logoUrl']
),
'external_course_marketing_type': product_dict['productType'],
'taxi_form_id': product_dict['edxTaxiFormId'],
'post_submit_url': utils.format_base64_strings(product_dict['prospectusUrl']),
}

0 comments on commit 45d63f3

Please sign in to comment.