mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-12-23 07:52:23 +00:00
clean code
This commit is contained in:
parent
41568916b8
commit
9f53bda1cd
@ -56,7 +56,11 @@ class HistoryTable(tables.Table):
|
||||
def render_valid(self, value):
|
||||
return "✔" if value else "✖"
|
||||
|
||||
|
||||
# function delete_button(id) provided in template file
|
||||
delete_template = """
|
||||
<button id="{{ record.pk }}" class="btn btn-danger" onclick="delete_button(this.id)"> {{ delete_trans }}</a>
|
||||
"""
|
||||
|
||||
class AliasTable(tables.Table):
|
||||
class Meta:
|
||||
attrs = {
|
||||
@ -69,13 +73,9 @@ class AliasTable(tables.Table):
|
||||
|
||||
show_header = False
|
||||
name = tables.Column(attrs={'td': {'class': 'text-center'}})
|
||||
delete = tables.LinkColumn('member:user_alias_delete',
|
||||
args=[A('pk')],
|
||||
attrs={
|
||||
'td': {'class': 'col-sm-2'},
|
||||
'a': {'class': 'btn btn-danger'}},
|
||||
text='delete', accessor='pk')
|
||||
|
||||
delete = tables.TemplateColumn(template_code=delete_template,
|
||||
extra_context={"delete_trans":_('delete')},
|
||||
attrs={'td':{'class': 'col-sm-1'}})
|
||||
class ButtonTable(tables.Table):
|
||||
class Meta:
|
||||
attrs = {
|
||||
@ -90,10 +90,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="""
|
||||
<button id="{{ record.pk }}" class="btn btn-danger" onclick="delete_button(this.id)"> delete </a>
|
||||
""")
|
||||
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)
|
||||
|
@ -63,15 +63,13 @@ function search_field_moved(secondfield) {
|
||||
$.ajax({
|
||||
url:"/api/note/transaction/template/"+button_id,
|
||||
method:"DELETE",
|
||||
headers: {
|
||||
"X-CSRFTOKEN": CSRF_TOKEN
|
||||
},
|
||||
success: function(){
|
||||
addMsg('{% trans "button successfully deleted "%}','success');
|
||||
$("#buttons_table").load('{% url "note:template_list" %} #buttons_tables');
|
||||
},
|
||||
error: addMsg(' {% trans "Unable to delete button "%} #' + button_id,'danger' )
|
||||
});
|
||||
}
|
||||
headers: {"X-CSRFTOKEN": CSRF_TOKEN}
|
||||
})
|
||||
.done(function(){
|
||||
addMsg('{% trans "button successfully deleted "%}','success');
|
||||
$("#buttons_table").load("{% url 'note:template_list' %} #buttons_table");
|
||||
})
|
||||
.fail(addMsg(' {% trans "Unable to delete button "%} #' + button_id,'danger' ));
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user