Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2591: Remove profile feature flag - [MEOWARD] #2738

Merged
merged 33 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
44c911e
removed method to add has_profile_feature_flag to context, and reference
asaki222 Sep 9, 2024
2e3f4bd
removed profile feature flag reference from process view method
asaki222 Sep 9, 2024
32e3d2f
removed the profile_feature_flag from send_status_update_emailmethod
asaki222 Sep 9, 2024
c2bdfaa
final changes
asaki222 Sep 9, 2024
8954efb
remvoed all reference to profile feature flag in code
asaki222 Sep 9, 2024
db46ca9
adding back some conditionals for feature flag
asaki222 Sep 10, 2024
f7c3579
removed submitter
asaki222 Sep 10, 2024
1203e54
ran formatting command
asaki222 Sep 10, 2024
acfaaa0
removed unused reference
asaki222 Sep 10, 2024
6d57f51
fixed linting issues
asaki222 Sep 10, 2024
b17ef34
reverted tests
asaki222 Sep 10, 2024
519c942
made changes to the tests
asaki222 Sep 10, 2024
e7936ce
Merge branch 'main' of https://github.com/cisagov/manage.get.gov into…
asaki222 Sep 11, 2024
91532ad
updated to main
asaki222 Sep 11, 2024
d386e69
closed a tag
asaki222 Sep 11, 2024
a55c019
put the end tag back in its correct spot
asaki222 Sep 13, 2024
ff27eab
merged to main
asaki222 Sep 13, 2024
d4475f0
finalized updates
asaki222 Sep 13, 2024
ffeed48
tentative changes to tests"
asaki222 Sep 16, 2024
2fd84a9
removed print statements
asaki222 Sep 16, 2024
013e566
removed the password
asaki222 Sep 16, 2024
2679f0a
fix for recent test fail
asaki222 Sep 17, 2024
171894d
cleaning up some code
asaki222 Sep 17, 2024
eabbc08
added back the user info
asaki222 Sep 17, 2024
e8d36b9
removed the remaining profile feature"
asaki222 Sep 17, 2024
441095f
fixing format
asaki222 Sep 17, 2024
270094e
added new line
asaki222 Sep 17, 2024
0d69558
removed unused reference
asaki222 Sep 18, 2024
294fbee
added more detail for test based on suggestion:
asaki222 Sep 18, 2024
f3159b5
refactored test
asaki222 Sep 18, 2024
6be34e0
reformatted test file
asaki222 Sep 18, 2024
7a81210
removed profile feature from docs
asaki222 Sep 18, 2024
d8d3605
removed profile feature from documentation
asaki222 Sep 18, 2024
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
4 changes: 2 additions & 2 deletions docs/developer/adding-feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ We use [django-waffle](https://waffle.readthedocs.io/en/stable/) for our feature
3. Click `Add waffle flag`.
4. Add the model as you would normally. Refer to waffle's documentation [regarding attributes](https://waffle.readthedocs.io/en/stable/types/flag.html#flag-attributes) for more information on them.

### Enabling the profile_feature flag
### Enabling a feature flag
1. On the app, navigate to `\admin`.
2. Under models, click `Waffle flags`.
3. Click the `profile_feature` record. This should exist by default, if not - create one with that name.
3. Click the featue flag record. This should exist by default, if not - create one with that name.
4. (Important) Set the field `Everyone` to `Unknown`. This field overrides all other settings when set to anything else.
5. Configure the settings as you see fit.

Expand Down
10 changes: 9 additions & 1 deletion src/api/tests/test_available.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,15 @@ class AvailableAPITest(MockEppLib):

def setUp(self):
super().setUp()
self.user = get_user_model().objects.create(username="username")
username = "test_user"
first_name = "First"
last_name = "Last"
email = "info@example.com"
title = "title"
phone = "8080102431"
self.user = get_user_model().objects.create(
username=username, title=title, first_name=first_name, last_name=last_name, email=email, phone=phone
)

def test_available_get(self):
self.client.force_login(self.user)
Expand Down
7 changes: 1 addition & 6 deletions src/registrar/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,11 +1977,7 @@ def _check_for_valid_email(self, request, obj):
so we should display that information using this function.

"""

if hasattr(obj, "creator"):
recipient = obj.creator
else:
recipient = None
recipient = obj.creator

# Displays a warning in admin when an email cannot be sent
if recipient and recipient.email:
Expand Down Expand Up @@ -2186,7 +2182,6 @@ def change_view(self, request, object_id, form_url="", extra_context=None):
extra_context["filtered_audit_log_entries"] = filtered_audit_log_entries
emails = self.get_all_action_needed_reason_emails(obj)
extra_context["action_needed_reason_emails"] = json.dumps(emails)
extra_context["has_profile_feature_flag"] = flag_is_active(request, "profile_feature")

# Denote if an action needed email was sent or not
email_sent = request.session.get("action_needed_email_sent", False)
Expand Down
1 change: 0 additions & 1 deletion src/registrar/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@
"registrar.context_processors.is_production",
"registrar.context_processors.org_user_status",
"registrar.context_processors.add_path_to_context",
"registrar.context_processors.add_has_profile_feature_flag_to_context",
"registrar.context_processors.portfolio_permissions",
],
},
Expand Down
5 changes: 0 additions & 5 deletions src/registrar/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf import settings
from waffle.decorators import flag_is_active


def language_code(request):
Expand Down Expand Up @@ -54,10 +53,6 @@ def add_path_to_context(request):
return {"path": getattr(request, "path", None)}


def add_has_profile_feature_flag_to_context(request):
return {"has_profile_feature_flag": flag_is_active(request, "profile_feature")}


def portfolio_permissions(request):
"""Make portfolio permissions for the request user available in global context"""
portfolio_context = {
Expand Down
2 changes: 1 addition & 1 deletion src/registrar/models/waffle_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class WaffleFlag(AbstractUserFlag):
Custom implementation of django-waffles 'Flag' object.
Read more here: https://waffle.readthedocs.io/en/stable/types/flag.html

Use this class when dealing with feature flags, such as profile_feature.
Use this class when dealing with feature flags.
"""

class Meta:
Expand Down
6 changes: 0 additions & 6 deletions src/registrar/registrar_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ def process_view(self, request, view_func, view_args, view_kwargs):
"""Runs pre-processing logic for each view. Checks for the
finished_setup flag on the current user. If they haven't done so,
then we redirect them to the finish setup page."""
# Check that the user is "opted-in" to the profile feature flag
has_profile_feature_flag = flag_is_active(request, "profile_feature")

# If they aren't, skip this check entirely
if not has_profile_feature_flag:
return None

if request.user.is_authenticated:
profile_page = self.profile_page
Expand Down
7 changes: 0 additions & 7 deletions src/registrar/templates/domain_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ <h3 class="margin-top-3"> DNS name servers </h3>
{% include "includes/summary_item.html" with title='Senior official' value=domain.domain_info.senior_official contact='true' edit_link=url editable=is_editable %}
{% endif %}


{# Conditionally display profile #}
{% if not has_profile_feature_flag %}
{% url 'domain-your-contact-information' pk=domain.id as url %}
{% include "includes/summary_item.html" with title='Your contact information' value=request.user contact='true' edit_link=url editable=is_editable %}
{% endif %}

{% url 'domain-security-email' pk=domain.id as url %}
{% if security_email is not None and security_email not in hidden_security_emails%}
{% include "includes/summary_item.html" with title='Security email' value=security_email edit_link=url editable=is_editable %}
Expand Down
2 changes: 0 additions & 2 deletions src/registrar/templates/domain_request_intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ <h1>You’re about to start your .gov domain request.</h1>
<h2>Time to complete the form</h2>
<p>If you have <a href="{% public_site_url 'domains/before/#information-you%E2%80%99ll-need-to-complete-the-domain-request-form' %}" target="_blank" class="usa-link">all the information you need</a>,
completing your domain request might take around 15 minutes.</p>
{% if has_profile_feature_flag %}
<h2>How we’ll reach you</h2>
<p>While reviewing your domain request, we may need to reach out with questions. We’ll also email you when we complete our review. If the contact information below is not correct, visit <a href="{% url 'user-profile' %}?redirect=domain-request:" class="usa-link">your profile</a> to make updates.</p>
{% include "includes/profile_information.html" with user=user%}
{% endif %}


{% block form_buttons %}
Expand Down
1 change: 0 additions & 1 deletion src/registrar/templates/domain_request_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ <h2 class="text-primary-darker"> Summary of your domain request </h2>
{% if DomainRequest.creator %}
{% include "includes/summary_item.html" with title='Your contact information' value=DomainRequest.creator contact='true' heading_level=heading_level %}
{% endif %}

{% if DomainRequest.other_contacts.all %}
{% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.other_contacts.all contact='true' list='true' heading_level=heading_level %}
{% else %}
Expand Down
2 changes: 0 additions & 2 deletions src/registrar/templates/includes/header_basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
{% if user.is_authenticated %}
<span class="usa-nav__username ellipsis">{{ user.email }}</span>
</li>
{% if has_profile_feature_flag %}
<li class="usa-nav__primary-item">
{% url 'user-profile' as user_profile_url %}
{% url 'finish-user-profile-setup' as finish_setup_url %}
<a class="usa-nav-link {% if request.path == user_profile_url or request.path == finish_setup_url %}usa-current{% endif %}" href="{{ user_profile_url }}">
<span class="text-primary">Your profile</span>
</a>
</li>
{% endif %}
<li class="usa-nav__primary-item">
<a href="{% url 'logout' %}"><span class="text-primary">Sign out</span></a>
{% else %}
Expand Down
2 changes: 0 additions & 2 deletions src/registrar/templates/includes/header_extended.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
{% if user.is_authenticated %}
<span class="ellipsis usa-nav__username">{{ user.email }}</span>
</li>
{% if has_profile_feature_flag %}
<li class="usa-nav__secondary-item">
{% url 'user-profile' as user_profile_url %}
{% url 'finish-user-profile-setup' as finish_setup_url %}
<a class="usa-nav-link {% if path == user_profile_url or path == finish_setup_url %}usa-current{% endif %}" href="{{ user_profile_url }}">
Your profile
</a>
</li>
{% endif %}
<li class="usa-nav__secondary-item">
<a class="usa-nav-link" href="{% url 'logout' %}">Sign out</a>
{% else %}
Expand Down
3 changes: 0 additions & 3 deletions src/registrar/templates/includes/non-production-alert.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<div class="usa-alert">
<div class="usa-alert__body {% if add_body_class %}{{ add_body_class }}{% endif %}">
<b>Attention:</b> You are on a test site.
{% if has_profile_feature_flag %}
The profile_feature flag is active.
{% endif %}
</div>
</div>
</div>
14 changes: 12 additions & 2 deletions src/registrar/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,10 @@ def sharedSetUp(cls):
first_name = "First"
last_name = "Last"
email = "info@example.com"
title = "title"
phone = "8080102431"
cls.user = get_user_model().objects.create(
username=username, first_name=first_name, last_name=last_name, email=email
username=username, first_name=first_name, last_name=last_name, email=email, title=title, phone=phone
)

current_date = get_time_aware_date(datetime(2024, 4, 2))
Expand Down Expand Up @@ -845,6 +847,7 @@ def create_superuser():
last_name="last",
is_staff=True,
password=p,
phone="8003111234",
)
# Retrieve the group or create it if it doesn't exist
group, _ = UserGroup.objects.get_or_create(name="full_access_group")
Expand All @@ -862,7 +865,9 @@ def create_user():
first_name="first",
last_name="last",
is_staff=True,
title="title",
password=p,
phone="8003111234",
)
# Retrieve the group or create it if it doesn't exist
group, _ = UserGroup.objects.get_or_create(name="cisa_analysts_group")
Expand All @@ -879,7 +884,12 @@ def create_test_user():
phone = "8003111234"
title = "test title"
user = get_user_model().objects.create(
username=username, first_name=first_name, last_name=last_name, email=email, phone=phone, title=title
username=username,
first_name=first_name,
last_name=last_name,
email=email,
phone=phone,
title=title,
)
return user

