mirror of
https://github.com/bugsink/bugsink.git
synced 2026-02-12 16:59:12 -06:00
Save the data as proper JSON; add viewer to admin
This commit is contained in:
@@ -1,8 +1,20 @@
|
||||
from django.utils.html import escape, mark_safe
|
||||
from django.contrib import admin
|
||||
|
||||
import json
|
||||
|
||||
from .models import DecompressedEvent
|
||||
|
||||
|
||||
@admin.register(DecompressedEvent)
|
||||
class DecompressedEventAdmin(admin.ModelAdmin):
|
||||
list_display = ["timestamp", "project"]
|
||||
exclude = ["data"]
|
||||
|
||||
readonly_fields = [
|
||||
'pretty_data',
|
||||
]
|
||||
|
||||
def pretty_data(self, obj):
|
||||
return mark_safe("<pre>" + escape(json.dumps(json.loads(obj.data), indent=2)) + "</pre>")
|
||||
pretty_data.short_description = "Data"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import json # TODO consider faster APIs
|
||||
|
||||
from rest_framework import permissions, status
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.views import APIView
|
||||
@@ -19,7 +21,10 @@ class BaseIngestAPIView(APIView):
|
||||
http_method_names = ["post"]
|
||||
|
||||
def process_event(self, event_data, request, project):
|
||||
DecompressedEvent.objects.create(project=project, data=event_data)
|
||||
DecompressedEvent.objects.create(
|
||||
project=project,
|
||||
data=json.dumps(event_data), # TODO don't parse-then-print for BaseIngestion
|
||||
)
|
||||
|
||||
|
||||
class IngestEventAPIView(BaseIngestAPIView):
|
||||
|
||||
Reference in New Issue
Block a user