Source code for payments.widgets
"""Widgets provided by the payments package"""
from django.forms import Widget
from payments.models import Payment
[docs]class PaymentWidget(Widget):
"""
Custom widget for the Payment object, used in registrations
"""
template_name = "payments/widgets/payment.html"
[docs] def get_context(self, name, value, attrs) -> dict:
context = super().get_context(name, value, attrs)
if value:
payment = Payment.objects.get(pk=value)
context["url"] = payment.get_admin_url()
context["payment"] = payment
return context