Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit b7b6ce5

Browse files
author
Andy McKay
committed
scorched earth non ajax pass of advanced payments submission (bug 726205)
1 parent 8eae390 commit b7b6ce5

File tree

13 files changed

+346
-34
lines changed

13 files changed

+346
-34
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
INSERT INTO waffle_flag_mkt
2+
(name, everyone, percent, superusers, staff, authenticated, rollout, note) VALUES
3+
('advanced-payments-submission', 0, NULL, 0, 0, 0, 0, 'A more advanced payments submission');

mkt/developers/decorators.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from addons.decorators import addon_view
1010

1111

12-
def dev_required(owner_for_post=False, allow_editors=False, webapp=False):
12+
def dev_required(owner_for_post=False, allow_editors=False, webapp=False,
13+
skip_submit_check=False):
1314
"""Requires user to be add-on owner or admin.
1415
1516
When allow_editors is True, an editor can view the page.
@@ -35,16 +36,17 @@ def wrapper(request, addon, *args, **kw):
3536
# Ignore disabled so they can view their add-on.
3637
elif acl.check_addon_ownership(request, addon, viewer=True,
3738
ignore_disabled=True):
38-
try:
39-
# If it didn't go through the app submission
40-
# checklist. Don't die. This will be useful for
41-
# creating apps with an API later.
42-
step = addon.appsubmissionchecklist.get_next()
43-
except ObjectDoesNotExist:
44-
step = None
45-
# Redirect to the submit flow if they're not done.
46-
if not getattr(f, 'submitting', False) and step:
47-
return _resume(addon, step)
39+
if not skip_submit_check:
40+
try:
41+
# If it didn't go through the app submission
42+
# checklist. Don't die. This will be useful for
43+
# creating apps with an API later.
44+
step = addon.appsubmissionchecklist.get_next()
45+
except ObjectDoesNotExist:
46+
step = None
47+
# Redirect to the submit flow if they're not done.
48+
if not getattr(f, 'submitting', False) and step:
49+
return _resume(addon, step)
4850
return fun()
4951
return http.HttpResponseForbidden()
5052
return wrapper

mkt/developers/forms.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from files.models import File, FileUpload, Platform
3333
from files.utils import parse_addon, VERSION_RE
3434
from market.models import AddonPremium, Price, AddonPaymentData
35+
from mkt.site.forms import AddonChoiceField, APP_UPSELL_CHOICES
3536
from payments.models import InappConfig
3637
from translations.widgets import (TransInput, TransTextarea,
3738
TranslationTextarea, TranslationTextInput)
@@ -981,21 +982,6 @@ def clean_manifest(self):
981982
return manifest
982983

983984

984-
UPSELL_CHOICES = (
985-
(0, _("I don't have a free add-on to associate.")),
986-
(1, _('This is a premium upgrade to:')),
987-
)
988-
APP_UPSELL_CHOICES = (
989-
(0, _("I don't have a free app to associate.")),
990-
(1, _('This is a premium upgrade to:')),
991-
)
992-
993-
994-
class AddonChoiceField(forms.ModelChoiceField):
995-
def label_from_instance(self, obj):
996-
return obj.name
997-
998-
999985
class PremiumForm(happyforms.Form):
1000986
"""
1001987
The premium details for an addon, which is unfortunately
@@ -1009,7 +995,7 @@ class PremiumForm(happyforms.Form):
1009995
empty_label=None,
1010996
required=False)
1011997
do_upsell = forms.TypedChoiceField(coerce=lambda x: bool(int(x)),
1012-
choices=UPSELL_CHOICES,
998+
choices=APP_UPSELL_CHOICES,
1013999
widget=forms.RadioSelect(),
10141000
required=False)
10151001
free = AddonChoiceField(queryset=Addon.objects.none(),

mkt/developers/views.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
AppFormBasic, AppFormDetails)
4545
from mkt.developers.models import ActivityLog, SubmitStep
4646
from mkt.developers import perf
47+
from mkt.submit.decorators import submit_step
4748
from editors.helpers import get_position
4849
from files.models import File, FileUpload, Platform
4950
from files.utils import parse_addon
@@ -295,7 +296,7 @@ def paypal_setup_bounce(request, addon_id, addon, webapp):
295296
if not addon.paypal_id:
296297
messages.error(request, 'We need a PayPal email before continuing.')
297298
return redirect(addon.get_dev_url('paypal_setup'))
298-
paypal_url = paypal.get_permission_url(addon, 'payments',
299+
paypal_url = paypal.get_permission_url(addon, 'management',
299300
['REFUND',
300301
'ACCESS_BASIC_PERSONAL_DATA',
301302
'ACCESS_ADVANCED_PERSONAL_DATA'])
@@ -320,15 +321,28 @@ def paypal_setup_confirm(request, addon_id, addon, webapp):
320321

321322

322323
@write
323-
@dev_required(webapp=True)
324+
@dev_required(webapp=True, skip_submit_check=True)
324325
def acquire_refund_permission(request, addon_id, addon, webapp=False):
325326
"""This is the callback from Paypal."""
327+
# Set up our redirects.
328+
if request.GET.get('dest', '') == 'submission':
329+
on_good = reverse('submit.app.payments.confirm',
330+
args=[addon.app_slug])
331+
on_error = reverse('submit.app.payments.paypal',
332+
args=[addon.app_slug])
333+
show_good_msgs = False
334+
else:
335+
# The management pages are the default.
336+
on_good = addon.get_dev_url('paypal_setup_confirm')
337+
on_error = addon.get_dev_url('paypal_setup_bounce')
338+
show_good_msgs = True
339+
326340
if 'request_token' not in request.GET:
327341
paypal_log.debug('User did not approve permissions for'
328342
' addon: %s' % addon_id)
329343
messages.error(request, 'You will need to accept the permissions '
330344
'to continue.')
331-
return redirect(addon.get_dev_url('paypal_setup_bounce'))
345+
return redirect(on_error)
332346

333347
paypal_log.debug('User approved permissions for addon: %s' % addon_id)
334348

@@ -366,9 +380,10 @@ def acquire_refund_permission(request, addon_id, addon, webapp=False):
366380
paypal_log.debug('AddonPremium saved with token: %s' % addonpremium.pk)
367381
amo.log(amo.LOG.EDIT_PROPERTIES, addon)
368382

369-
messages.success(request, 'Please confirm the data we '
370-
'received from PayPal.')
371-
return redirect(addon.get_dev_url('paypal_setup_confirm'))
383+
if show_good_msgs:
384+
messages.success(request, 'Please confirm the data we '
385+
'received from PayPal.')
386+
return redirect(on_good)
372387
# End of new paypal stuff.
373388

374389

mkt/site/forms.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from django import forms
2+
3+
from tower import ugettext as _
4+
5+
6+
APP_UPSELL_CHOICES = (
7+
(0, _("I don't have a free app to associate.")),
8+
(1, _('This is a premium upgrade to:')),
9+
)
10+
11+
12+
class AddonChoiceField(forms.ModelChoiceField):
13+
def label_from_instance(self, obj):
14+
return obj.name
15+

mkt/submit/forms.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from addons.forms import AddonFormBasic
1010
from addons.models import Addon
1111
from files.models import FileUpload
12+
from market.models import Price
13+
from mkt.site.forms import AddonChoiceField, APP_UPSELL_CHOICES
1214
from translations.widgets import TransInput, TransTextarea
1315
from translations.fields import TransField
1416
from users.models import UserProfile
@@ -52,6 +54,23 @@ class PremiumTypeForm(happyforms.Form):
5254
widget=forms.RadioSelect())
5355

