Permalink
Browse files

Put d2c buttons behind waffle flag.

  • Loading branch information...
1 parent bbd6879 commit 9269e54b68f6798ffc8feedf03c8f7c4fdbbbecf @robhudson robhudson committed Mar 29, 2012
View
7 apps/addons/templates/addons/button.html
@@ -12,8 +12,11 @@
{% if compat %}
data-min="{{ compat.min.version }}"
data-max="{{ compat.max.version }}"
- data-is-compatible="{{ version.is_compatible|json }}"
- data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
+ {% if waffle.switch('d2c-buttons') %}
+ data-waffle-d2c-buttons="true"
+ data-is-compatible="{{ version.is_compatible|json }}"
+ data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
+ {% endif %}
data-version="{{ version.version }}"
data-compatible-apps="{{ version.compatible_apps[request.APP] }}"
data-lastupdated-isotime="{{ version.created|isotime }}"
View
7 apps/addons/templates/addons/includes/button_data_attributes.html
@@ -16,8 +16,11 @@
{% if compat %}
data-min="{{ compat.min.version }}"
data-max="{{ compat.max.version }}"
- data-is-compatible="{{ version.is_compatible|json }}"
- data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
+ {% if waffle.switch('d2c-buttons') %}
+ data-waffle-d2c-buttons="true"
+ data-is-compatible="{{ version.is_compatible|json }}"
+ data-compat-overrides="{{ version.compat_override_app_versions()|json }}"
+ {% endif %}
{% endif %}
{% if addon.is_webapp() %}
data-manifest-url="{% if (addon.is_premium() and addon.has_purchased(amo_user)) or (not addon.is_premium()) -%}
View
1 apps/addons/tests/test_buttons.py
@@ -605,6 +605,7 @@ def test_addon_not_ready(self):
assert doc('.install-button').text('Not ready for purchase.')
def test_d2c_attrs(self):
+ waffle.models.Switch.objects.create(name='d2c-buttons', active=True)
compat = Mock()
compat.min.version = '4.0'
compat.max.version = '12.0'
View
33 media/js/zamboni/buttons.js
@@ -98,6 +98,7 @@ var installButton = function() {
accept_eula = $this.hasClass('accept'),
webapp = $this.hasattr('data-manifest-url'),
compatible = $this.attr('data-is-compatible') == 'true',
+ waffle_d2c_buttons = $this.hasattr('data-waffle-d2c-buttons'),
has_overrides = $this.hasattr('data-compat-overrides'),
// L10n: {0} is an app name like Firefox.
_s = accept_eula ? gettext('Accept and Install') : gettext('Add to {0}'),
@@ -123,21 +124,25 @@ var installButton = function() {
newerBrowser = VersionCompare.compareVersions(z.browserVersion, max) > 0;
}
- // Firefox 10+ is compatible by default.
- var compatible = compatible && z.browserVersion != 0 &&
+ if (waffle_d2c_buttons) {
+ // Firefox 10+ is compatible by default.
+ compatible = compatible && z.browserVersion != 0 &&
VersionCompare.compareVersions(z.browserVersion, '10.0') >= 0;
- // If it's still compatible, check the overrides.
- if (compatible && has_overrides) {
- var overrides = JSON.parse($this.attr('data-compat-overrides'));
- _.each(overrides, function(override) {
- var _min = override[0],
- _max = override[1];
- if (VersionCompare.compareVersions(z.browserVersion, _min) >= 0 ||
- VersionCompare.compareVersions(z.browserVersion, _max) <= 0) {
- compatible = false;
- return;
- }
- });
+ // If it's still compatible, check the overrides.
+ if (compatible && has_overrides) {
+ var overrides = JSON.parse($this.attr('data-compat-overrides'));
+ _.each(overrides, function(override) {
+ var _min = override[0],
+ _max = override[1];
+ if (VersionCompare.compareVersions(z.browserVersion, _min) >= 0 ||
+ VersionCompare.compareVersions(z.browserVersion, _max) <= 0) {
+ compatible = false;
+ return;
+ }
+ });
+ }
+ } else {
+ compatible = false; // We always assumed not compatible before.
}
if (!$body.hasClass('acr-pitch') && newerBrowser && z.hasNightly && !z.hasACR) {
View
2 migrations/352-waffle-d2c-buttons.sql
@@ -0,0 +1,2 @@
+INSERT INTO waffle_switch_amo (name, active, note)
+ VALUES ('d2c-buttons', 0, 'If active, this turns on default-to-compatible for the install buttons.');
View
3 templates/qunit/qunit.html
@@ -71,6 +71,7 @@ <h2 class="addon"><span class="version"></span></h2>
<div class="install"
data-min="4.0"
data-max="5.0"
+ data-waffle-d2c-buttons="true"
data-is-compatible="true"
data-compat-overrides="[]">
<p class="install-button">
@@ -85,6 +86,7 @@ <h2 class="addon"><span class="version"></span></h2>
<div class="install"
data-min="4.0"
data-max="5.0"
+ data-waffle-d2c-buttons="true"
data-is-compatible="true"
data-compat-overrides="{{ [['10.0a1', '99.*']]|json }}">
<p class="install-button">
@@ -99,6 +101,7 @@ <h2 class="addon"><span class="version"></span></h2>
<div class="install"
data-min="4.0"
data-max="5.0"
+ data-waffle-d2c-buttons="true"
data-is-compatible="false"
data-compat-overrides="[]">
<p class="install-button">

0 comments on commit 9269e54

Please sign in to comment.