add in the firefoxos to devices
This commit is contained in:
Родитель
a68fbb074e
Коммит
691c493e95
|
@ -150,24 +150,28 @@ class DEVICE_DESKTOP(object):
|
|||
id = 1
|
||||
name = _(u'Desktop')
|
||||
class_name = 'desktop'
|
||||
api_name = 'desktop'
|
||||
|
||||
|
||||
class DEVICE_MOBILE(object):
|
||||
id = 2
|
||||
name = _(u'Firefox Mobile')
|
||||
class_name = 'android-mobile'
|
||||
api_name = 'mobile'
|
||||
|
||||
|
||||
class DEVICE_TABLET(object):
|
||||
id = 3
|
||||
name = _(u'Firefox Tablet')
|
||||
class_name = 'android-tablet'
|
||||
api_name = 'tablet'
|
||||
|
||||
|
||||
class DEVICE_GAIA(object):
|
||||
id = 4
|
||||
name = _(u'Firefox OS')
|
||||
class_name = 'firefoxos'
|
||||
api_name = 'firefoxos'
|
||||
|
||||
|
||||
DEVICE_TYPES = {
|
||||
|
|
|
@ -243,7 +243,8 @@ Fields:
|
|||
* `support_url` (optional): a URL to your support homepage.
|
||||
* `support_email` (required): the email address for support.
|
||||
* `device_types` (required): a list of the device types at least one of:
|
||||
'desktop', 'mobile', 'tablet'.
|
||||
'desktop', 'mobile', 'tablet', 'firefoxos'. 'mobile' and 'tablet' both refer
|
||||
to Android mobile and tablet. As opposed to Firefox OS.
|
||||
* `payment_type` (required): only choice at this time is 'free'.
|
||||
|
||||
Example body data::
|
||||
|
|
|
@ -153,7 +153,7 @@ class AppResource(MarketplaceResource):
|
|||
|
||||
def devices(self, data):
|
||||
with no_translation():
|
||||
names = dict([(n.class_name, n.id)
|
||||
names = dict([(n.api_name, n.id)
|
||||
for n in DEVICE_TYPES.values()])
|
||||
filtered = [names.get(n, n) for n in data.get('device_types', [])]
|
||||
return {'device_types': filtered}
|
||||
|
|
|
@ -378,15 +378,15 @@ class TestAppCreateHandler(CreateHandler, AMOPaths):
|
|||
eq_(res.status_code, 400)
|
||||
eq_(self.get_error(res)['device_types'], ['This field is required.'])
|
||||
|
||||
def test_put_desktop_worked(self):
|
||||
def test_put_devices_worked(self):
|
||||
app = self.create_app()
|
||||
data = self.base_data()
|
||||
data['device_types'] = amo.DEVICE_TYPES.keys()[:2]
|
||||
data['device_types'] = [a.api_name for a in amo.DEVICE_TYPES.values()]
|
||||
res = self.client.put(self.get_url, data=json.dumps(data))
|
||||
eq_(res.status_code, 202)
|
||||
app = Webapp.objects.get(pk=app.pk)
|
||||
eq_(set(d for d in app.device_types),
|
||||
set(amo.DEVICE_TYPES[d] for d in amo.DEVICE_TYPES.keys()[:2]))
|
||||
set(amo.DEVICE_TYPES[d] for d in amo.DEVICE_TYPES.keys()))
|
||||
|
||||
def test_put_desktop_error_nice(self):
|
||||
self.create_app()
|
||||
|
|
Загрузка…
Ссылка в новой задаче