1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2024-11-26 18:37:12 +00:00

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): def render_valid(self, value):
return "" if value else "" return "" if value else ""
# function delete_button(id) provided in template file # 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> <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 model = TransactionTemplate
edit = tables.LinkColumn('note:template_update', edit = tables.LinkColumn('note:template_update',
args=[A('pk')], args=[A('pk')],
attrs={ attrs={'td': {'class': 'col-sm-1'},
'td': {'class': 'col-sm-1'}, 'a': {'class': 'btn btn-primary'}},
'a': {'class': 'btn btn-primary'}}, text=_('edit'),
text=_('edit'), accessor='pk') accessor='pk')
delete = tables.TemplateColumn(template_code=delete_template, delete = tables.TemplateColumn(template_code=DELETE_TEMPLATE,
extra_context={"delete_trans":_('delete')}, extra_context={"delete_trans": _('delete')},
attrs={'td':{'class':'col-sm-1'}}) attrs={'td': {'class': 'col-sm-1'}})
def render_amount(self, value): def render_amount(self, value):
return pretty_money(value) return pretty_money(value)

View File

@ -111,6 +111,7 @@ class TransactionTemplateCreateView(LoginRequiredMixin, CreateView):
form_class = TransactionTemplateForm form_class = TransactionTemplateForm
success_url = reverse_lazy('note:template_list') success_url = reverse_lazy('note:template_list')
class TransactionTemplateListView(LoginRequiredMixin, SingleTableView): class TransactionTemplateListView(LoginRequiredMixin, SingleTableView):
""" """
List TransactionsTemplates List TransactionsTemplates
@ -118,14 +119,6 @@ class TransactionTemplateListView(LoginRequiredMixin, SingleTableView):
model = TransactionTemplate model = TransactionTemplate
table_class = ButtonTable 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): class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView):
""" """
@ -134,6 +127,7 @@ class TransactionTemplateUpdateView(LoginRequiredMixin, UpdateView):
form_class = TransactionTemplateForm form_class = TransactionTemplateForm
success_url = reverse_lazy('note:template_list') success_url = reverse_lazy('note:template_list')
class ConsoView(LoginRequiredMixin, SingleTableView): class ConsoView(LoginRequiredMixin, SingleTableView):
""" """
The Magic View that make people pay their beer and burgers. The Magic View that make people pay their beer and burgers.

View File

@ -14,12 +14,14 @@
</div> </div>
</div> </div>
<div class="row justify-content-center"> <div class="row justify-content-center">
<div class="col-md-10 card shadow"> <div class="col-md-10">
<div class="card-header text-center"> <div class="card card-border shadow">
<h5> {% trans "buttons listing "%}</h5> <div class="card-header text-center">
</div> <h5> {% trans "buttons listing "%}</h5>
<div class="card" id="buttons_table"> </div>
{% render_table table %} <div class="card-body px-0 py-0" id="buttons_table">
{% render_table table %}
</div>
</div> </div>
</div> </div>
</div> </div>