Expand Down
2 changes: 0 additions & 2 deletions src/registrar/tests/test_admin_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
GenericTestHelper,
)
from unittest.mock import patch
from waffle.testutils import override_flag

from django.conf import settings
import boto3_mocking # type: ignore
Expand Down Expand Up @@ -957,7 +956,6 @@ def test_save_model_sends_submitted_email_with_bcc_on_prod(self):
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)

@override_flag("profile_feature", True)
@less_console_noise_decorator
def test_save_model_sends_approved_email(self):
"""When transitioning to approved on a domain request,
Expand Down
12 changes: 1 addition & 11 deletions src/registrar/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,9 @@ def check_email_sent(

email_allowed.delete()

@override_flag("profile_feature", active=False)
@less_console_noise_decorator
def test_submit_from_started_sends_email(self):
msg = "Create a domain request and submit it and see if email was sent."
domain_request = completed_domain_request(user=self.dummy_user_2)
self.check_email_sent(
domain_request, msg, "submit", 1, expected_content="Lava", expected_email=self.dummy_user_2.email
)

@override_flag("profile_feature", active=True)
@less_console_noise_decorator
def test_submit_from_started_sends_email_to_creator(self):
"""Tests if, when the profile feature flag is on, we send an email to the creator"""
"""tests that we send an email to the creator"""
msg = "Create a domain request and submit it and see if email was sent when the feature flag is on."
domain_request = completed_domain_request(user=self.dummy_user_2)
self.check_email_sent(
Expand Down
Loading
Loading