def collection_detail_json(request, username, slug): c = get_collection(request, username, slug) if not (c.listed or acl.check_collection_ownership(request, c)): raise PermissionDenied # We evaluate the QuerySet with `list` to work around bug 866454. addons_dict = [addon_to_dict(a) for a in list(c.addons.valid())] return {"name": c.name, "url": c.get_abs_url(), "iconUrl": c.icon_url, "addons": addons_dict}
def test_contrib_info(self): self.a.wants_contributions = True self.a.suggested_amount = 5 self.a.paypal_id = '*****@*****.**' self.a.save() d = addon_to_dict(self.a) eq_(d['contribution']['suggested_amount'], 5)
def test_contrib_info(self): self.a.wants_contributions = True self.a.suggested_amount = 5 self.a.paypal_id = "*****@*****.**" self.a.save() d = addon_to_dict(self.a) eq_(d["contribution"]["suggested_amount"], 5)
def test_sanitize(self): """Check that tags are stripped for summary and description.""" self.a.summary = self.a.description = 'i <3 <a href="">amo</a>!' self.a.save() d = addon_to_dict(self.a) eq_(d['summary'], 'i <3 amo!') eq_(d['description'], 'i <3 amo!')
def test_dict_disco(self): """Check for correct add-on detail URL for discovery pane.""" d = addon_to_dict(self.a, disco=True, src="discovery-personalrec") u = "%s%s?src=discovery-personalrec" % ( settings.SERVICES_URL, reverse("discovery.addons.detail", args=["a3615"]), ) eq_(d["learnmore"], u)
def test_no_contrib_info_until_approved(self): self.a.wants_contributions = True self.a.suggested_amount = 5 self.a.status = amo.STATUS_LITE self.a.paypal_id = '*****@*****.**' self.a.save() d = addon_to_dict(self.a) assert 'contribution' not in d
def collection_detail_json(request, username, slug): c = get_collection(request, username, slug) if not (c.listed or acl.check_collection_ownership(request, c)): raise PermissionDenied addons_dict = [addon_to_dict(a) for a in c.addons.valid()] return { 'name': c.name, 'url': c.get_abs_url(), 'iconUrl': c.icon_url, 'addons': addons_dict }
def collection_detail_json(request, username, slug): c = get_collection(request, username, slug) if not (c.listed or acl.check_collection_ownership(request, c)): raise PermissionDenied addons_dict = [addon_to_dict(a) for a in c.addons.valid()] return { 'name': c.name, 'url': c.get_abs_url(), 'iconUrl': c.icon_url, 'addons': addons_dict }
def collection_detail_json(request, username, slug): c = get_collection(request, username, slug) if not (c.listed or acl.check_collection_ownership(request, c)): return http.HttpResponseForbidden() addons = c.addons.valid() addons_dict = [addon_to_dict(a) for a in addons] d = {'name': c.name, 'url': c.get_abs_url(), 'iconUrl': c.icon_url, 'addons': addons_dict, } return d
def collection_detail_json(request, username, slug): c = get_collection(request, username, slug) if not (c.listed or acl.check_collection_ownership(request, c)): raise PermissionDenied # We evaluate the QuerySet with `list` to work around bug 866454. addons_dict = [addon_to_dict(a) for a in list(c.addons.valid())] return { 'name': c.name, 'url': c.get_abs_url(), 'iconUrl': c.icon_url, 'addons': addons_dict }
def collection_detail_json(request, username, slug): c = get_collection(request, username, slug) if not (c.listed or acl.check_collection_ownership(request, c)): return http.HttpResponseForbidden() addons = c.addons.valid() addons_dict = [addon_to_dict(a) for a in addons] d = { 'name': c.name, 'url': c.get_abs_url(), 'iconUrl': c.icon_url, 'addons': addons_dict, } return d
def render_json(self, context): return json.dumps([addon_to_dict(a) for a in context['addons']], cls=JSONEncoder)
def render_json(self, context): return json.dumps(addon_to_dict(context['addon']), cls=JSONEncoder)
def test_dict_disco(self): """Check for correct add-on detail URL for discovery pane.""" d = addon_to_dict(self.a, disco=True, src='discovery-personalrec') u = '%s%s?src=discovery-personalrec' % (settings.SERVICES_URL, reverse('discovery.addons.detail', args=['a3615'])) eq_(d['learnmore'], u)
def test_dict(self): """Verify that we're getting dict.""" d = addon_to_dict(self.a) assert d, 'Add-on dictionary not found' assert d['learnmore'].endswith('/addon/a3615/?src=api'), ( 'Add-on details URL does not end with "?src=api"')
def render_json(self, context): return json.dumps(addon_to_dict(context['addon']), cls=JSONEncoder)
def render_json(self, context): return json.dumps([addon_to_dict(a) for a in context['addons']], cls=JSONEncoder)
def test_dict(self): """Verify that we're getting dict.""" d = addon_to_dict(self.a) assert d, "Add-on dictionary not found" assert d["learnmore"].endswith("/addon/a3615/?src=api"), 'Add-on details URL does not end with "?src=api"'