From 0411646ae69f8e0011e51baf954bfaebf25ac352 Mon Sep 17 00:00:00 2001
From: Pierre-antoine Comby <comby@crans.org>
Date: Wed, 25 Mar 2020 00:03:48 +0100
Subject: [PATCH] make the CI pass and nicer front

---
 apps/note/tables.py                          | 29 ++++++++++----------
 apps/note/views.py                           | 10 ++-----
 templates/note/transactiontemplate_list.html | 14 ++++++----
 3 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/apps/note/tables.py b/apps/note/tables.py
index b2326fe3..6e662107 100644
--- a/apps/note/tables.py
+++ b/apps/note/tables.py
@@ -56,11 +56,12 @@ class HistoryTable(tables.Table):
     def render_valid(self, value):
         return "✔" if value else "✖"
 
+
 # function delete_button(id) provided in template file
-delete_template = """ 
+DELETE_TEMPLATE = """
     <button id="{{ record.pk }}" class="btn btn-danger" onclick="delete_button(this.id)"> {{ delete_trans }}</button>
 """
-    
+
 class AliasTable(tables.Table):
     class Meta:
         attrs = {
@@ -75,7 +76,7 @@ class AliasTable(tables.Table):
     name = tables.Column(attrs={'td': {'class': 'text-center'}})
     # delete = tables.TemplateColumn(template_code=delete_template,
     #                                attrs={'td':{'class': 'col-sm-1'}})
-    
+
     delete = tables.LinkColumn('member:user_alias_delete',
                                args=[A('pk')],
                                attrs={
@@ -97,16 +98,16 @@ class ButtonTable(tables.Table):
 
         model = TransactionTemplate
 
-    edit  = tables.LinkColumn('note:template_update',
-                               args=[A('pk')],
-                               attrs={
-                                   'td': {'class': 'col-sm-1'},
-                                   'a': {'class': 'btn btn-primary'}},
-                               text=_('edit'), accessor='pk')
-    
-    delete = tables.TemplateColumn(template_code=delete_template,
-                                   extra_context={"delete_trans":_('delete')},
-                                   attrs={'td':{'class':'col-sm-1'}})
-    
+    edit = tables.LinkColumn('note:template_update',
+                             args=[A('pk')],
+                             attrs={'td': {'class': 'col-sm-1'},
+                                    'a': {'class': 'btn btn-primary'}},
+                             text=_('edit'),
+                             accessor='pk')
+
+    delete = tables.TemplateColumn(template_code=DELETE_TEMPLATE,
+                                   extra_context={"delete_trans": _('delete')},
+                                   attrs={'td': {'class': 'col-sm-1'}})
+
     def render_amount(self, value):
         return pretty_money(value)
diff --git a/apps/note/views.py b/apps/note/views.py
index 6ddc8975..7d8d80aa 100644
--- a/apps/note/views.py
+++ b/apps/note/views.py
@@ -111,6 +111,7 @@ class TransactionTemplateCreateView(LoginRequiredMixin, CreateView):
     form_class = TransactionTemplateForm
     success_url = reverse_lazy('note:template_list')
 
+
 class TransactionTemplateListView(LoginRequiredMixin, SingleTableView):
     """
     List TransactionsTemplates
@@ -118,14 +119,6 @@ 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):
     """
@@ -134,6 +127,7 @@ class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView):
     form_class = TransactionTemplateForm
     success_url = reverse_lazy('note:template_list')
 
+
 class ConsoView(LoginRequiredMixin, SingleTableView):
     """
     The Magic View that make people pay their beer and burgers.
diff --git a/templates/note/transactiontemplate_list.html b/templates/note/transactiontemplate_list.html
index ba0254bc..043a06e9 100644
--- a/templates/note/transactiontemplate_list.html
+++ b/templates/note/transactiontemplate_list.html
@@ -14,12 +14,14 @@
     </div>
 </div>
 <div class="row justify-content-center">   
-    <div class="col-md-10 card shadow">
-        <div class="card-header text-center">
-            <h5> {% trans "buttons listing "%}</h5>
-        </div>
-        <div class="card" id="buttons_table">
-            {% render_table table %}
+    <div class="col-md-10">
+        <div class="card card-border shadow">
+            <div class="card-header text-center">
+                <h5> {% trans "buttons listing "%}</h5>
+            </div>
+            <div class="card-body px-0 py-0" id="buttons_table">
+                {% render_table table %}
+            </div>
         </div>
     </div>
 </div>
-- 
GitLab