Fix trade offer png generation (fixes #27).

- Updated `card_badge.html` to adjust width properties for better layout consistency.
- Modified `trade_offer_png.html` to change padding for improved visual appearance.
- Enhanced `bubble_up_trade_offer_updates` signal to delete cached images when related instances change, ensuring up-to-date content.
- Updated `TradeOfferPNGView` to pass the request context when rendering the template, improving compatibility with Django's template rendering.
- Refactored `render_trade_offer_png` to use constants for dimensions and improve readability, while also updating context handling for better integration.
This commit is contained in:
badblocks 2025-05-05 21:50:52 -07:00
parent 9c41f63247
commit 9b3b3d099f
5 changed files with 40 additions and 17 deletions

View file

@ -1,3 +1,4 @@
from django.template import RequestContext
from django.views.generic import DeleteView, CreateView, ListView, DetailView, UpdateView
from django.views import View
from django.urls import reverse_lazy
@ -521,9 +522,13 @@ class TradeOfferPNGView(View):
image_height = tag_context.get('image_height')
if not image_width or not image_height:
raise ValueError("Could not determine image dimensions from tag_context")
html = render_to_string("templatetags/trade_offer_png.html", tag_context)
html = render_to_string(
"templatetags/trade_offer_png.html",
context=tag_context,
request=request
)
# if query string has "debug=true", render the HTML instead of the PNG
# if query string has "debug", render the HTML instead of the PNG
if request.GET.get("debug") == "html":
return render(request, "templatetags/trade_offer_png.html", tag_context)