When a user is thanking, check state to see if other user thanked first, if so switch new_state to THANKED_BY_BOTH. fixes #13
This commit is contained in:
parent
52663c83ef
commit
a83ce746b5
7 changed files with 35 additions and 42 deletions
|
|
@ -498,9 +498,9 @@ class TradeOfferPNGView(View):
|
|||
trade_offer = get_object_or_404(TradeOffer, pk=kwargs['pk'])
|
||||
|
||||
# If the image is already generated and stored, serve it directly.
|
||||
# if trade_offer.image:
|
||||
# trade_offer.image.open()
|
||||
# return HttpResponse(trade_offer.image.read(), content_type="image/png")
|
||||
if trade_offer.image and not request.GET.get("debug"):
|
||||
trade_offer.image.open()
|
||||
return HttpResponse(trade_offer.image.read(), content_type="image/png")
|
||||
|
||||
# Acquire PostgreSQL advisory lock to prevent concurrent generation.
|
||||
from django.db import connection
|
||||
|
|
@ -509,10 +509,10 @@ class TradeOfferPNGView(View):
|
|||
cursor.execute("SELECT pg_advisory_lock(%s)", [lock_key])
|
||||
try:
|
||||
# Double-check if the image was generated while waiting for the lock.
|
||||
# trade_offer.refresh_from_db()
|
||||
# if trade_offer.image:
|
||||
# trade_offer.image.open()
|
||||
# return HttpResponse(trade_offer.image.read(), content_type="image/png")
|
||||
trade_offer.refresh_from_db()
|
||||
if trade_offer.image and not request.GET.get("debug"):
|
||||
trade_offer.image.open()
|
||||
return HttpResponse(trade_offer.image.read(), content_type="image/png")
|
||||
|
||||
tag_context = render_trade_offer_png(
|
||||
{'request': request}, trade_offer, show_friend_code=True
|
||||
|
|
@ -523,6 +523,10 @@ class TradeOfferPNGView(View):
|
|||
raise ValueError("Could not determine image dimensions from tag_context")
|
||||
html = render_to_string("templatetags/trade_offer_png.html", tag_context)
|
||||
|
||||
# if query string has "debug=true", render the HTML instead of the PNG
|
||||
if request.GET.get("debug") == "html":
|
||||
return render(request, "trades/trade_offer_png_debug.html", {"html": html})
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(
|
||||
headless=True,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue