From ba04a6555f429a307f6c908e4a641416110f344b Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Tue, 24 Mar 2020 22:12:44 +0100 Subject: [PATCH] dynamically delete buttons --- apps/note/api/views.py | 3 ++- apps/note/tables.py | 5 ++++ templates/note/transactiontemplate_list.html | 28 +++++++++++++++++--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/apps/note/api/views.py b/apps/note/api/views.py index 977441f7..d35c3797 100644 --- a/apps/note/api/views.py +++ b/apps/note/api/views.py @@ -5,6 +5,7 @@ from django.db.models import Q from django_filters.rest_framework import DjangoFilterBackend from rest_framework.filters import OrderingFilter, SearchFilter from api.viewsets import ReadProtectedModelViewSet, ReadOnlyProtectedModelViewSet +from rest_framework import viewsets from .serializers import NotePolymorphicSerializer, AliasSerializer, TemplateCategorySerializer, \ TransactionTemplateSerializer, TransactionPolymorphicSerializer @@ -81,7 +82,7 @@ class TemplateCategoryViewSet(ReadProtectedModelViewSet): search_fields = ['$name', ] -class TransactionTemplateViewSet(ReadProtectedModelViewSet): +class TransactionTemplateViewSet(viewsets.ModelViewSet): """ REST API View set. The djangorestframework plugin will get all `TransactionTemplate` objects, serialize it to JSON with the given serializer, diff --git a/apps/note/tables.py b/apps/note/tables.py index 2986c748..ad57c265 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -90,5 +90,10 @@ class ButtonTable(tables.Table): model = TransactionTemplate + + delete = tables.TemplateColumn(template_code=""" +