Merge pull request #362 from eReuse/feature/3790-snapshot-columns

add new columns to list of snapshots
This commit is contained in:
cayop 2022-09-23 11:04:07 +02:00 committed by GitHub
commit 83b790c97f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 1 deletions

View File

@ -1137,6 +1137,9 @@ class SnapshotListView(GenericMixin):
'status': snap.get_status(), 'status': snap.get_status(),
'severity': snap.severity, 'severity': snap.severity,
'created': snap.created, 'created': snap.created,
'type_device': snap.get_type_device(),
'original_dhid': snap.get_original_dhid(),
'new_device': snap.get_new_device(),
} }
continue continue

View File

@ -48,6 +48,36 @@ class SnapshotsLog(Thing):
return '' return ''
def get_original_dhid(self):
if self.snapshot:
dev = self.snapshot.device
if dev.dhid_bk:
return dev.dhid_bk
return self.get_device()
def get_type_device(self):
if self.snapshot:
if self.snapshot.device.binding:
return self.snapshot.device.binding.status
return ''
def get_new_device(self):
if not self.snapshot:
return ''
if not self.snapshot.device:
return ''
snapshots = []
for s in self.snapshot.device.actions:
if s == self.snapshot:
continue
if s.type == self.snapshot.type:
snapshots.append(s)
return snapshots and 'Update' or 'New Device'
class PlaceholdersLog(Thing): class PlaceholdersLog(Thing):
"""A Placeholder log.""" """A Placeholder log."""

View File

@ -31,6 +31,9 @@
<th scope="col">DHID</th> <th scope="col">DHID</th>
<th scope="col">System UUID</th> <th scope="col">System UUID</th>
<th scope="col">Status</th> <th scope="col">Status</th>
<th scope="col">Type Upload</th>
<th scope="col">Type Device</th>
<th scope="col">Original DHID</th>
<th scope="col" data-type="date" data-format="DD-MM-YYYY">Time</th> <th scope="col" data-type="date" data-format="DD-MM-YYYY">Time</th>
<th scope="col"></th> <th scope="col"></th>
</tr> </tr>
@ -68,6 +71,15 @@
<td> <td>
{{ snap.status }} {{ snap.status }}
</td> </td>
<td>
{{ snap.new_device }}
</td>
<td>
{{ snap.type_device }}
</td>
<td>
{{ snap.original_dhid }}
</td>
<td>{{ snap.created.strftime('%H:%M %d-%m-%Y') }}</td> <td>{{ snap.created.strftime('%H:%M %d-%m-%Y') }}</td>
<td> <td>
{% if snap.snapshot_uuid %} {% if snap.snapshot_uuid %}

View File

@ -1699,7 +1699,6 @@ def test_export_lots(user3: UserClientFlask):
@pytest.mark.mvp @pytest.mark.mvp
@pytest.mark.usefixtures(conftest.app_context.__name__) @pytest.mark.usefixtures(conftest.app_context.__name__)
def test_export_snapshot_json(user3: UserClientFlask): def test_export_snapshot_json(user3: UserClientFlask):
file_name = 'real-eee-1001pxd.snapshot.13.json' file_name = 'real-eee-1001pxd.snapshot.13.json'
snap = create_device(user3, file_name) snap = create_device(user3, file_name)