mirror of https://gitlab.crans.org/bde/nk20
non dynamic search for button
This commit is contained in:
parent
1ce7dc0118
commit
7cd8a37aec
|
@ -89,9 +89,9 @@ class TransactionTemplateViewSet(ReadProtectedModelViewSet):
|
|||
"""
|
||||
queryset = TransactionTemplate.objects.all()
|
||||
serializer_class = TransactionTemplateSerializer
|
||||
filter_backends = [DjangoFilterBackend]
|
||||
filter_backends = [SearchFilter, DjangoFilterBackend]
|
||||
filterset_fields = ['name', 'amount', 'display', 'category', ]
|
||||
|
||||
search_fields = ['$name', ]
|
||||
|
||||
class TransactionViewSet(ReadProtectedModelViewSet):
|
||||
"""
|
||||
|
|
|
@ -82,6 +82,11 @@ class ButtonTable(tables.Table):
|
|||
'class':
|
||||
'table table condensed table-striped table-hover'
|
||||
}
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
'data-href': lambda record: record.pk
|
||||
}
|
||||
|
||||
model = TransactionTemplate
|
||||
|
||||
def render_amount(self, value):
|
||||
|
|
|
@ -8,6 +8,7 @@ from django.db.models import Q
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import CreateView, ListView, UpdateView
|
||||
from django_tables2 import SingleTableView
|
||||
from django.urls import reverse_lazy
|
||||
from permission.backends import PermissionBackend
|
||||
|
||||
from .forms import TransactionTemplateForm
|
||||
|
@ -108,7 +109,7 @@ class TransactionTemplateCreateView(LoginRequiredMixin, CreateView):
|
|||
"""
|
||||
model = TransactionTemplate
|
||||
form_class = TransactionTemplateForm
|
||||
|
||||
success_url = reverse_lazy('template_list')
|
||||
|
||||
class TransactionTemplateListView(LoginRequiredMixin, SingleTableView):
|
||||
"""
|
||||
|
@ -117,6 +118,14 @@ class TransactionTemplateListView(LoginRequiredMixin, SingleTableView):
|
|||
model = TransactionTemplate
|
||||
table_class = ButtonTable
|
||||
|
||||
def get_queryset(self):
|
||||
name = self.request.GET.get('name','')
|
||||
if (name != ''):
|
||||
object_list = self.model.objects.filter(name__icontains = name)
|
||||
else:
|
||||
object_list = self.model.objects.all()
|
||||
return object_list
|
||||
|
||||
|
||||
class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView):
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,26 @@
|
|||
{% extends "base.html" %}
|
||||
{% load pretty_money %}
|
||||
{% load i18n %}
|
||||
{% load render_table from django_tables2 %}
|
||||
{% block content %}
|
||||
<a class="btn btn-primary text-center" href="{% url 'note:template_create' %}">Créer un bouton</a>
|
||||
{% render_table table %}
|
||||
<div class="row justify-content-center mb-4">
|
||||
<div class="col-md-10 text-center">
|
||||
<h4>
|
||||
{% trans "search button" %}
|
||||
</h4>
|
||||
<form action="" method="GET">
|
||||
{% csrf_token %}
|
||||
<input class="form-control mx-auto w-25" type="text" id="name" name="name" value='{{ request.GET.name }}'/>
|
||||
</form>
|
||||
<ul class="list-group list-group-flush" id="alias_matched">
|
||||
</ul>
|
||||
<hr>
|
||||
<a class="btn btn-primary text-center my-4" href="{% url 'note:template_create' %}">Créer un bouton</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-10">
|
||||
{% render_table table %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue