fix delete schemas
This commit is contained in:
parent
156b0b4586
commit
55355f9e69
|
@ -229,7 +229,7 @@ class TemplateTable(tables.Table):
|
|||
delete_template_code = """<a class="text-danger"
|
||||
href="javascript:void()"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#confirm-delete-{{ record.id }}"
|
||||
data-bs-target="#confirm-delete-{}"
|
||||
title="Remove"
|
||||
><i class="bi bi-trash"></i></a>"""
|
||||
delete_schema = tables.TemplateColumn(template_code=delete_template_code,
|
||||
|
@ -254,8 +254,9 @@ class TemplateTable(tables.Table):
|
|||
return (queryset, True)
|
||||
|
||||
def render_delete_schema(self, value, record):
|
||||
if record.has_credentials():
|
||||
return value
|
||||
if not record.has_credentials:
|
||||
tmpl = self.delete_template_code.format(record.id)
|
||||
return format_html(tmpl)
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
|
|
@ -870,10 +870,10 @@ class SchemasDeleteView(SchemasMix):
|
|||
def get(self, request, *args, **kwargs):
|
||||
self.check_valid_user()
|
||||
self.pk = kwargs['pk']
|
||||
issued = VerificableCredential.Status.ISSUED
|
||||
self.object = get_object_or_404(
|
||||
Schemas,
|
||||
Schemas.objects.exclude(vcredentials__status=issued),
|
||||
pk=self.pk,
|
||||
vcredentials__status=VerificableCredential.Status.ISSUED
|
||||
)
|
||||
self.object.delete()
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ class Schemas(models.Model):
|
|||
return name
|
||||
|
||||
@property
|
||||
def has_credentials(self, request=None):
|
||||
def has_credentials(self):
|
||||
return self.vcredentials.filter(
|
||||
status=VerificableCredential.Status.ISSUED).exists()
|
||||
|
||||
|
|
Loading…
Reference in a new issue