Use a materialized Extension.latest_version field instead of a dynamic property #152

Merged
Oleg-Komarov merged 15 commits from latest-version-field into main 2024-05-27 17:58:56 +02:00
2 changed files with 3 additions and 0 deletions
Showing only changes of commit b42350b4e9 - Show all commits

View File

@ -429,6 +429,7 @@ class Extension(CreatedModifiedMixin, RatingMixin, TrackChangesMixin, models.Mod
and self.versions.filter(file__status=File.STATUSES.APPROVED).count() > 0
)
# this method is called from post_save signal, this early return above should prevent a loop
if self.is_listed == should_be_listed:
return

View File

@ -74,6 +74,8 @@ def _update_version(
if hasattr(instance, 'version'):
extension = instance.version.extension
with transaction.atomic():
# it's important to update is_listed before computing latest_version
# because latest_version for listed and unlisted extensions are defined differently
extension.update_is_listed()
extension.update_latest_version()