Make class view more descriptive

This commit is contained in:
sergio_gimenez 2024-10-22 09:18:59 +02:00
parent 1ec7a69c06
commit d49cc44b4c
1 changed files with 4 additions and 2 deletions

View File

@ -110,7 +110,7 @@ class DetailsView(DashboardView, TemplateView):
return context
class DeviceWebView(TemplateView):
class PublicDeviceWebView(TemplateView):
template_name = "device_web.html"
def get(self, request, *args, **kwargs):
@ -132,17 +132,19 @@ class DeviceWebView(TemplateView):
def get_json_response(self):
data = {
'object': self.get_object_data(),
# TODO i) agree on what fields to return. ii) implement get_components_data for new and old snapshot
# 'components': self.get_components_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': object.last_evidence.doc.device.serialNumber,
'serial_number': serial_number,
}
return object_data