Use a materialized Extension.latest_version field instead of a dynamic property #152
@ -429,6 +429,7 @@ class Extension(CreatedModifiedMixin, RatingMixin, TrackChangesMixin, models.Mod
|
|||||||
and self.versions.filter(file__status=File.STATUSES.APPROVED).count() > 0
|
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:
|
if self.is_listed == should_be_listed:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -74,6 +74,8 @@ def _update_version(
|
|||||||
if hasattr(instance, 'version'):
|
if hasattr(instance, 'version'):
|
||||||
extension = instance.version.extension
|
extension = instance.version.extension
|
||||||
with transaction.atomic():
|
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_is_listed()
|
||||||
extension.update_latest_version()
|
extension.update_latest_version()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user