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
2 changed files with 17 additions and 4 deletions
Showing only changes of commit 9329c8c63d - Show all commits

View File

@ -103,10 +103,14 @@
<a href="{{ version.update_url }}" class="btn">
<i class="i-edit"></i><span>Edit</span>
</a>
<a href="{{ version.get_delete_url }}" class="btn btn-danger">
<i class="i-trash"></i>
<span>{% trans "Delete Version" %}</span>
</a>
{% with cannot_be_deleted_reasons=version.cannot_be_deleted_reasons %}
{% if not cannot_be_deleted_reasons %}
<a href="{{ version.get_delete_url }}" class="btn btn-danger">
<i class="i-trash"></i>
<span>{% trans "Delete Version" %}</span>
</a>
{% endif %}
{% endwith %}
{% endif %}
</div>
</div>

View File

@ -193,6 +193,7 @@ class DeleteExtensionView(
class VersionDeleteView(
LoginRequiredMixin,
MaintainedExtensionMixin,
UserPassesTestMixin,
DeleteView,
):
model = Version
@ -232,6 +233,14 @@ class VersionDeleteView(
context['confirm_url'] = version.get_delete_url()
return context
def test_func(self) -> bool:
obj = self.get_object()
# Unless this version cannot be deleted anymore
cannot_be_deleted_reasons = obj.cannot_be_deleted_reasons
if len(cannot_be_deleted_reasons) > 0:
return False
return True
class ManageVersionsView(
LoginRequiredMixin,