diff --git a/idhub/admin/tables.py b/idhub/admin/tables.py index ce19c48..a95ad63 100644 --- a/idhub/admin/tables.py +++ b/idhub/admin/tables.py @@ -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 = """""" + 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") diff --git a/idhub/admin/views.py b/idhub/admin/views.py index cd82a3a..255f5ab 100644 --- a/idhub/admin/views.py +++ b/idhub/admin/views.py @@ -38,7 +38,8 @@ from idhub.admin.tables import ( ServicesTable, CredentialTable, DIDTable, - DataTable + DataTable, + TemplateTable ) from idhub.models import ( DID, @@ -730,19 +731,21 @@ 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): def get(self, request, *args, **kwargs): diff --git a/idhub/templates/idhub/admin/import.html b/idhub/templates/idhub/admin/import.html index 6c280e4..87c0cc3 100644 --- a/idhub/templates/idhub/admin/import.html +++ b/idhub/templates/idhub/admin/import.html @@ -7,32 +7,8 @@ {{ subtitle }} -
- | - | - |
---|---|---|
{{ f.created_at }} | -{{ f.file_name }} | -{% if f.success %}{% else %}{% endif %} | -