5456

57+
class UpsellForm(happyforms.Form):
58+
price = forms.ModelChoiceField(queryset=Price.objects.active(),
59+
label=_('App price'),
60+
empty_label=None,
61+
required=True)
62+
63+
do_upsell = forms.TypedChoiceField(coerce=lambda x: bool(int(x)),
64+
choices=APP_UPSELL_CHOICES,
65+
widget=forms.RadioSelect(),
66+
required=False)
67+
free = AddonChoiceField(queryset=Addon.objects.none(),
68+
required=False,
69+
empty_label='')
70+
text = forms.CharField(widget=forms.Textarea(), required=False)
71+
72+
73+
5574
class AppDetailsBasicForm(AddonFormBasic):
5675
"""Form for "Details" submission step."""
5776
name = TransField(max_length=128,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{% extends 'developers/base_impala.html' %}
2+
3+
{% set title = _('App Payments') %}
4+
5+
{% block title %}{{ hub_page_title(title) }}{% endblock %}
6+
7+
{% block content %}
8+
{{ hub_breadcrumbs(items=[(None, _('Submit App'))]) }}
9+
<h1>{{ _('Submit an App') }}</h1>
10+
{{ progress(request, addon=addon, step=step) }}
11+
<section id="submit-payments" class="primary">
12+
<h2>App Payments</h2>
13+
<div class="brform island swagger c">
14+
<p>{{ loc('In order to process refunds you approve through the Marketplace
15+
as well as automatic refunds we need you to give permission to us
16+
in PayPal. We also request permission to read your account information
17+
from PayPal.') }}</p>
18+
<footer class="listing-footer">
19+
<a href="{{ paypal_url }}" class="button">Set up permissions</a>
20+
</footer>
21+
</div>
22+
</section>
23+
{% endblock %}
24+
25+
26+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{% extends 'developers/base_impala.html' %}
2+
3+
{% set title = _('App Payments') %}
4+
5+
{% block title %}{{ hub_page_title(title) }}{% endblock %}
6+
7+
{% block content %}
8+
{{ hub_breadcrumbs(items=[(None, _('Submit App'))]) }}
9+
<h1>{{ _('Submit an App') }}</h1>
10+
{{ progress(request, addon=addon, step=step) }}
11+
<section id="submit-payments" class="primary">
12+
<h2>App Payments</h2>
13+
<form method="post" id="upload-webapp">
14+
<div class="brform island swagger c">
15+
{{ csrf() }}
16+
<p>{{ loc("Your PayPal is all set up! The last thing we need is
17+
your real name and contact information.") }}</p>
18+
<p>
19+
{{ form.as_p() }}
20+
</p>
21+
</div>
22+
<button class="prominent continue c" type="submit">
23+
{{ _('Continue') }}
24+
</button>
25+
</form>
26+
</section>
27+
{% endblock %}
28+
29+
30+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% extends 'developers/base_impala.html' %}
2+
3+
{% set title = _('App Payments') %}
4+
5+
{% block title %}{{ hub_page_title(title) }}{% endblock %}
6+
7+
{% block content %}
8+
{{ hub_breadcrumbs(items=[(None, _('Submit App'))]) }}
9+
<h1>{{ _('Submit an App') }}</h1>
10+
{{ progress(request, addon=addon, step=step) }}
11+
<section id="submit-payments" class="primary">
12+
<h2>App Payments</h2>
13+
<form method="post" id="upload-webapp">
14+
<div class="brform island swagger c">
15+
{{ csrf() }}
16+
<p>{{ loc("Next, we'll set up your PayPal account so you can
17+
receive payments.") }}</p>
18+
<p>
19+
{{ form.as_p() }}
20+
</p>
21+
</div>
22+
<button class="prominent continue c" type="submit">
23+
{{ _('Continue') }}
24+
</button>
25+
</form>
26+
</section>
27+
{% endblock %}
28+
29+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{% extends 'developers/base_impala.html' %}
2+
3+
{% set title = _('App Payments') %}
4+
5+
{% block title %}{{ hub_page_title(title) }}{% endblock %}
6+
7+
{% block content %}
8+
{{ hub_breadcrumbs(items=[(None, _('Submit App'))]) }}
9+
<h1>{{ _('Submit an App') }}</h1>
10+
{{ progress(request, addon=addon, step=step) }}
11+
<section id="submit-payments" class="primary">
12+
<h2>App Payments</h2>
13+
<form method="post" id="upload-webapp">
14+
<div class="brform island swagger c">
15+
{{ csrf() }}
16+
<p>{{ loc("To sell your app in the Marketplace you'll first need
17+
to set your price. Select a price tier for your add-on
18+
below. Price tiers are based on US Dollars and are
19+
fixed for all support countries.") }} </p>
20+
<p>
21+
{{ form.as_p() }}
22+
</p>
23+
</div>
24+
<button class="prominent continue c" type="submit">
25+
{{ _('Continue') }}
26+
</button>
27+
</form>
28+
</section>
29+
{% endblock %}
30+

0 commit comments

Comments
 (0)