Skip to content
Snippets Groups Projects
Commit 2920d250 authored by HeJ's avatar HeJ
Browse files

backoffice/schedules: change table ordering

parent b13bd90e
Branches
No related tags found
No related merge requests found
......@@ -26,13 +26,19 @@
</div>
<table class="card-body table table-sm table-hover">
<thead>
<tr><th>Type</th><th>Action</th><th>Source ID</th><th>Local ID</th><th>Message</th></tr>
<tr>
<th>Type</th>
<th>Action</th>
<th>Source ID</th>
<th>Local ID</th>
<th>Message</th>
</tr>
</thead>
<tbody>
{% for error in object.errors %}
<tr>
<td>{{ error.type|default:"???" }}</td>
<td>{{ error.action|default:"???" }}</td>
<td>{{ error.type|default:"???" }}</td>
<td>{{ error.source_id|default:"-/-" }}</td>
<td>{{ error.local_id|default:"-/-" }}</td>
<td>{{ error.message }}</td>
......@@ -48,22 +54,29 @@
<div class="card-header text-bg-primary">
Activity
</div>
<table class="card-body table table-sm table-hover">
<div class="card-body">
<table class="table table-sm table-hover">
<thead>
<tr><th>Type</th><th>Action</th><th>Source ID</th><th>Local ID</th></tr>
<tr>
<th>Type</th>
<th>Action</th>
<th>Source ID</th>
<th>Local ID</th>
</tr>
</thead>
<tbody>
{% for item in activity %}
<tr{% if item.action != "seen" %} class="fw-bold"{% endif %}>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% endif %}">{{ item.type|default:"???" }}</td>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% endif %}">{{ item.action|default:"???" }}</td>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% endif %}">{{ item.source_id|default:"-/-" }}</td>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% endif %}">{{ item.local_id|default:"-/-" }}</td>
<tr>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% elif item.action == "missing" or item.action == "removed" %}text-warning{% elif item.action == "added" %}text-success{% endif %}">{{ item.action|default:"???" }}</td>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% elif item.action == "missing" or item.action == "removed" %}text-warning{% elif item.action == "added" %}text-success{% endif %}">{{ item.type|default:"???" }}</td>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% elif item.action == "missing" or item.action == "removed" %}text-warning{% elif item.action == "added" %}text-success{% endif %}">{{ item.source_id|default:"-/-" }}</td>
<td class="{% if item.action == "seen" %}text-muted{% elif item.action == "error" %}text-danger{% elif item.action == "missing" or item.action == "removed" %}text-warning{% elif item.action == "added" %}text-success{% endif %}">{{ item.local_id|default:"-/-" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
{% if object.data %}
......
......@@ -122,13 +122,13 @@ class ScheduleSourceImportDetailView(ScheduleAdminMixin, DetailView):
model = ScheduleSourceImport
def get_context_data(self, *args, **kwargs):
action2sort = {'error': '01', 'removed': '02', 'added': '03', 'seen': '08'}
type2sort = {'room': '10', 'event': '20', 'speaker': '50'}
action2sort = {'error': 10, 'removed': 20, 'missing': 25, 'added': 30, 'seen': 80}
type2sort = {'room': 10, 'event': 20, 'speaker': 50}
ctx = super().get_context_data(*args, **kwargs)
if data := ctx['object'].data:
ctx['activity'] = sorted(
data.get('_activity', []),
key=lambda item: f'{action2sort.get(item["action"], "99")}__{type2sort.get(item["type"], "99")}__{item["source_id"]:>10}',
key=lambda item: (action2sort.get(item["action"], 99), type2sort.get(item["type"], 99), item["source_id"]),
)
else:
ctx['activity'] = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment