show add-on dependencies (bug 678662)
This commit is contained in:
Родитель
32ad8480f5
Коммит
3a11fb1adc
|
@ -66,6 +66,12 @@ def upsell_note(context, addon, module_context='impala'):
|
|||
return new_context(**locals())
|
||||
|
||||
|
||||
@register.inclusion_tag('addons/impala/dependencies_note.html')
|
||||
@jinja2.contextfunction
|
||||
def dependencies_note(context, addon, module_context='impala'):
|
||||
return new_context(**locals())
|
||||
|
||||
|
||||
@register.inclusion_tag('addons/contribution.html')
|
||||
@jinja2.contextfunction
|
||||
def contribution(context, addon, text=None, src='', show_install=False,
|
||||
|
@ -217,7 +223,11 @@ def sidebar_listing(context, addon):
|
|||
@register.filter
|
||||
@jinja2.contextfilter
|
||||
@register.inclusion_tag('addons/impala/addon_hovercard.html')
|
||||
def addon_hovercard(context, addon, lazyload=False):
|
||||
def addon_hovercard(context, addon, lazyload=False, src=None, dl_src=None):
|
||||
if not src:
|
||||
src = context.get('src')
|
||||
if not dl_src:
|
||||
dl_src = context.get('dl_src', src)
|
||||
vital_summary = context.get('vital_summary') or 'rating'
|
||||
vital_more = context.get('vital_more') or 'adu'
|
||||
return new_context(**locals())
|
||||
|
@ -230,9 +240,9 @@ def addon_grid(context, addons, src=None, dl_src=None, pagesize=6, cols=2,
|
|||
vital_summary='rating', vital_more='adu'):
|
||||
if not src:
|
||||
src = context.get('src')
|
||||
# dl_src is an optional src paramater just for the download links
|
||||
# dl_src is an optional src parameter just for the download links
|
||||
if not dl_src:
|
||||
dl_src = src
|
||||
dl_src = context.get('dl_src', src)
|
||||
pages = chunked(addons, pagesize)
|
||||
columns = 'cols-%d' % cols
|
||||
return new_context(**locals())
|
||||
|
|
|
@ -964,6 +964,11 @@ class Addon(amo.models.OnChangeMixin, amo.models.ModelBase):
|
|||
def can_review(self, user):
|
||||
return not self.is_premium() or self.has_purchased(user)
|
||||
|
||||
@property
|
||||
def all_dependencies(self):
|
||||
"""Return all the add-ons this add-on depends on."""
|
||||
return list(self.dependencies.all()[:9])
|
||||
|
||||
|
||||
@receiver(dbsignals.post_save, sender=Addon,
|
||||
dispatch_uid='addons.update.name.table')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% from "addons/macros.html" import vital %}
|
||||
<div class="addon hovercard single">
|
||||
<div class="addon hovercard">
|
||||
<a href="{{ addon.get_url_path(impala=True)|urlparams(src=dl_src) }}">
|
||||
<div class="icon">
|
||||
{% if lazyload %}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
{% set deps = addon.all_dependencies %}
|
||||
{% if deps %}
|
||||
<div class="notice dependencies">
|
||||
<h3>{{ _('This add-on requires the following add-ons to work properly:') }}</h3>
|
||||
{% if module_context == 'discovery' %}
|
||||
<ul>
|
||||
{% for dep in deps %}
|
||||
<li>
|
||||
<a href="{{ services_url('discovery.addons.detail', dep.slug, src='discovery-dependencies') }}">
|
||||
<img src="{{ dep.icon }}">{{ dep.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
{{ deps|addon_grid(cols=3, src='dp-hc-dependencies', dl_src='dp-dl-dependencies') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
|
@ -85,6 +85,8 @@
|
|||
{{ impala_performance_note(amount=addon.ts_slowness) }}
|
||||
{% endif %}
|
||||
|
||||
{{ dependencies_note(addon) }}
|
||||
|
||||
{{ upsell_note(addon) }}
|
||||
|
||||
{% if addon.takes_contributions %}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
<div class="premium">
|
||||
{% with prm = upsell.premium %}
|
||||
{% if module_context == 'discovery' %}
|
||||
<a href="{{ services_url('discovery.addons.detail', prm.slug, src='discovery-details') }}">
|
||||
<a href="{{ services_url('discovery.addons.detail', prm.slug, src='discovery-upsell') }}">
|
||||
<img src="{{ prm.icon }}">{{ prm.name }}</a>
|
||||
{% else %}
|
||||
{{ prm|addon_hovercard }}
|
||||
{{ prm|addon_hovercard(src='dp-hc-upsell', dl_src='dp-dl-upsell') }}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
|
|
@ -1253,6 +1253,7 @@ class TestAddonDependencies(amo.tests.TestCase):
|
|||
dependent_addon=Addon.objects.get(id=dependent_id)).save()
|
||||
|
||||
eq_(sorted([a.id for a in a.dependencies.all()]), sorted(ids))
|
||||
eq_(list(a.dependencies.all()), a.all_dependencies)
|
||||
|
||||
|
||||
class TestListedAddonTwoVersions(amo.tests.TestCase):
|
||||
|
|
|
@ -9,6 +9,7 @@ import re
|
|||
from django import test
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
from django.core.cache import cache
|
||||
from django.utils.encoding import iri_to_uri
|
||||
|
||||
from mock import patch
|
||||
|
@ -24,7 +25,8 @@ from amo.tests.test_helpers import get_image_path
|
|||
from amo.urlresolvers import reverse
|
||||
from abuse.models import AbuseReport
|
||||
from addons import cron
|
||||
from addons.models import Addon, AddonUpsell, AddonUser, Charity, Category
|
||||
from addons.models import (Addon, AddonDependency, AddonUpsell, AddonUser,
|
||||
Charity, Category)
|
||||
from files.models import File
|
||||
from paypal.tests import other_error
|
||||
from stats.models import Contribution
|
||||
|
@ -703,6 +705,21 @@ class TestImpalaDetailPage(amo.tests.TestCase):
|
|||
doc = pq(self.client.get(self.url).content)
|
||||
eq_(doc('.performance-note').length, 1)
|
||||
|
||||
def test_dependencies(self):
|
||||
doc = pq(self.client.get(self.url).content)
|
||||
eq_(doc('.dependencies').length, 0)
|
||||
req = Addon.objects.get(id=592)
|
||||
AddonDependency.objects.create(addon=self.addon, dependent_addon=req)
|
||||
eq_(self.addon.all_dependencies, [req])
|
||||
cache.clear()
|
||||
d = pq(self.client.get(self.url).content)('.dependencies')
|
||||
eq_(d.length, 1)
|
||||
eq_(d.find('.hovercard h3').text(), unicode(req.name))
|
||||
eq_(d.find('.hovercard > a').attr('href')
|
||||
.endswith('?src=dp-dl-dependencies'), True)
|
||||
eq_(d.find('.hovercard .install-button a').attr('href')
|
||||
.endswith('?src=dp-hc-dependencies'), True)
|
||||
|
||||
def test_upsell(self):
|
||||
doc = pq(self.client.get(self.url).content)
|
||||
eq_(doc('.upsell').length, 0)
|
||||
|
@ -712,6 +729,10 @@ class TestImpalaDetailPage(amo.tests.TestCase):
|
|||
eq_(upsell.length, 1)
|
||||
eq_(upsell.find('.prose').text(), 'XXX')
|
||||
eq_(upsell.find('.hovercard h3').text(), unicode(premie.name))
|
||||
eq_(upsell.find('.hovercard > a').attr('href')
|
||||
.endswith('?src=dp-dl-upsell'), True)
|
||||
eq_(upsell.find('.hovercard .install-button a').attr('href')
|
||||
.endswith('?src=dp-hc-upsell'), True)
|
||||
|
||||
def test_no_restart(self):
|
||||
f = self.addon.current_version.all_files[0]
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
{{ impala_performance_note(amount=addon.ts_slowness) }}
|
||||
{% endif %}
|
||||
|
||||
{{ dependencies_note(addon, 'discovery') }}
|
||||
|
||||
{{ upsell_note(addon, 'discovery') }}
|
||||
|
||||
{% if addon.type != amo.ADDON_PERSONA %}
|
||||
|
|
|
@ -2,6 +2,7 @@ import json
|
|||
|
||||
from django import test
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
|
||||
import mock
|
||||
from nose import SkipTest
|
||||
|
@ -12,7 +13,7 @@ import amo
|
|||
import amo.tests
|
||||
import addons.signals
|
||||
from amo.urlresolvers import reverse
|
||||
from addons.models import Addon, AddonUpsell
|
||||
from addons.models import Addon, AddonDependency, AddonUpsell
|
||||
from applications.models import Application, AppVersion
|
||||
from bandwagon.models import Collection, MonthlyPick
|
||||
from bandwagon.tests.test_models import TestRecommendations as Recs
|
||||
|
@ -366,6 +367,19 @@ class TestDetails(amo.tests.TestCase):
|
|||
doc = pq(self.client.get(self.detail_url).content)
|
||||
eq_(doc('.performance-note').length, 1)
|
||||
|
||||
def test_dependencies(self):
|
||||
doc = pq(self.client.get(self.detail_url).content)
|
||||
eq_(doc('.dependencies').length, 0)
|
||||
req = Addon.objects.get(id=592)
|
||||
AddonDependency.objects.create(addon=self.addon, dependent_addon=req)
|
||||
eq_(self.addon.all_dependencies, [req])
|
||||
cache.clear()
|
||||
d = pq(self.client.get(self.detail_url).content)('.dependencies')
|
||||
eq_(d.length, 1)
|
||||
a = d.find('ul a')
|
||||
eq_(a.text(), unicode(req.name))
|
||||
eq_(a.attr('href').endswith('?src=discovery-dependencies'), True)
|
||||
|
||||
def test_upsell(self):
|
||||
doc = pq(self.client.get(self.detail_url).content)
|
||||
eq_(doc('.upsell').length, 0)
|
||||
|
@ -374,7 +388,9 @@ class TestDetails(amo.tests.TestCase):
|
|||
upsell = pq(self.client.get(self.detail_url).content)('.upsell')
|
||||
eq_(upsell.length, 1)
|
||||
eq_(upsell.find('.prose').text(), 'XXX')
|
||||
eq_(upsell.find('.premium a').text(), unicode(premie.name))
|
||||
a = upsell.find('.premium a')
|
||||
eq_(a.text(), unicode(premie.name))
|
||||
eq_(a.attr('href').endswith('?src=discovery-upsell'), True)
|
||||
|
||||
|
||||
class TestDownloadSources(amo.tests.TestCase):
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
.border-radius(5px);
|
||||
.box-shadow(0 -1px 0 #D7E1ED inset, 0 1px 0 rgba(0, 0, 0, 0.05));
|
||||
border: 1px solid #CCD6E3;
|
||||
padding: 14px 14px 14px 104px;
|
||||
padding: 14px;
|
||||
background: #E3EDFA;
|
||||
margin-bottom: 1em;
|
||||
h3 {
|
||||
|
@ -120,14 +120,17 @@
|
|||
background: url(../../img/impala/turtle.png) no-repeat 28px 16px #fff8dc;
|
||||
border-color: #e2dbbf;
|
||||
.box-shadow(0 -1px 0 #F7F0D5 inset, 0 1px 0 rgba(0, 0, 0, 0.05));
|
||||
padding-left: 104px;
|
||||
}
|
||||
&.upsell,
|
||||
&.dependencies {
|
||||
> h3 {
|
||||
margin: 0 0 .5em;
|
||||
}
|
||||
}
|
||||
&.upsell {
|
||||
min-height: 64px;
|
||||
padding: 14px !important;
|
||||
position: relative;
|
||||
h3 {
|
||||
margin: 0 0 .5em;
|
||||
}
|
||||
.premium {
|
||||
position: absolute;
|
||||
top: 14px;
|
||||
|
@ -137,12 +140,16 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
&.dependencies {
|
||||
background-color: #f8ffdc;
|
||||
border-color: #dbe2bf;
|
||||
}
|
||||
}
|
||||
|
||||
.html-rtl .notice {
|
||||
padding: 14px 104px 14px 14px;
|
||||
&.performance-note {
|
||||
background-position: 96% 16px;
|
||||
padding: 14px 104px 14px 14px;
|
||||
}
|
||||
&.upsell {
|
||||
.premium {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
@import 'lib';
|
||||
|
||||
.notice {
|
||||
#submit-persona .notice {
|
||||
.border-radius(5px);
|
||||
padding: 1em 1em 1em 104px;
|
||||
background: #ECF5FE;
|
||||
margin-bottom: 1em;
|
||||
h3 {
|
||||
|
|
|
@ -988,20 +988,19 @@ li#no-restart {
|
|||
border-radius: 5px;
|
||||
width: 50%;
|
||||
margin-bottom: 1.286em;
|
||||
padding: 14px 14px 14px 104px;
|
||||
padding: 14px;
|
||||
}
|
||||
.notice p {
|
||||
margin: 0;
|
||||
}
|
||||
.html-rtl .notice {
|
||||
padding: 14px 104px 14px 14px;
|
||||
}
|
||||
|
||||
.performance-note {
|
||||
background: url(../../img/impala/turtle.png) no-repeat 28px 16px #fff8dc;
|
||||
padding: 14px 14px 14px 104px;
|
||||
}
|
||||
.html-rtl .performance-note {
|
||||
background-position: 96% 16px;
|
||||
padding: 14px 104px 14px 14px;
|
||||
}
|
||||
.notice h3,
|
||||
.upsell .premium a {
|
||||
|
@ -1009,7 +1008,6 @@ li#no-restart {
|
|||
}
|
||||
|
||||
.upsell {
|
||||
padding: 14px !important;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ z.visitor = z.Storage('visitor');
|
|||
})();
|
||||
|
||||
function hoverTruncate(grid) {
|
||||
var $grid = $(grid || this);
|
||||
var $grid = $(grid);
|
||||
if ($grid.hasClass('hovercard')) {
|
||||
$grid = $grid.parent();
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ $(function() {
|
|||
$('.listing-grid').each(listing_grid);
|
||||
|
||||
// Truncate titles on single hovercards.
|
||||
$('.hovercard.single').each(function() {
|
||||
$('.hovercard').each(function() {
|
||||
hoverTruncate(this);
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
DELETE FROM download_sources WHERE type = 'prefix' AND name IN ('co-hc-', 'co-dp-');
|
||||
|
||||
INSERT INTO download_sources (name, type, created)
|
||||
VALUES ('co-hc-sidebar', 'full', NOW()),
|
||||
('co-dp-sidebar', 'full', NOW()),
|
||||
('dp-hc-dependencies', 'full', NOW()),
|
||||
('dp-dl-dependencies', 'full', NOW()),
|
||||
('dp-hc-upsell', 'full', NOW()),
|
||||
('dp-dl-upsell', 'full', NOW()),
|
||||
('discovery-dependencies', 'full', NOW()),
|
||||
('discovery-upsell', 'full', NOW());
|
Загрузка…
Ссылка в новой задаче