Add public data

This commit is contained in:
sergio_gimenez 2024-10-23 08:47:40 +02:00
parent fd2adfa3a5
commit 42cf720613
1 changed files with 6 additions and 16 deletions

View File

@ -124,30 +124,20 @@ class PublicDeviceWebView(TemplateView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
self.object.initial() self.object.initial()
context.update({ context.update({
'object': self.object, 'object': self.object
'snapshot': self.object.get_last_evidence(),
}) })
return context return context
def get_json_response(self): def get_json_response(self):
data = { data = {
'object': self.get_object_data(), 'id': self.object.id,
# TODO i) agree on what fields to return. ii) implement get_components_data for new and old snapshot 'shortid': self.object.shortid,
# 'components': self.get_components_data(), 'uuids': self.object.uuids,
'hids': self.object.hids,
'components': self.object.components
} }
return JsonResponse(data) return JsonResponse(data)
def get_object_data(self):
serial_number = self.object.last_evidence.doc.device.serialNumber if self.object.last_evidence else "None"
object_data = {
'phid': self.object.id,
'type': self.object.type,
'manufacturer': self.object.manufacturer,
'model': self.object.model,
'serial_number': serial_number,
}
return object_data
class AddAnnotationView(DashboardView, CreateView): class AddAnnotationView(DashboardView, CreateView):
template_name = "new_annotation.html" template_name = "new_annotation.html"