feature/90-implement-public-website-for-device #17
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue