def get(self, request, report_id): assert report_id report = self.get_object() if not report.log: raise BridgeException(_("The component doesn't have log")) content = ArchiveFileContent(report, 'log', LOG_FILE).content if len(content) > 10**5: content = str( _('The component log is huge and can not be shown but you can download it' )) else: content = content.decode('utf8') return HttpResponse(content)
def get_context_data(self, **kwargs): if not JobAccess(self.request.user, self.object.root.job).can_view(): raise BridgeException(code=400) if not self.object.log: raise BridgeException(_("The component doesn't have log")) content = ArchiveFileContent(self.object, 'log', LOG_FILE).content if len(content) > 10**5: content = str( _('The component log is huge and can not be shown but you can download it' )) else: content = content.decode('utf8') return {'content': content}