Fixed templates and data admin tables
This commit is contained in:
parent
dd89997941
commit
c55db24954
|
@ -7,7 +7,8 @@ from idhub.models import (
|
|||
Service,
|
||||
VerificableCredential,
|
||||
DID,
|
||||
File_datas
|
||||
File_datas,
|
||||
Schemas
|
||||
)
|
||||
from idhub_auth.models import User
|
||||
|
||||
|
@ -216,3 +217,28 @@ class DataTable(tables.Table):
|
|||
model = File_datas
|
||||
template_name = "idhub/custom_table.html"
|
||||
fields = ("created_at", "file_name", "success")
|
||||
|
||||
|
||||
class TemplateTable(tables.Table):
|
||||
view_schema = ButtonColumn(
|
||||
linkify={
|
||||
"viewname": "idhub:admin_schemas_download",
|
||||
"args": [tables.A("pk")]
|
||||
},
|
||||
orderable=False
|
||||
)
|
||||
delete_template_code = """<a class="text-danger"
|
||||
href="javascript:void()"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#confirm-delete-{{ record.id }}"
|
||||
title="Remove"
|
||||
><i class="bi bi-trash"></i></a>"""
|
||||
delete_schema = tables.TemplateColumn(template_code=delete_template_code,
|
||||
orderable=False,
|
||||
verbose_name="Delete schema")
|
||||
|
||||
class Meta:
|
||||
model = Schemas
|
||||
template_name = "idhub/custom_table.html"
|
||||
fields = ("created_at", "file_schema", "name", "description",
|
||||
"view_schema", "delete_schema")
|
||||
|
|
|
@ -38,7 +38,8 @@ from idhub.admin.tables import (
|
|||
ServicesTable,
|
||||
CredentialTable,
|
||||
DIDTable,
|
||||
DataTable
|
||||
DataTable,
|
||||
TemplateTable
|
||||
)
|
||||
from idhub.models import (
|
||||
DID,
|
||||
|
@ -730,17 +731,19 @@ class WalletConfigIssuesView(Credentials):
|
|||
wallet = True
|
||||
|
||||
|
||||
class SchemasView(SchemasMix):
|
||||
class SchemasView(SchemasMix, SingleTableView):
|
||||
template_name = "idhub/admin/schemas.html"
|
||||
table_class = TemplateTable
|
||||
subtitle = _('View credential templates')
|
||||
icon = ''
|
||||
model = Schemas
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context.update({
|
||||
'schemas': Schemas.objects,
|
||||
})
|
||||
return context
|
||||
queryset = kwargs.pop('object_list', None)
|
||||
if queryset is None:
|
||||
self.object_list = self.model.objects.all()
|
||||
|
||||
return super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
class SchemasDeleteView(SchemasMix):
|
||||
|
|
|
@ -7,32 +7,8 @@
|
|||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
<div class="row mt-5">
|
||||
<div class="col">
|
||||
{% render_table table %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Created' %}</button></th>
|
||||
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'File' %}</button></th>
|
||||
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Success' %}</button></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for f in dates.all %}
|
||||
<tr style="font-size:15px;">
|
||||
<td>{{ f.created_at }}</td>
|
||||
<td>{{ f.file_name }}</td>
|
||||
<td>{% if f.success %}<i class="bi bi-check-circle text-primary"></i>{% else %}<i class="bi bi-x-circle text-danger"></i>{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-actions-no-box">
|
||||
<a class="btn btn-green-admin" href="{% url 'idhub:admin_import_add' %}">{% translate "Import data" %} <i class="bi bi-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,46 +1,18 @@
|
|||
{% extends "idhub/base_admin.html" %}
|
||||
{% load i18n %}
|
||||
{% load render_table from django_tables2 %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
<div class="row mt-5">
|
||||
<div class="col">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Created' %}</button></th>
|
||||
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Template file' %}</button></th>
|
||||
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Name' %}</button></th>
|
||||
<th scope="col"><button type="button" class="btn btn-grey border border-dark">{% trans 'Description' %}</button></th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for schema in schemas.all %}
|
||||
<tr style="font-size:15px;">
|
||||
<td>{{ schema.created_at }}</td>
|
||||
<td>{{ schema.file_schema }}</td>
|
||||
<td>{{ schema.name }}</td>
|
||||
<td>{{ schema.description }}</td>
|
||||
<td><a class="text-primary" href="{% url 'idhub:admin_schemas_download' schema.id %}" target="_blank" title="{% trans 'View' %}"><i class="bi bi-eye"></i></a></td>
|
||||
<td><a class="text-danger" href="jacascript:void()" data-bs-toggle="modal" data-bs-target="#confirm-delete-{{ schema.id }}" title="{% trans 'Remove' %}"><i class="bi bi-trash"></i></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% render_table table %}
|
||||
<div class="form-actions-no-box">
|
||||
<a class="btn btn-green-admin" href="{% url 'idhub:admin_schemas_import' %}">{% translate "Add template" %} <i class="bi bi-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
{% for schema in schemas.all %}
|
||||
{% for schema in object_list %}
|
||||
<div class="modal" id="confirm-delete-{{ schema.id }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
|
Loading…
Reference in New Issue