put a flag on refunds (bug 708604)

This commit is contained in:
Andy McKay 2011-12-21 11:30:27 -08:00
Родитель fd0df62fd7
Коммит 75e1727352
6 изменённых файлов: 21 добавлений и 5 удалений

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

@ -1317,6 +1317,8 @@ class TestIssueRefund(amo.tests.TestCase):
fixtures = ('base/apps', 'base/users', 'base/addon_3615')
def setUp(self):
waffle.models.Flag.objects.create(name='allow-refund', everyone=True)
self.addon = Addon.objects.get(id=3615)
self.transaction_id = u'fake-txn-id'
self.paykey = u'fake-paykey'

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

@ -28,6 +28,7 @@ from PIL import Image
from session_csrf import anonymous_csrf
from tower import ugettext_lazy as _lazy, ugettext as _
import waffle
from waffle.decorators import waffle_flag
from applications.models import Application, AppVersion
import amo
@ -495,6 +496,7 @@ def acquire_refund_permission(request, addon_id, addon, webapp=False):
return redirect(addon.get_dev_url(dest))
@waffle_flag('allow-refund')
@dev_required(webapp=True)
def issue_refund(request, addon_id, addon, webapp=False):
txn_id = request.REQUEST.get('transaction_id')

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

@ -14,5 +14,12 @@
<p><a href="{{ url('users.support', contribution.pk, 'resources') }}">
{{ _('I have billing or payment concerns &raquo;') }}</a></p>
#}
<p><a href="{{ url('users.support', contribution.pk, 'request') }}">
{{ _('I want to request a refund &raquo;') }}</a></p>
{% if waffle.switch('allow-refund') %}
<p><a href="{{ url('users.support', contribution.pk, 'request') }}">
{{ _('I want to request a refund &raquo;') }}</a></p>
{% else %}
{# Temporary text, no i18n or even loc on purpose #}
<p>Refunds are not enabled in the Apps Developer Preview.
If you wish to provide a refund you can do so through the PayPal user
interface.</p>
{% endif %}

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

@ -1193,6 +1193,7 @@ class TestPurchases(amo.tests.TestCase):
def setUp(self):
waffle.models.Switch.objects.create(name='marketplace', active=True)
waffle.models.Flag.objects.create(name='allow-refund', everyone=True)
self.url = reverse('users.purchases')
self.client.login(username='regular@mozilla.com', password='password')

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

@ -16,7 +16,7 @@ from django.utils.http import base36_to_int
from django.contrib.auth.tokens import default_token_generator
from django_browserid.auth import BrowserIDBackend
from waffle.decorators import waffle_flag
from waffle.decorators import waffle_flag, waffle_switch
import commonware.log
import jingo
@ -745,10 +745,9 @@ class PurchasesFilter(BaseFilter):
@login_required
@mobile_template('users/{mobile/}purchases.html')
@waffle_switch('marketplace')
def purchases(request, addon_id=None, template=None):
"""A list of purchases that a user has made through the marketplace."""
if not waffle.switch_is_active('marketplace'):
raise http.Http404
webapp = settings.APP_PREVIEW
cs = (Contribution.objects
.filter(user=request.amo_user,
@ -848,6 +847,7 @@ def support_mozilla(request, contribution, wizard):
{'addon': addon, 'form': form})
@waffle_flag('allow-refund')
def refund_request(request, contribution, wizard):
addon = contribution.addon
webapp = addon.is_webapp()
@ -860,6 +860,7 @@ def refund_request(request, contribution, wizard):
'form': form, 'contribution': contribution})
@waffle_flag('allow-refund')
def refund_reason(request, contribution, wizard):
addon = contribution.addon
if not 'request' in wizard.get_progress():

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

@ -0,0 +1,3 @@
INSERT INTO `waffle_flag`
(name, everyone, percent, superusers, staff, authenticated, rollout, note) VALUES
('allow-refund',0,NULL,0,0,0,0, 'Allow refund of paypal payments');