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

backoffice/schedules: change table ordering

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