-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(history): use django-tables2 for history table
The table contains a custom `fields_changed` column, which uses new `get_diff_old` and `get_diff_new` templatetags for displaying the change between two values.
- Loading branch information
Showing
6 changed files
with
94 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.diff-remove { | ||
background: #ffebe9; | ||
} | ||
.diff-insert { | ||
background: #dafbe1; | ||
} | ||
.difftable td { | ||
width: 40%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
apis_core/history/templates/history/columns/fields_changed.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{% load apis_history_templatetags %} | ||
<details> | ||
<summary> | ||
{% for change in record.get_diff %} | ||
{{ change.field }} | ||
|
||
{% if not forloop.last %},{% endif %} | ||
|
||
{% endfor %} | ||
</summary> | ||
<table class="table table-sm table-hover table-bordered difftable"> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
<th>Old value</th> | ||
<th>New value</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for change in record.get_diff %} | ||
<tr> | ||
<th>{{ change.field }}</th> | ||
<td>{{ change|get_diff_old }}</td> | ||
<td>{{ change|get_diff_new }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters