Fill in some missing account data (bug 759526)

This commit is contained in:
Kumar McMillan 2012-06-05 19:15:15 -05:00
Родитель a09131cd28
Коммит 2b1b55e7c6
4 изменённых файлов: 80 добавлений и 14 удалений

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

@ -298,7 +298,7 @@ class AddonPaymentData(amo.models.ModelBase):
#
# I've no idea what the biggest lengths of these are, so making
# up some aribtrary lengths.
addon = models.OneToOneField('addons.Addon')
addon = models.OneToOneField('addons.Addon', related_name='payment_data')
# Basic.
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)

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

@ -55,7 +55,13 @@
<h2>{{ _('Payments') }}</h2>
<dl>
<dt>{{ _('PayPal linked') }}:</dt>
<dd>TODO</dd>
<dd>
{% for email in paypal_ids %}
<div>{{ email }}</div>
{% else %}
<div>{{ _('None') }}</div>
{% endfor %}
</dd>
<dt>{{ _('Marketplace Credit') }}:</dt>
<dd>TODO</dd>
<dt>{{ _('Payments') }}:</dt>
@ -80,8 +86,23 @@
{{ _('No') }}
{% endif %}
</dd>
<dt>{{ _('Address') }}:</dt>
<dd>TODO</dd>
<dt>{{ _('Addresses') }}:</dt>
<dd>
{% for pd in payment_data %}
<div>{{ pd.full_name }}</div>
{% if pd.business_name %}
<div>{{ pd.business_name }}</div>
{% endif %}
<div>{{ pd.address_one }}</div>
{% if pd.address_two %}
<div>{{ pd.address_two }}</div>
{% endif %}
<div>{{ pd.city }}, {{ pd.state }} {{ pd.post_code }}</div>
<div>{{ pd.country }}</div>
{% else %}
{{ _('None') }}
{% endfor %}
</dd>
<dt>{{ _('Submissions') }}:</dt>
<dd class="submissions">
{% for addon in user_addons %}

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

@ -7,7 +7,7 @@ from addons.models import Addon
import amo
from amo.urlresolvers import reverse
from amo.tests import TestCase, ESTestCase, app_factory
from market.models import Refund
from market.models import Refund, AddonPaymentData
from stats.models import Contribution
from users.cron import reindex_users
from users.models import UserProfile
@ -25,11 +25,11 @@ class TestAcctSummary(AcctLookupTest, TestCase):
def setUp(self):
super(TestAcctSummary, self).setUp()
self.user_id = 31337 # steamcube
self.user = UserProfile.objects.get(pk=31337) # steamcube
self.steamcube = Addon.objects.get(pk=337141)
self.otherapp = app_factory(app_slug='otherapp')
self.reg_user = UserProfile.objects.get(email='regular@mozilla.com')
self.summary_url = reverse('acct_lookup.summary', args=[self.user_id])
self.summary_url = reverse('acct_lookup.summary', args=[self.user.pk])
def buy_stuff(self, contrib_type):
for i in range(3):
@ -42,7 +42,7 @@ class TestAcctSummary(AcctLookupTest, TestCase):
type=contrib_type,
currency=curr,
amount=amount,
user_id=self.user_id)
user_id=self.user.pk)
def summary(self, expected_status=200):
res = self.client.get(self.summary_url)
@ -66,7 +66,7 @@ class TestAcctSummary(AcctLookupTest, TestCase):
def test_basic_summary(self):
res = self.summary()
eq_(res.context['account'].pk, self.user_id)
eq_(res.context['account'].pk, self.user.pk)
def test_app_counts(self):
self.buy_stuff(amo.CONTRIB_PURCHASE)
@ -84,7 +84,7 @@ class TestAcctSummary(AcctLookupTest, TestCase):
def test_requested_refunds(self):
contrib = Contribution.objects.create(type=amo.CONTRIB_PURCHASE,
user_id=self.user_id,
user_id=self.user.pk,
addon=self.steamcube,
currency='USD',
amount='0.99')
@ -95,7 +95,7 @@ class TestAcctSummary(AcctLookupTest, TestCase):
def test_approved_refunds(self):
contrib = Contribution.objects.create(type=amo.CONTRIB_PURCHASE,
user_id=self.user_id,
user_id=self.user.pk,
addon=self.steamcube,
currency='USD',
amount='0.99')
@ -109,6 +109,42 @@ class TestAcctSummary(AcctLookupTest, TestCase):
res = self.summary()
eq_(len(res.context['user_addons']), 1)
def test_paypal_ids(self):
self.user.addons.update(paypal_id='somedev@app.com')
res = self.summary()
eq_(list(res.context['paypal_ids']), [u'somedev@app.com'])
def test_no_paypal(self):
self.user.addons.update(paypal_id='')
res = self.summary()
eq_(list(res.context['paypal_ids']), [])
def test_payment_data(self):
AddonPaymentData.objects.create(addon=self.steamcube,
full_name='Ed Peabody Jr.',
business_name='Mr. Peabody',
phone='(1) 773-111-2222',
address_one='1111 W Leland Ave',
address_two='Apt 1W',
city='Chicago',
post_code='60640',
country='USA',
state='Illinois')
res = self.summary()
pd = res.context['payment_data'][0]
eq_(pd.full_name, 'Ed Peabody Jr.')
eq_(pd.business_name, 'Mr. Peabody')
eq_(pd.address_one, '1111 W Leland Ave')
eq_(pd.address_two, 'Apt 1W')
eq_(pd.city, 'Chicago')
eq_(pd.state, 'Illinois')
eq_(pd.post_code, '60640')
eq_(pd.country, 'USA')
def test_no_payment_data(self):
res = self.summary()
eq_(res.context['payment_data'], [])
class TestAcctSearch(AcctLookupTest, ESTestCase):
fixtures = ['base/users']

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

@ -30,14 +30,23 @@ def summary(request, user_id):
refund_summary = {'approved': appr.count(),
'requested': req.count()}
# TODO: This should return all `addon` types and not just webapps.
# -- currently get_details_url() fails on non-webapps so this is a temp fix.
user_addons = user.addons.filter(type=amo.ADDON_WEBAPP).order_by('-created')
# -- currently get_details_url() fails on non-webapps so this is a
# temp fix.
user_addons = (user.addons.filter(type=amo.ADDON_WEBAPP)
.order_by('-created'))
user_addons = paginate(request, user_addons, per_page=15)
paypal_ids = (user.addons.exclude(paypal_id='').distinct('paypal_id')
.values_list('paypal_id', flat=True))
payment_data = []
for ad in user.addons.exclude(payment_data=None):
payment_data.append(ad.payment_data)
return jingo.render(request, 'acct_lookup/summary.html',
{'account': user,
'app_summary': app_summary,
'refund_summary': refund_summary,
'user_addons': user_addons})
'user_addons': user_addons,
'payment_data': payment_data,
'paypal_ids': paypal_ids})
@login_required