Return same authors list in JSON API responses as XML responses.
This commit is contained in:
Родитель
ca260a85c4
Коммит
9bbc159114
|
@ -16,6 +16,7 @@ import amo
|
|||
from addons.models import (Addon, AppSupport, CompatOverride,
|
||||
CompatOverrideRange, Persona, Preview)
|
||||
from amo import helpers
|
||||
from amo.helpers import absolutify
|
||||
from amo.tests import addon_factory, ESTestCase, TestCase
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.views import handler500
|
||||
|
@ -297,7 +298,9 @@ class APITest(TestCase):
|
|||
eq_(data['guid'], addon.guid)
|
||||
eq_(data['version'], '2.1.072')
|
||||
eq_(data['status'], 'public')
|
||||
eq_(data['author'], u'55021 \u0627\u0644\u062a\u0637\u0628')
|
||||
eq_(data['authors'],
|
||||
[{'id': 55021, 'name': u'55021 \u0627\u0644\u062a\u0637\u0628',
|
||||
'link': absolutify(u'/en-US/firefox/user/55021/?src=api')}])
|
||||
eq_(data['summary'], unicode(addon.summary))
|
||||
eq_(data['description'],
|
||||
'This extension integrates your browser with Delicious '
|
||||
|
@ -342,7 +345,7 @@ class APITest(TestCase):
|
|||
eq_(doc('license name').length, 1)
|
||||
eq_(doc('license url').length, 1)
|
||||
eq_(doc('license name').text(), unicode(license.name))
|
||||
eq_(doc('license url').text(), helpers.absolutify(license.url))
|
||||
eq_(doc('license url').text(), absolutify(license.url))
|
||||
|
||||
license.url = ''
|
||||
license.save()
|
||||
|
@ -350,7 +353,7 @@ class APITest(TestCase):
|
|||
response = self.client.get(api_url)
|
||||
doc = pq(response.content)
|
||||
license_url = addon.current_version.license_url()
|
||||
eq_(doc('license url').text(), helpers.absolutify(license_url))
|
||||
eq_(doc('license url').text(), absolutify(license_url))
|
||||
|
||||
license.delete()
|
||||
response = self.client.get(api_url)
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.conf import settings
|
|||
from django.utils.html import strip_tags
|
||||
|
||||
import amo
|
||||
from amo.helpers import absolutify
|
||||
from amo.urlresolvers import reverse
|
||||
from amo.utils import urlparams, epoch
|
||||
from addons.models import Category
|
||||
|
@ -35,8 +36,9 @@ def addon_to_dict(addon, disco=False, src='api'):
|
|||
'guid': addon.guid,
|
||||
'status': amo.STATUS_CHOICES_API[addon.status],
|
||||
'type': amo.ADDON_SLUGS_UPDATE[addon.type],
|
||||
'author': (addon.listed_authors[0].name if
|
||||
addon.listed_authors else ''),
|
||||
'authors': [{'id': a.id, 'name': a.name,
|
||||
'link': absolutify(a.get_url_path(src=src))}
|
||||
for a in addon.listed_authors],
|
||||
'summary': strip_tags(addon.summary),
|
||||
'description': strip_tags(addon.description),
|
||||
'icon': addon.icon_url,
|
||||
|
|
Загрузка…
Ссылка в новой задаче