Fixed templates and data admin tables
This commit is contained in:
parent
dd89997941
commit
c55db24954
|
@ -7,7 +7,8 @@ from idhub.models import (
|
||||||
Service,
|
Service,
|
||||||
VerificableCredential,
|
VerificableCredential,
|
||||||
DID,
|
DID,
|
||||||
File_datas
|
File_datas,
|
||||||
|
Schemas
|
||||||
)
|
)
|
||||||
from idhub_auth.models import User
|
from idhub_auth.models import User
|
||||||
|
|
||||||
|
@ -216,3 +217,28 @@ class DataTable(tables.Table):
|
||||||
model = File_datas
|
model = File_datas
|
||||||
template_name = "idhub/custom_table.html"
|
template_name = "idhub/custom_table.html"
|
||||||
fields = ("created_at", "file_name", "success")
|
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,
|
ServicesTable,
|
||||||
CredentialTable,
|
CredentialTable,
|
||||||
DIDTable,
|
DIDTable,
|
||||||
DataTable
|
DataTable,
|
||||||
|
TemplateTable
|
||||||
)
|
)
|
||||||
from idhub.models import (
|
from idhub.models import (
|
||||||
DID,
|
DID,
|
||||||
|
@ -730,19 +731,21 @@ class WalletConfigIssuesView(Credentials):
|
||||||
wallet = True
|
wallet = True
|
||||||
|
|
||||||
|
|
||||||
class SchemasView(SchemasMix):
|
class SchemasView(SchemasMix, SingleTableView):
|
||||||
template_name = "idhub/admin/schemas.html"
|
template_name = "idhub/admin/schemas.html"
|
||||||
|
table_class = TemplateTable
|
||||||
subtitle = _('View credential templates')
|
subtitle = _('View credential templates')
|
||||||
icon = ''
|
icon = ''
|
||||||
|
model = Schemas
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
queryset = kwargs.pop('object_list', None)
|
||||||
context.update({
|
if queryset is None:
|
||||||
'schemas': Schemas.objects,
|
self.object_list = self.model.objects.all()
|
||||||
})
|
|
||||||
return context
|
return super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SchemasDeleteView(SchemasMix):
|
class SchemasDeleteView(SchemasMix):
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
|
|
@ -7,32 +7,8 @@
|
||||||
<i class="{{ icon }}"></i>
|
<i class="{{ icon }}"></i>
|
||||||
{{ subtitle }}
|
{{ subtitle }}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="row mt-5">
|
{% render_table table %}
|
||||||
<div class="col">
|
<div class="form-actions-no-box">
|
||||||
{% render_table table %}
|
<a class="btn btn-green-admin" href="{% url 'idhub:admin_import_add' %}">{% translate "Import data" %} <i class="bi bi-plus"></i></a>
|
||||||
<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>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,47 +1,19 @@
|
||||||
{% extends "idhub/base_admin.html" %}
|
{% extends "idhub/base_admin.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>
|
<h3>
|
||||||
<i class="{{ icon }}"></i>
|
<i class="{{ icon }}"></i>
|
||||||
{{ subtitle }}
|
{{ subtitle }}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="row mt-5">
|
{% render_table table %}
|
||||||
<div class="col">
|
<div class="form-actions-no-box">
|
||||||
<div class="table-responsive">
|
<a class="btn btn-green-admin" href="{% url 'idhub:admin_schemas_import' %}">{% translate "Add template" %} <i class="bi bi-plus"></i></a>
|
||||||
<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>
|
|
||||||
<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>
|
</div>
|
||||||
<!-- Modal -->
|
<!-- 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" id="confirm-delete-{{ schema.id }}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
|
Loading…
Reference in New Issue