Skip to content

Comments

Fix supernav update on save#2941

Merged
JacobCoffee merged 3 commits intomainfrom
fix/supernav-update-on-releasefile-save
Feb 23, 2026
Merged

Fix supernav update on save#2941
JacobCoffee merged 3 commits intomainfrom
fix/supernav-update-on-releasefile-save

Conversation

@JacobCoffee
Copy link
Member

Description

  • add postfave handler to that dont need to double save
  • purge after release

Copilot AI review requested due to automatic review settings February 23, 2026 22:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR ensures the Downloads “supernav” and related download boxes refresh immediately when a ReleaseFile is added/changed/deleted, avoiding the need to “double save” a Release to see updates.

Changes:

  • Add post_save and post_delete signal handlers for ReleaseFile to trigger supernav + box regeneration.
  • Purge the Fastly /box/* endpoints when ReleaseFile changes on a published Release.
  • Add model tests asserting box update functions are (or aren’t) triggered based on Release publish status.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
apps/downloads/models.py Adds ReleaseFile save/delete signal handlers to refresh boxes and purge cached box URLs.
apps/downloads/tests/test_models.py Adds tests verifying the new signal-driven updates run only for published releases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +341 to +343
purge_url("/box/supernav-python-downloads/")
purge_url("/box/homepage-downloads/")
purge_url("/box/download-sources/")
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of box purge URLs is duplicated here and in purge_fastly_download_pages() above. To avoid future drift (e.g., adding/removing a box in one place but not the other), consider centralizing these paths in a shared constant or a small helper used by both code paths.

Copilot uses AI. Check for mistakes.

def _update_boxes_for_release_file(instance):
"""Update supernav and download boxes if the file's release is published."""
if instance.release_id and instance.release.is_published:
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_update_boxes_for_release_file() dereferences instance.release to check is_published, which can introduce an extra DB query on each ReleaseFile save/delete when the Release isn’t already cached. If this handler ends up being called frequently, consider checking publication status via a lightweight query (e.g., Release.objects.filter(pk=instance.release_id, is_published=True).exists()) to avoid loading the full Release object.

Suggested change
if instance.release_id and instance.release.is_published:
if instance.release_id and Release.objects.filter(pk=instance.release_id, is_published=True).exists():

Copilot uses AI. Check for mistakes.
@JacobCoffee JacobCoffee merged commit 500173e into main Feb 23, 2026
18 checks passed
@JacobCoffee JacobCoffee deleted the fix/supernav-update-on-releasefile-save branch February 23, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant