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