make the CI pass and nicer front

This commit is contained in:
Pierre-antoine Comby 2020-03-25 00:03:48 +01:00
parent 20ea017e96
commit 0411646ae6
3 changed files with 25 additions and 28 deletions

View File

@ -56,8 +56,9 @@ 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>
"""
@ -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')
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'}})
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)

View File

@ -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.

View File

@ -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>