Exemplo n.º 1
0
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}
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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 &lt;3 amo!')
     eq_(d['description'], 'i &lt;3 amo!')
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
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
    }
Exemplo n.º 8
0
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
    }
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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
    }
Exemplo n.º 11
0
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
Exemplo n.º 12
0
 def render_json(self, context):
     return json.dumps([addon_to_dict(a) for a in context['addons']],
                       cls=JSONEncoder)
Exemplo n.º 13
0
 def render_json(self, context):
     return json.dumps(addon_to_dict(context['addon']), cls=JSONEncoder)
Exemplo n.º 14
0
 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)
Exemplo n.º 15
0
 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"')
Exemplo n.º 16
0
 def render_json(self, context):
     return json.dumps(addon_to_dict(context['addon']), cls=JSONEncoder)
Exemplo n.º 17
0
 def render_json(self, context):
     return json.dumps([addon_to_dict(a) for a in context['addons']],
                       cls=JSONEncoder)
Exemplo n.º 18
0
 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"'