feature/90-implement-public-website-for-device #17

Merged
cayop merged 32 commits from feature/90-implement-public-website-for-device into main 2024-10-30 15:02:18 +00:00
1 changed files with 4 additions and 2 deletions
Showing only changes of commit 2636e80ece - Show all commits

View File

@ -110,7 +110,7 @@ class DetailsView(DashboardView, TemplateView):
return context return context
class DeviceWebView(TemplateView): class PublicDeviceWebView(TemplateView):
template_name = "device_web.html" template_name = "device_web.html"
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
@ -132,17 +132,19 @@ class DeviceWebView(TemplateView):
def get_json_response(self): def get_json_response(self):
data = { data = {
'object': self.get_object_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(), # 'components': self.get_components_data(),
} }
return JsonResponse(data) return JsonResponse(data)
def get_object_data(self): def get_object_data(self):
serial_number = self.object.last_evidence.doc.device.serialNumber if self.object.last_evidence else "None"
object_data = { object_data = {
'phid': self.object.id, 'phid': self.object.id,
'type': self.object.type, 'type': self.object.type,
'manufacturer': self.object.manufacturer, 'manufacturer': self.object.manufacturer,
'model': self.object.model, 'model': self.object.model,
# 'serial_number': object.last_evidence.doc.device.serialNumber, 'serial_number': serial_number,
} }
return object_data return object_data