From b3e3af1c1a428a01bcfbf1abd313e6aba3013d81 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 3 Oct 2018 22:54:45 +0200 Subject: [PATCH] Make ProductPaymentForm's recurring field hidden --- hosting/forms.py | 11 +++++++++++ hosting/static/hosting/js/payment.js | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hosting/forms.py b/hosting/forms.py index 4092f4a1..6bf9cdd0 100644 --- a/hosting/forms.py +++ b/hosting/forms.py @@ -109,6 +109,17 @@ class ProductPaymentForm(GenericPaymentForm): 'readonly': 'readonly' } ) ) + if self.product.product_is_subscription: + self.fields['amount'].label = "{amt} ({payment_type})".format( + amt=_('Amount in CHF'), + payment_type=_('Monthly subscription') + ) + else: + self.fields['amount'].label = "{amt} ({payment_type})".format( + amt=_('Amount in CHF'), + payment_type = _('One time payment') + ) + self.fields['recurring'].widget=forms.HiddenInput() def clean_amount(self): amount = self.cleaned_data.get('amount') diff --git a/hosting/static/hosting/js/payment.js b/hosting/static/hosting/js/payment.js index 52dd511a..fa89f218 100644 --- a/hosting/static/hosting/js/payment.js +++ b/hosting/static/hosting/js/payment.js @@ -165,9 +165,14 @@ $(document).ready(function () { function submitBillingForm() { var billing_form = $('#billing-form'); + var recurring_input = $('#id_generic_payment_form-recurring'); billing_form.append(''); billing_form.append(''); - billing_form.append(''); + if (recurring_input.attr('type') === 'hidden') { + billing_form.append(''); + } else { + billing_form.append(''); + } billing_form.append(''); billing_form.submit(); }