add in later and reverse yes and no (bug 729839)

This commit is contained in:
Andy McKay 2012-02-23 09:35:30 -08:00
Родитель c97579feeb
Коммит 8adb71381a
6 изменённых файлов: 41 добавлений и 10 удалений

Просмотреть файл

@ -10,10 +10,10 @@ exports.email_setup = function() {
}
$('div.paypal-inline input[type=radio]').click(function(e) {
if ($(this).val() === 'no') {
$('#id_email').closest('div').hide();
} else {
if ($(this).val() === 'yes') {
$('#id_email').closest('div').show();
} else {
$('#id_email').closest('div').hide();
}
});
}

Просмотреть файл

@ -1198,13 +1198,18 @@ class AppFormBasic(addons.forms.AddonFormBase):
class PaypalSetupForm(happyforms.Form):
business_account = forms.ChoiceField(widget=forms.RadioSelect,
choices=(('no', _('No')),
('yes', _('Yes'))),
label="""Do you already have a PayPal
choices=[],
label="""Do you already have a PayPal
Premier or Business account?""")
email = forms.EmailField(required=False,
label='PayPal email address')
def __init__(self, *args, **kw):
super(PaypalSetupForm, self).__init__(*args, **kw)
self.fields['business_account'].choices = (('yes', _lazy('Yes')),
('no', _lazy('No')))
def clean(self):
data = self.cleaned_data
if data.get('business_account') == 'yes' and not data.get('email'):

Просмотреть файл

@ -41,7 +41,8 @@ from addons.models import Addon, AddonUser
from addons.views import BaseFilter
from mkt.developers.decorators import dev_required
from mkt.developers.forms import (CheckCompatibilityForm, InappConfigForm,
AppFormBasic, AppFormDetails)
AppFormBasic, AppFormDetails,
PaypalSetupForm)
from mkt.developers.models import ActivityLog, SubmitStep
from mkt.developers import perf
from mkt.submit.decorators import submit_step
@ -260,7 +261,7 @@ def paypal_setup(request, addon_id, addon, webapp):
messages.error(request, 'Your app does not use payments.')
return redirect(addon.get_dev_url('payments'))
form = forms.PaypalSetupForm(request.POST or None)
form = PaypalSetupForm(request.POST or None)
context = {'addon': addon, 'form': form}
if form.is_valid():
existing = form.cleaned_data['business_account']

Просмотреть файл

@ -16,6 +16,7 @@ from amo.utils import raise_required
from devhub import tasks as devhub_tasks
from files.models import FileUpload
from market.models import AddonPremium, Price
from mkt.developers.forms import PaypalSetupForm as OriginalPaypalSetupForm
from mkt.site.forms import AddonChoiceField, APP_UPSELL_CHOICES
from translations.widgets import TransInput, TransTextarea
from translations.fields import TransField
@ -54,6 +55,16 @@ class NewWebappForm(happyforms.Form):
return upload
class PaypalSetupForm(OriginalPaypalSetupForm):
def __init__(self, *args, **kw):
super(PaypalSetupForm, self).__init__(*args, **kw)
self.fields['business_account'].choices = (
('yes', _lazy('Yes')),
('no', _lazy('No')),
('later', _lazy("I'll link my PayPal account later.")))
class PremiumTypeForm(happyforms.Form):
premium_type = forms.TypedChoiceField(coerce=lambda x: int(x),
choices=amo.ADDON_PREMIUM_TYPES.items(),

Просмотреть файл

@ -737,6 +737,13 @@ class TestPaymentsAdvanced(TestSubmit):
eq_(res.status_code, 302)
eq_(res._headers['location'][1], settings.PAYPAL_CGI_URL)
def test_later_paypal(self):
self.webapp.update(premium_type=amo.ADDON_PREMIUM)
res = self.client.post(self.get_url('payments.paypal'),
{'business_account': 'later'})
eq_(res.status_code, 302)
self.assertRedirects(res, self.get_url('done'))
def test_bad_paypal(self):
# some tests for when it goes wrong
raise SkipTest

Просмотреть файл

@ -11,8 +11,9 @@ from addons.models import Addon, AddonUser
from market.models import AddonPaymentData
from mkt.developers import tasks
from mkt.developers.decorators import dev_required
from mkt.developers.forms import PaypalSetupForm, PaypalPaymentData
from mkt.submit.forms import AppDetailsBasicForm, PreviewFormSet
from mkt.developers.forms import PaypalPaymentData
from mkt.submit.forms import (AppDetailsBasicForm, PaypalSetupForm,
PreviewFormSet)
from mkt.submit.models import AppSubmissionChecklist
import paypal
from files.models import Platform
@ -174,6 +175,12 @@ def payments_paypal(request, addon_id, addon):
form = PaypalSetupForm(request.POST or None)
if request.POST and form.is_valid():
existing = form.cleaned_data['business_account']
if existing == 'later':
# We'll have a premium or similar account with no PayPal id
# at this point.
(AppSubmissionChecklist.objects.get(addon=addon)
.update(payments=True))
return redirect('submit.app.done', addon.app_slug)
if existing != 'yes':
# Go create an account.
# TODO: this will either become the API or something some better