mitodl / ocw-studio

Open Source Courseware authoring tool
BSD 3-Clause "New" or "Revised" License
7 stars 3 forks source link

fix: metadata fields for migration rules #2163

Closed HussainTaj-arbisoft closed 2 months ago

HussainTaj-arbisoft commented 2 months ago

What are the relevant tickets?

Relates to https://github.com/mitodl/ocw-hugo-projects/pull/292

Description (What does it do?)

With https://github.com/mitodl/ocw-hugo-projects/pull/292 merged, the default metadata will have a title field. When migration is run on older data to create new external resource objects, those objects will have a title in their metadata field. This will cause the menu item selection UI to misbehave on Studio. This is because it prefers website_content.metadata.title over website_content.title (which is the default location of the title).

This PR prevents title from being added to the metadata and keeps the structure consistent with what normal flow gets us.

This PR also fixes a spelling error in a field name has_external_licence_warning -> has_external_license_warning.

How can this be tested?

  1. Navigate to your local ocw-studio setup.
  2. Checkout branch external-resource-add-title-field.
  3. Start/Restart Studio.
  4. Follow the instructions in https://github.com/mitodl/ocw-hugo-projects/pull/292 to load the starter config.
  5. Create a course.
  6. Create a page in that course.
  7. Create a markdown link on that page.
  8. Save the page.
  9. Run the following set of commands.
    docker compose exec web ./manage.py markdown_cleanup link_to_external_resource --skip-sync --commit --filter your-course-id
  10. Open Django admin.
  11. Expect to see new content created for the markdown link.
  12. Open that new content object.
  13. Observe the metadata field.
  14. Expect to NOT find any title field.
  15. Expect to find a has_external_license_warning field with these exact spellings.