Skip to content

Commit 27998fc

Browse files
authored
WP-777 - json download issue (#380)
1 parent ed8458c commit 27998fc

File tree

1 file changed

+2
-33
lines changed
  • apcd_cms/src/apps/admin_submissions

1 file changed

+2
-33
lines changed

apcd_cms/src/apps/admin_submissions/views.py

+2-33
Original file line numberDiff line numberDiff line change
@@ -60,37 +60,6 @@ def get_options(self, request):
6060
except Exception as e:
6161
logger.error("Error fetching options data: %s", e)
6262
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)
9463

9564
def filtered_submissions(self, submission_content, status, sort):
9665
def getDate(submission):
@@ -162,8 +131,8 @@ def get_log(cls, request, is_admin=False):
162131

163132
if log_type not in content_types:
164133
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])
167136
response['Content-Disposition'] = f'attachment; filename="{file_name}"'
168137
return response
169138

0 commit comments

Comments
 (0)