Make it possible to fully delete unlisted/unrated extensions #81
@ -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 []
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user