Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<div class="moz24-newsletter">
{{ email_newsletter_form(
newsletters='mozilla-foundation, mozilla-and-you',
newsletters='mozilla-foundation' if switch('foundation-separate-newsletter') else 'mozilla-foundation, mozilla-and-you',
title=None
)}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion bedrock/mozorg/templates/mozorg/about/manifesto.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h3 class="principle-number">{{ principle_number_10 }}</h3>
<div class="newsletter-content">
{% if ftl_has_messages('multi-newsletter-form-title', 'multi-newsletter-form-desc', 'multi-newsletter-form-checkboxes-legend') %}
{{ email_newsletter_form(
newsletters='mozilla-foundation, mozilla-and-you',
newsletters='mozilla-foundation' if switch('foundation-separate-newsletter') else 'mozilla-foundation, mozilla-and-you',
button_class='button-dark'
)}}
{% elif LANG.startswith('en-') %}
Expand Down
2 changes: 1 addition & 1 deletion bedrock/mozorg/templates/mozorg/home/home-old.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ <h2 class="mzp-c-picto-heading">{{ ftl('home-need-help') }}</h2>
<div class="newsletter-content">
{% if ftl_has_messages('multi-newsletter-form-title', 'multi-newsletter-form-desc', 'multi-newsletter-form-checkboxes-legend') %}
{{ email_newsletter_form(
newsletters='mozilla-foundation, mozilla-and-you',
newsletters='mozilla-foundation' if switch('foundation-separate-newsletter') else 'mozilla-foundation, mozilla-and-you',
button_class='button-dark'
)}}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion bedrock/mozorg/templates/mozorg/mission.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h4><a href="{{ url('mozorg.about.governance.governance') }}">{{ ftl('mission-go
<div class="newsletter-content">
{% if ftl_has_messages('multi-newsletter-form-title', 'multi-newsletter-form-desc', 'multi-newsletter-form-checkboxes-legend') %}
{{ email_newsletter_form(
newsletters='mozilla-foundation, mozilla-and-you',
newsletters='mozilla-foundation' if switch('foundation-separate-newsletter') else 'mozilla-foundation, mozilla-and-you',
button_class='button-dark'
)}}
{% elif LANG.startswith('en-') %}
Expand Down
2 changes: 1 addition & 1 deletion bedrock/newsletter/templates/newsletter/family.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{{ email_newsletter_form(
title=newsletter_title|safe,
desc='Firefox is made in part by lots of real-life, tired yet strangely optimistic parents, and we’re backed by an awesome non-profit too.',
newsletters='mozilla-foundation, mozilla-and-you',
newsletters='mozilla-foundation' if switch('foundation-separate-newsletter') else 'mozilla-foundation, mozilla-and-you',
button_class='mzp-t-dark',
include_title=True,
include_country=False,
Expand Down
2 changes: 1 addition & 1 deletion bedrock/newsletter/templates/newsletter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="mzp-l-content mzp-t-content-sm">
{% if ftl_has_messages('multi-newsletter-form-title', 'multi-newsletter-form-desc', 'multi-newsletter-form-checkboxes-legend') %}
{{ email_newsletter_form(
newsletters='mozilla-foundation, mozilla-and-you',
newsletters='mozilla-foundation' if switch('foundation-separate-newsletter') else 'mozilla-foundation, mozilla-and-you',
button_class='button-dark'
) }}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion bedrock/newsletter/templates/newsletter/mozilla.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1 class="page-title">{{ self.page_title() }}</h1>
<h2 class="section-title">{{ self.page_desc() }}</h2>
{% if ftl_has_messages('multi-newsletter-form-title', 'multi-newsletter-form-desc', 'multi-newsletter-form-checkboxes-legend') %}
{{ email_newsletter_form(
newsletters='mozilla-foundation, mozilla-and-you',
newsletters='mozilla-foundation' if switch('foundation-separate-newsletter') else 'mozilla-foundation, mozilla-and-you',
include_title=False,
button_class='button-dark'
)}}
Expand Down
7 changes: 6 additions & 1 deletion bedrock/newsletter/templatetags/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django_jinja import library
from markupsafe import Markup

from bedrock.base.waffle import switch
from bedrock.newsletter.forms import NewsletterFooterForm
from lib.l10n_utils import get_locale

Expand Down Expand Up @@ -43,7 +44,11 @@ def email_newsletter_form(
):
request = ctx["request"]
context = ctx.get_all()
action = settings.BASKET_SUBSCRIBE_URL

if switch("foundation-separate-newsletter") and newsletters == "mozilla-foundation":
action = settings.FOUNDATION_SUBSCRIBE_URL
else:
action = settings.BASKET_SUBSCRIBE_URL

success = bool(ctx.get("success"))
if success and not use_thankyou:
Expand Down
27 changes: 15 additions & 12 deletions bedrock/newsletter/tests/test_footer_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

from unittest.mock import patch

from django.conf import settings
from django.test.utils import override_settings

from pyquery import PyQuery as pq
from waffle.testutils import override_switch

from bedrock.base.urlresolvers import reverse
from bedrock.mozorg.tests import TestCase
Expand Down Expand Up @@ -62,18 +64,19 @@ def test_language_selected(self):
assert doc('#id_lang option[selected="selected"]').val() == ""

@override_settings(DEV=True)
def test_newsletters_selected(self):
def test_newsletter_action(self):
"""
By default both newsletters should be checked.
Newsletter points to correct POST URL.
"""
with self.activate_locale("en-US"):
resp = self.client.get(reverse(self.view_name))
doc = pq(resp.content)
assert doc('#id_newsletters_0[checked="checked"]').length == 1
assert doc('#id_newsletters_1[checked="checked"]').length == 1

with self.activate_locale("en-US"):
resp = self.client.get(reverse("firefox.nothing-personal.index"))
doc = pq(resp.content)
assert doc('#id_newsletters_0[checked="checked"]').length == 0
assert doc('#id_newsletters_1[checked="checked"]').length == 0
with override_switch("FOUNDATION_SEPARATE_NEWSLETTER", active=True):
with self.activate_locale("en-US"):
resp = self.client.get(reverse(self.view_name))
doc = pq(resp.content)
assert doc("#newsletter-form").attr("action") == settings.FOUNDATION_SUBSCRIBE_URL

with override_switch("FOUNDATION_SEPARATE_NEWSLETTER", active=False):
with self.activate_locale("en-US"):
resp = self.client.get(reverse(self.view_name))
doc = pq(resp.content)
assert doc("#newsletter-form").attr("action") == settings.BASKET_SUBSCRIBE_URL
2 changes: 2 additions & 0 deletions bedrock/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"www.mozilla.org/submit/bedrock/",
BASKET_URL,
FXA_ENDPOINT,
FOUNDATION_URL,
}
_csp_font_src = {
csp.constants.SELF,
Expand All @@ -62,6 +63,7 @@
# progressively enhance forms by using Javascript.
BASKET_URL,
FXA_ENDPOINT,
FOUNDATION_URL,
}
# On hosts with wagtail admin enabled, we need to allow the admin to frame itself for previews.
_csp_frame_ancestors = {
Expand Down
4 changes: 4 additions & 0 deletions bedrock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,10 @@ def _is_bedrock_custom_app(app_name):
BASKET_TIMEOUT = config("BASKET_TIMEOUT", parser=int, default="10")
BASKET_SUBSCRIBE_URL = f"{BASKET_URL}/news/subscribe/"

# Foundation newsletters are handled through Campaign Monitor
FOUNDATION_URL = config("FOUNDATION_URL", default="https://kmq73rfvbh.execute-api.us-east-2.amazonaws.com" if DEV else "TBD")
FOUNDATION_SUBSCRIBE_URL = f"{FOUNDATION_URL}/api/newsletter/mozillaorg"

BOUNCER_URL = config("BOUNCER_URL", default="https://download.mozilla.org/")

# Use a message storage mechanism that doesn't need a database.
Expand Down
Loading
Loading