Make it possible to fully delete unlisted/unrated extensions #81

Merged
Anna Sirota merged 24 commits from fully-delete-extension into main 2024-04-19 11:00:19 +02:00
Showing only changes of commit b375f9d865 - Show all commits

View File

@ -228,12 +228,12 @@ class Extension(CreatedModifiedMixin, RatingMixin, TrackChangesMixin, models.Mod
def cannot_be_deleted_reasons(self) -> List[str]:
"""Return a list of reasons why this extension cannot be deleted."""
reasons = []
if self.abusereport_set.count() > 0:
reasons.append('has_abuse_reports')
if self.ratings.count() > 0:
reasons.append('has_ratings')
if self.is_listed:
reasons.append('is_listed')
if self.ratings.count() > 0:
reasons.append('has_ratings')
if self.abusereport_set.count() > 0:
reasons.append('has_abuse_reports')
for v in self.versions.all():
reasons.extend(v.cannot_be_deleted_reasons)
return reasons
@ -575,10 +575,10 @@ class Version(CreatedModifiedMixin, RatingMixin, TrackChangesMixin, models.Model
def cannot_be_deleted_reasons(self) -> List[str]:
"""Return a list of reasons why this version cannot be deleted."""
reasons = []
if self.ratings.count() > 0:
reasons.append('version_has_ratings')
if self.is_listed:
reasons.append('version_is_listed')
if self.ratings.count() > 0:
reasons.append('version_has_ratings')
return reasons
@property
@ -665,6 +665,7 @@ class Preview(CreatedModifiedMixin, models.Model):
@property
def cannot_be_deleted_reasons(self) -> List[str]:
"""Return a list of reasons why this preview cannot be deleted."""
return []