Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "on the user's profile, make the tip button open the QR code for the BCH address and remove the PayPal form. #1820" #1845

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@
path("company/", include("company.urls")),
path("sponsor/", website.views.sponsor_view, name="sponsor"),
path("companies/", DomainListView.as_view(), name="domain_lists"),
path("generate-bch-qr/<str:username>/", website.views.generate_bch_qr, name="generate_bch_qr"),
]

if settings.DEBUG:
Expand Down
29 changes: 15 additions & 14 deletions website/templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,21 @@ <h1 class="page-header text-capitalize">{{ user.username }}</h1>
{% endif %}
{% endif %}
<div class="status">
<button type="button" id="openModal" class="btn btn-danger" style="color: black;">Send a Tip</button>
<dialog id="dialog">
<img id="qr-image" src="{% url 'generate_bch_qr' username=user.username %}" alt="QR Code">
<p id="bch-address" style="color: aliceblue;">BCH: {{ user.userprofile.crypto_address }}</p>
</dialog>
<form name="_xclick"
action="https://www.paypal.com/cgi-bin/webscr"
method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden"
name="business"
value="{{ project.paypal|default:" coderbounty@gmail.com" }}">
<input type="hidden"
name="item_name"
value="tip for {{ user.username }} on {% env 'DOMAIN_NAME' %}">
<input type="hidden" name="currency_code" value="USD">
<button type="submit" class="btn btn-danger text-black">
<i class="fa fa-money fa-lg"></i> {% trans "Send a tip" %}
</button>
</form>
</div>
</div>
<div class="icon-block">
Expand Down Expand Up @@ -411,15 +421,6 @@ <h1 class="page-header text-capitalize">{{ user.username }}</h1>
</div>
</div>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
const openModalButton = document.getElementById('openModal');
const dialog = document.getElementById('dialog');

openModalButton.addEventListener('click', function() {
dialog.showModal();
});
});

$(function () {
$('.img-thumbnail, .upload-btn').on('mouseenter', function () {
$('.upload-btn').show();
Expand Down
31 changes: 0 additions & 31 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
from collections import deque
from datetime import datetime, timedelta, timezone
from decimal import Decimal
from io import BytesIO
from urllib.parse import urlparse, urlsplit, urlunparse

import humanize
import qrcode
import requests
import requests.exceptions
import six
Expand Down Expand Up @@ -3827,32 +3825,3 @@ def invite_friend(request):
# headers=headers,
# )
# mail.logout()


@csrf_exempt
def generate_bch_qr(request, username):
if request.method == "GET":
try:
user = User.objects.get(username=username)
profile = user.userprofile
address = profile.crypto_address
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(address)
qr.make(fit=True)

img = qr.make_image(fill_color="black", back_color="white")
buffer = BytesIO()
img.save(buffer)
qr_image = buffer.getvalue()
return HttpResponse(qr_image, content_type="image/png")
except User.DoesNotExist:
return HttpResponse(status=404) # User not found
except Exception as e:
return HttpResponse(status=500) # Internal server error
else:
return HttpResponse(status=405) # Method Not Allowed
Loading