@@ -60,37 +60,6 @@ def get_options(self, request):
60
60
except Exception as e :
61
61
logger .error ("Error fetching options data: %s" , e )
62
62
return JsonResponse ({'error' : str (e )}, status = 500 )
63
-
64
- def get_log (self , request ):
65
- try :
66
- log_type = self .get_required_param (request , 'log_type' , default = 'html' )
67
- log_id = self .get_required_param (request , 'log_id' )
68
-
69
- results = get_user_submission_log (log_id , log_type )
70
- if not results :
71
- raise Http404 ("Log not found or empty." )
72
-
73
- file_path = results [0 ][1 ]
74
- file_name = file_path .split ('/' )[- 1 ] if '/' in file_path else file_path
75
-
76
- content_types = {
77
- 'html' : "text/html" ,
78
- 'json' : "application/json" ,
79
- }
80
-
81
- if log_type not in content_types :
82
- raise Http404 ("Unsupported log type requested." )
83
-
84
- response = HttpResponse (results [0 ][0 ], content_type = content_types [log_type ])
85
- response ['Content-Disposition' ] = f'attachment; filename="{ file_name } "'
86
- return response
87
-
88
- except Http404 as e :
89
- logger .warning ("Log not found or unsupported log type: %s" , e )
90
- raise
91
- except Exception as e :
92
- logger .error ("Error fetching log data: %s" , e )
93
- return JsonResponse ({'error' : 'Internal error fetching log.' }, status = 500 )
94
63
95
64
def filtered_submissions (self , submission_content , status , sort ):
96
65
def getDate (submission ):
@@ -162,8 +131,8 @@ def get_log(cls, request, is_admin=False):
162
131
163
132
if log_type not in content_types :
164
133
raise Http404 ("Unsupported log type requested." )
165
-
166
- response = HttpResponse (results [0 ][0 ], content_type = content_types [log_type ])
134
+
135
+ response = HttpResponse (str ( results [0 ][0 ]) , content_type = content_types [log_type ])
167
136
response ['Content-Disposition' ] = f'attachment; filename="{ file_name } "'
168
137
return response
169
138
0 commit comments