Repository: mdn/kuma

Issue:
T - Implement 3 waffle flags to improve control of subscription rollout

**Audience**
Devs and a fraction of staff users who have seen the Subscription form at the bottom of the Edit Profile page. 

**Proposal**

Have 3 feature flags. Make a slight distinction between getting new subscribers and existing subscribers. 

1. One feature flag for the fundamentals. E.g. the subscription management page, the ability to cancel. Let's call this `subscription`.
2. One feature flag for the presence of the Subscription banner. Let's call/keep calling this `subscription_banner`. 
3. One feature flag for the subscription form. I.e. the `<SubscriptionForm/>` React component inclusion inside the `<Payments/>` component. Let's call this `subscription_form`.

That way, we can control the "flood gates" with waffle flags but not accidentally get snagged in a catch-22 for people who are already in. 

**Additional context**

I don't know which issue to link to that tells about what should happen to people who are subscribers and return to MDN. As it stands, their only hope is to sign back in and use the signed-in drop-down to go to the Edit Profile page. 
An easy remedy to all of this is to leverage the fact that we know if a user is a subscriber in `<Login/>` and use that to make a link to the Subscription landing page. Once that loads, it should a link to the Subscription management page on the Wiki. 


Discussion:
@tobinmori - sep out user stories (1) flag issue p1, next sprint. (2) refactor stripe to not break DRY
The question is; what should happen to the Subscription landing page if the `subscription_form` is not on for the user? Because this is what happens:
<img width="1589" alt="Screen Shot 2020-04-09 at 4 23 39 PM" src="https://user-images.githubusercontent.com/26739/78937438-8095f280-7a7e-11ea-9e9a-13fc14530687.png">


I.e. the `subscription_banner` was on but this is what I see when I go to the Subscription landing page. 

My immediate reaction is that we drop the "You will be MDN member number: ..." and drop the "Support MDN with a $5 monthly subscription ..."

What do you think @mindy ?
Another question is; What should we do on the subscription form at the bottom of the Edit Profile page? At the moment it's based on the `subscription` banner but that actually wraps two possible outcomes: A) you already had a subscription, B) show the form. 

My inclination is to go deeper into that and make it so that if you *don't* already have a subscription, you don't get the form at all if `subscription_form` is off. 
cc: @malqinneh @atopal 

Resolving patch:
diff --git a/kuma/core/migrations/0005_auto_20200409_1312.py b/kuma/core/migrations/0005_auto_20200409_1312.py
new file mode 100644
--- /dev/null
+++ b/kuma/core/migrations/0005_auto_20200409_1312.py
@@ -0,0 +1,20 @@
+# Generated by Django 2.2.11 on 2020-04-09 13:12
+
+from django.db import migrations
+
+
+def create_subscription_form_flag(apps, schema_editor):
+    Flag = apps.get_model("waffle", "Flag")
+    if not Flag.objects.filter(name="subscription_form").exists():
+        Flag.objects.create(
+            name="subscription_form", staff=True, note="Shows the subscription form"
+        )
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("core", "0004_create_subscription_banner_flag"),
+    ]
+
+    operations = [migrations.RunPython(create_subscription_form_flag)]


Test patch:
diff --git a/kuma/api/v1/tests/test_views.py b/kuma/api/v1/tests/test_views.py
--- a/kuma/api/v1/tests/test_views.py
+++ b/kuma/api/v1/tests/test_views.py
@@ -235,6 +235,9 @@ def test_whoami(
     is_beta_tester,
 ):
     """Test responses for logged-in users."""
+    # First delete all flags created from data migrations
+    Flag.objects.all().delete()
+
     # Create some fake waffle objects
     Flag.objects.create(name="section_edit", authenticated=True)
     Flag.objects.create(name="flag_all", everyone=True)
@@ -268,8 +271,6 @@ def test_whoami(
     }
     if is_staff:
         expect["is_staff"] = True
-        expect["waffle"]["flags"]["subscription"] = True
-        expect["waffle"]["flags"]["subscription_banner"] = True
     if is_superuser:
         expect["is_superuser"] = True
     if is_beta_tester:
diff --git a/kuma/javascript/src/payments/index.test.jsx b/kuma/javascript/src/payments/index.test.jsx
--- a/kuma/javascript/src/payments/index.test.jsx
+++ b/kuma/javascript/src/payments/index.test.jsx
@@ -48,7 +48,7 @@ describe('Payments Landing Page', () => {
         const mockData = {
             waffle: {
                 flags: {
-                    ['subscription_banner']: true,
+                    ['subscription_form']: true,
                 },
 
                 // this is to avoid having to do a deep merge in setup()
diff --git a/kuma/users/tests/test_stripe_subscription.py b/kuma/users/tests/test_stripe_subscription.py
--- a/kuma/users/tests/test_stripe_subscription.py
+++ b/kuma/users/tests/test_stripe_subscription.py
@@ -91,6 +91,7 @@ def test_create_stripe_subscription(mock1, mock2, test_user):
 
 
 @override_flag("subscription", True)
+@override_flag("subscription_form", True)
 def test_next_subscriber_number_shown_for_non_subscribers(test_user):
     client = Client()
     client.force_login(test_user)