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"> <a href="{{ version.update_url }}" class="btn">
<i class="i-edit"></i><span>Edit</span> <i class="i-edit"></i><span>Edit</span>
</a> </a>
<a href="{{ version.get_delete_url }}" class="btn btn-danger"> {% with cannot_be_deleted_reasons=version.cannot_be_deleted_reasons %}
<i class="i-trash"></i> {% if not cannot_be_deleted_reasons %}
<span>{% trans "Delete Version" %}</span> <a href="{{ version.get_delete_url }}" class="btn btn-danger">
</a> <i class="i-trash"></i>
<span>{% trans "Delete Version" %}</span>
</a>
{% endif %}
{% endwith %}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@ -193,6 +193,7 @@ class DeleteExtensionView(
class VersionDeleteView( class VersionDeleteView(
LoginRequiredMixin, LoginRequiredMixin,
MaintainedExtensionMixin, MaintainedExtensionMixin,
UserPassesTestMixin,
DeleteView, DeleteView,
): ):
model = Version model = Version
@ -232,6 +233,14 @@ class VersionDeleteView(
context['confirm_url'] = version.get_delete_url() context['confirm_url'] = version.get_delete_url()
return context 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( class ManageVersionsView(
LoginRequiredMixin, LoginRequiredMixin,