This commit is contained in:
Cayo Puigdefabregas 2024-02-29 13:00:59 +01:00
parent da6ae895a3
commit 61e2dc0d9c
3 changed files with 13 additions and 1 deletions

View File

@ -870,7 +870,12 @@ class SchemasDeleteView(SchemasMix):
def get(self, request, *args, **kwargs):
self.check_valid_user()
self.pk = kwargs['pk']
self.object = get_object_or_404(Schemas, pk=self.pk)
schema.vcredentials.filter(status=VerificableCredential.Status.ISSUED).count()
self.object = get_object_or_404(
Schemas,
pk=self.pk,
vcredentials__status=VerificableCredential.Status.ISSUED
)
self.object.delete()
return redirect('idhub:admin_schemas')

View File

@ -527,6 +527,11 @@ class Schemas(models.Model):
return name
@property
def has_credentials(self, request=None):
return self.vcredentials.filter(
status=VerificableCredential.Status.ISSUED).exists()
def _get_language_code(self, request=None):
language_code = settings.LANGUAGE_CODE
if request:

View File

@ -13,6 +13,7 @@
</div>
<!-- Modal -->
{% for schema in object_list %}
{% if not schema.has_credentials %}
<div class="modal" id="confirm-delete-{{ schema.id }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
@ -30,5 +31,6 @@
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% endblock %}