35 lines
No EOL
1.1 KiB
Python
35 lines
No EOL
1.1 KiB
Python
from django.views.generic import View
|
|
from django.http.response import JsonResponse
|
|
|
|
from ..models import Panic
|
|
|
|
|
|
class HistoryView(View):
|
|
def get(self, request, *args, **kwargs) -> JsonResponse:
|
|
"""Return historic information about panic mode
|
|
|
|
Args:
|
|
request (HttpRequest): The request
|
|
*args: Additional arguments
|
|
**kwargs: Additional keyword arguments
|
|
|
|
Returns:
|
|
JsonResponse: The response
|
|
"""
|
|
|
|
panix = Panic.objects.all().order_by("created_at")
|
|
|
|
return JsonResponse({
|
|
"success": True,
|
|
"panics": [
|
|
{
|
|
"created_by": panic.created_by_user.username,
|
|
"created_at": panic.created_at,
|
|
"resolved_by": panic.resolved_by_user.username if panic.resolved_by_user else None,
|
|
"resolved_at": panic.resolved_at,
|
|
"create_reason": panic.create_reason,
|
|
"resolve_reason": panic.resolve_reason,
|
|
}
|
|
for panic in panix
|
|
]
|
|
}) |