Skip to content

Commit

Permalink
[#13] Fixed admin button
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Dec 12, 2024
1 parent 1877cef commit 0a3436a
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions log_outgoing_requests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from django import forms
from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html
from django.utils.html import mark_safe
from django.utils.translation import gettext as _

from solo.admin import SingletonModelAdmin
Expand Down Expand Up @@ -59,8 +58,8 @@ class OutgoingRequestsLogAdmin(admin.ModelAdmin):
"res_headers",
"res_content_type",
"res_body_encoding",
"response_body",
"prettify_body_response",
"response_body",
)
},
),
Expand Down Expand Up @@ -106,17 +105,15 @@ def response_body(self, obj) -> str:
return obj.response_body_decoded or "-"

def prettify_body_response(self, obj):
prettify_url = reverse("prettify_view")
original_url = reverse("original_view")

return format_html(
'<a class="prettify-body-response" href="{}">{}</a> | <a class="original-body-response" href="{}">{}</a><br><div class="body-response-text">{}</div>',
prettify_url,
"Prettify",
original_url,
"Original",
obj.res_body_encoding,
)
body_response = ""
if "xml" in obj.res_content_type or "json" in obj.res_content_type:
body_response = mark_safe(
f"""
<a href="#" class="prettify-toggle-link">Prettify</a><br>
<textarea readonly class="prettify-output" style="display:none;" rows="15" cols="60" content-type='{obj.res_content_type}'>{obj.response_body_decoded}</textarea>
"""
)
return body_response

prettify_body_response.allow_tags = True

Expand Down

0 comments on commit 0a3436a

Please sign in to comment.