diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 59e66e07..69387ab8 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -1210,9 +1210,18 @@ class SnapshotListView(GenericMixin): return flask.render_template(self.template_name, **self.context) def get_snapshots_log(self): + page = int(request.args.get('page', 1)) + per_page = int(request.args.get('per_page', PER_PAGE)) + snapshots_log = SnapshotsLog.query.filter( SnapshotsLog.owner == g.user ).order_by(SnapshotsLog.created.desc()) + + snapshots_log = snapshots_log.paginate(page=page, per_page=per_page) + snapshots_log.first = per_page * snapshots_log.page - per_page + 1 + snapshots_log.last = len(snapshots_log.items) + snapshots_log.first - 1 + return snapshots_log + logs = {} for snap in snapshots_log: try: diff --git a/ereuse_devicehub/parser/models.py b/ereuse_devicehub/parser/models.py index 4d298af0..bdd13f73 100644 --- a/ereuse_devicehub/parser/models.py +++ b/ereuse_devicehub/parser/models.py @@ -78,6 +78,12 @@ class SnapshotsLog(Thing): snapshots.append(s) return snapshots and 'Update' or 'New Device' + def get_system_uuid(self): + try: + return self.snapshot.device.system_uuid or '' + except AttributeError: + return '' + class PlaceholdersLog(Thing): """A Placeholder log.""" diff --git a/ereuse_devicehub/templates/inventory/snapshots_list.html b/ereuse_devicehub/templates/inventory/snapshots_list.html index 4c35f44e..1804f364 100644 --- a/ereuse_devicehub/templates/inventory/snapshots_list.html +++ b/ereuse_devicehub/templates/inventory/snapshots_list.html @@ -22,6 +22,38 @@
{% if snap.sid and snap.snapshot_uuid %} @@ -59,26 +91,26 @@ {{ snap.version }} | - {% if snap.device %} + {% if snap.get_device() %} - {{ snap.device }} + {{ snap.get_device() }} {% endif %} | - {{ snap.system_uuid }} + {{ snap.get_system_uuid() }} | - {{ snap.status }} + {{ snap.get_status() }} | - {{ snap.new_device }} + {{ snap.get_new_device() }} | - {{ snap.type_device }} + {{ snap.get_type_device() }} | - {{ snap.original_dhid }} + {{ snap.get_original_dhid() }} | {{ snap.created.strftime('%Y-%m-%d %H:%M') }} | @@ -93,6 +125,38 @@ |