Skip to content

Commit

Permalink
remove some legacy tech_preview related logic (#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
goneri committed Sep 11, 2024
1 parent 812bb98 commit f8c3633
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 105 deletions.
9 changes: 0 additions & 9 deletions ansible_ai_connect/main/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@

<body>
{% block banner %}
{% if use_tech_preview %}
<div class="pf-c-alert pf-m-warning ls_tech_preview_banner">
<div class="pf-c-alert__icon">
<i class="fas fa-fw fa-exclamation-triangle" aria-hidden="true"></i>
</div>
<p class="pf-c-alert__title ls_font_normal"><b>NOTE</b>: Due to overwhelming positive demand, we have extended the availability of the {{ project_name }} Technical Preview from December 31, 2023 to <b>March 11, 2024</b>.</p>
</div>
<br />
{% endif %}
{% endblock banner %}
{% if messages %}
<ul class="messages">
Expand Down
9 changes: 0 additions & 9 deletions ansible_ai_connect/main/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ <h1 class="pf-c-title pf-m-lg">Log in to {{ project_name }}</h1>
{% if deployment_mode == 'saas' and user.is_authenticated and user.rh_org_has_subscription and user.rh_user_is_org_admin %}
<a class="pf-l-level__item" href="/console"><span class="fas fa-solid fa-cog"></span> Admin Portal</a>
{% endif %}
{% if not user.is_authenticated %}
{% if use_tech_preview %}
{% if use_github_team %}
<a class="pf-l-level__item" href="{% url 'social:begin' 'github-team' %}{% if next %}?next={{ next|urlencode }}{% endif %}"><span class="fas fa-sign-in-alt"></span> Log in to Tech Preview</a>
{% else %}
<a class="pf-l-level__item" href="{% url 'social:begin' 'github' %}{% if next %}?next={{ next|urlencode }}{% endif %}"><span class="fas fa-sign-in-alt"></span> Log in to Tech Preview</a>
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
</div>
Expand Down
5 changes: 0 additions & 5 deletions ansible_ai_connect/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@
class LoginView(auth_views.LoginView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
try:
context["use_github_team"] = bool(settings.SOCIAL_AUTH_GITHUB_TEAM_KEY)
except AttributeError:
context["use_github_team"] = False
context["use_tech_preview"] = settings.ANSIBLE_AI_ENABLE_TECH_PREVIEW
context["deployment_mode"] = settings.DEPLOYMENT_MODE
context["project_name"] = settings.ANSIBLE_AI_PROJECT_NAME
context["aap_api_provider_name"] = settings.AAP_API_PROVIDER_NAME
Expand Down
16 changes: 3 additions & 13 deletions ansible_ai_connect/users/templates/users/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@
Contact your Red Hat account organization administrator for more information on how to assign a named seat.
</p>
</div>
{% elif use_tech_preview and user.rh_org_has_subscription and not user.rh_user_has_seat %}
<div class="pf-c-alert pf-m-info" aria-label="Information alert">
<div class="pf-c-alert__icon">
<i class="fas fa-fw fa-info-circle" aria-hidden="true"></i>
</div>
<p class="pf-c-alert__title">
You do not have a licensed seat for {{ project_name }}. You will be limited to features of the {{ project_name }} tech preview until you are assigned a named seat.
Contact your Red Hat account organization administrator for more information on how to assign a named seat.
</p>
</div>
{% endif %}

<section class="pf-c-page__main-section pf-m-light">
Expand All @@ -47,7 +37,7 @@
<div class="pf-c-empty-state__content">

{# https://issues.redhat.com/browse/AAP-18386 #}
{% if user.is_authenticated and not use_tech_preview and not user.rh_user_is_org_admin and not user.rh_org_has_subscription %}
{% if user.is_authenticated and not user.rh_user_is_org_admin and not user.rh_org_has_subscription %}
<span class="pf-c-icon pf-m-xl pf-m-inline">
<span class="pf-c-icon__content pf-m-danger">
<i class="fas fa-exclamation-circle" aria-hidden="true"></i>
Expand All @@ -62,7 +52,7 @@ <h1 class="pf-c-title pf-m-lg">
</div>

{# https://issues.redhat.com/browse/AAP-22398 #}
{% elif user.is_authenticated and not use_tech_preview and user.rh_user_is_org_admin and not user.rh_org_has_subscription %}
{% elif user.is_authenticated and user.rh_user_is_org_admin and not user.rh_org_has_subscription %}
<span class="pf-c-icon pf-m-xl pf-m-inline">
<span class="pf-c-icon__content pf-m-danger">
<i class="fas fa-exclamation-circle" aria-hidden="true"></i>
Expand All @@ -76,7 +66,7 @@ <h1 class="pf-c-title pf-m-lg">
<p>You do not have an Active subscription to Ansible Automation Platform which is required to use {{ project_name }}.
</div>

{% elif user.is_authenticated and not use_tech_preview and user.rh_org_has_subscription and not user.rh_user_has_seat %}
{% elif user.is_authenticated and user.rh_org_has_subscription and not user.rh_user_has_seat %}
<span class="pf-c-icon pf-m-xl pf-m-inline">
<span class="pf-c-icon__content pf-m-danger">
<i class="fas fa-exclamation-circle" aria-hidden="true"></i>
Expand Down
69 changes: 0 additions & 69 deletions ansible_ai_connect/users/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ def test_unauthorized(self):
self.assertNotContains(response, "Role:")
self.assertNotContains(response, "Admin Portal")

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=True)
def test_unauthorized_with_tech_preview(self):
response = self.client.get(reverse("login"))
self.assertContains(response, "Log in to Tech Preview")

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=False)
def test_unauthorized_without_tech_preview(self):
response = self.client.get(reverse("login"))
Expand Down Expand Up @@ -88,22 +83,6 @@ def test_rh_admin_with_seat_and_no_secret(self):
self.assertContains(response, "model settings have not been configured", count=1)
self.assertContains(response, "Admin Portal", count=1)

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=True)
@override_settings(ANSIBLE_AI_PROJECT_NAME="Project Name")
@patch.object(ansible_ai_connect.users.models.User, "rh_org_has_subscription", False)
@patch.object(ansible_ai_connect.users.models.User, "rh_user_has_seat", False)
def test_rh_admin_without_seat_and_with_no_secret_with_tech_preview(self):
response = self.client.get(reverse("home"))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "pf-c-alert__title", count=1)
self.assertNotContains(response, "Your organization doesn't have access to Project Name.")
self.assertNotContains(response, "You will be limited to features of the Project Name")
self.assertNotContains(
response, "The Project Name Technical Preview is no longer available"
)
self.assertContains(response, "Role: administrator")
self.assertContains(response, "Admin Portal")

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=False)
@override_settings(ANSIBLE_AI_PROJECT_NAME="Project Name")
@patch.object(ansible_ai_connect.users.models.User, "rh_org_has_subscription", False)
Expand Down Expand Up @@ -145,42 +124,6 @@ def tearDown(self):
self.user.delete()
super().tearDown()

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=True)
@override_settings(ANSIBLE_AI_PROJECT_NAME="Project Name")
@override_settings(WCA_SECRET_DUMMY_SECRETS="")
@patch.object(ansible_ai_connect.users.models.User, "rh_org_has_subscription", True)
@patch.object(ansible_ai_connect.users.models.User, "rh_user_has_seat", False)
def test_rh_user_without_seat_and_no_secret_with_tech_preview(self):
response = self.client.get(reverse("home"))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "Role:")
self.assertContains(response, "pf-c-alert__title", count=2)
self.assertContains(response, "You do not have a licensed seat for Project Name")
self.assertContains(response, "You will be limited to features of the Project Name")
self.assertNotContains(response, "fas fa-exclamation-circle")
self.assertNotContains(response, "Admin Portal")
self.assertNotContains(
response, "The Project Name Technical Preview is no longer available"
)

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=True)
@override_settings(ANSIBLE_AI_PROJECT_NAME="Project Name")
@override_settings(WCA_SECRET_DUMMY_SECRETS="valid")
@patch.object(ansible_ai_connect.users.models.User, "rh_org_has_subscription", True)
@patch.object(ansible_ai_connect.users.models.User, "rh_user_has_seat", False)
def test_rh_user_without_seat_with_secret_with_tech_preview(self):
response = self.client.get(reverse("home"))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "Role:")
self.assertContains(response, "pf-c-alert__title", count=2)
self.assertContains(response, "You do not have a licensed seat for Project Name")
self.assertContains(response, "You will be limited to features of the Project Name")
self.assertNotContains(response, "fas fa-exclamation-circle")
self.assertNotContains(response, "Admin Portal")
self.assertNotContains(
response, "The Project Name Technical Preview is no longer available"
)

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=False)
@override_settings(ANSIBLE_AI_PROJECT_NAME="Project Name")
@override_settings(WCA_SECRET_DUMMY_SECRETS="")
Expand Down Expand Up @@ -215,18 +158,6 @@ def test_rh_user_with_a_seat_and_with_secret(self):
self.assertContains(response, "Project Name</h1>")
self.assertNotContains(response, "Admin Portal")

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=True)
@override_settings(WCA_SECRET_DUMMY_SECRETS="1234567:valid")
@patch.object(ansible_ai_connect.users.models.User, "rh_org_has_subscription", True)
@patch.object(ansible_ai_connect.users.models.User, "rh_user_has_seat", False)
def test_rh_user_with_no_seat_and_with_secret(self):
response = self.client.get(reverse("home"))
self.assertEqual(response.status_code, 200)
self.assertNotContains(response, "Role: licensed user")
self.assertNotContains(response, "more information on how to get a licensed seat.")
self.assertContains(response, "pf-c-alert__title", count=2)
self.assertNotContains(response, "Admin Portal")

@override_settings(ANSIBLE_AI_ENABLE_TECH_PREVIEW=False)
@override_settings(ANSIBLE_AI_PROJECT_NAME="Project Name")
@patch.object(ansible_ai_connect.users.models.User, "rh_org_has_subscription", False)
Expand Down

0 comments on commit f8c3633

Please sign in to comment.