mirror of
https://github.com/viq/NewsBlur.git
synced 2025-04-13 09:38:09 +00:00
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
![]() |
from django import forms
|
||
|
from vendor.zebra.forms import StripePaymentForm
|
||
|
from django.utils.safestring import mark_safe
|
||
|
PLANS = [
|
||
|
(1, mark_safe("$12 / year <span class='NB-small'>($1/month)</span>")),
|
||
|
(2, mark_safe("$24 / year <span class='NB-small'>($2/month)</span>")),
|
||
|
(3, mark_safe("$36 / year <span class='NB-small'>($3/month)</span>")),
|
||
|
]
|
||
|
|
||
|
class HorizRadioRenderer(forms.RadioSelect.renderer):
|
||
|
""" this overrides widget method to put radio buttons horizontally
|
||
|
instead of vertically.
|
||
|
"""
|
||
|
def render(self):
|
||
|
"""Outputs radios"""
|
||
|
choices = '\n'.join(['%s\n' % w for w in self])
|
||
|
return mark_safe('<div class="NB-stripe-plan-choice">%s</div>' % choices)
|
||
|
|
||
|
class StripePlusPaymentForm(StripePaymentForm):
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
email = kwargs.pop('email')
|
||
|
plan = kwargs.pop('plan', '')
|
||
|
super(StripePlusPaymentForm, self).__init__(*args, **kwargs)
|
||
|
self.fields['email'].initial = email
|
||
|
if plan:
|
||
|
self.fields['plan'].initial = int(plan)
|
||
|
|
||
|
email = forms.EmailField(widget=forms.TextInput(attrs=dict(maxlength=75)),
|
||
|
label='Email address',
|
||
|
required=False)
|
||
|
plan = forms.ChoiceField(required=False, widget=forms.RadioSelect(renderer=HorizRadioRenderer),
|
||
|
choices=PLANS, label='Plan')
|