-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into hamza/PROD-4297
- Loading branch information
Showing
22 changed files
with
296 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
# The following users are the owners of all course-discovery files | ||
* @edx/course-discovery-admins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
course_discovery/apps/course_metadata/migrations/0347_pathway_status.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Generated by Django 4.2.18 on 2025-02-17 15:50 | ||
|
||
from django.db import migrations, models | ||
|
||
from course_discovery.apps.course_metadata.choices import PathwayStatus | ||
|
||
|
||
def set_status_on_existing_pathways(apps, schema_editor): | ||
# For all existing pathways, we set the status to Published. | ||
# Any deviations from that should be handled manually. | ||
Pathway = apps.get_model('course_metadata', 'Pathway') | ||
Pathway.objects.update(status=PathwayStatus.Published) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('course_metadata', '0346_archivecoursesconfig'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='pathway', | ||
name='status', | ||
field=models.CharField(choices=[('unpublished', 'Unpublished'), ('published', 'Published'), ('retired', 'Retired')], default='unpublished', max_length=255), | ||
), | ||
migrations.RunPython(set_status_on_existing_pathways, migrations.RunPython.noop) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
from course_discovery.apps.core.tests.factories import USER_PASSWORD, PartnerFactory, UserFactory | ||
from course_discovery.apps.core.tests.helpers import make_image_file | ||
from course_discovery.apps.course_metadata.admin import DegreeAdmin, PositionAdmin, ProgramEligibilityFilter | ||
from course_discovery.apps.course_metadata.choices import ProgramStatus | ||
from course_discovery.apps.course_metadata.choices import PathwayStatus, ProgramStatus | ||
from course_discovery.apps.course_metadata.constants import PathwayType | ||
from course_discovery.apps.course_metadata.forms import PathwayAdminForm, ProgramAdminForm | ||
from course_discovery.apps.course_metadata.models import ( | ||
|
@@ -628,6 +628,7 @@ def test_program_with_same_partner(self): | |
'email': '[email protected]', | ||
'programs': [program1.id], | ||
'pathway_type': PathwayType.CREDIT.value, | ||
'status': PathwayStatus.Published | ||
} | ||
form = PathwayAdminForm(data=data) | ||
|
||
|
@@ -650,6 +651,7 @@ def test_program_with_different_partner(self): | |
'email': '[email protected]', | ||
'programs': [program1.id, program2.id], | ||
'pathway_type': PathwayType.INDUSTRY.value, | ||
'status': PathwayStatus.Unpublished | ||
} | ||
form = PathwayAdminForm(data=data) | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ | |
from django.core import mail | ||
from django.test import TestCase | ||
|
||
from course_discovery.apps.core.tests.factories import UserFactory | ||
from course_discovery.apps.course_metadata.tests.factories import CourseFactory | ||
from course_discovery.apps.publisher.tests.factories import UserAttributeFactory | ||
from course_discovery.apps.tagging.emails import send_email_for_course_vertical_assignment | ||
|
||
|
||
|
@@ -15,19 +17,21 @@ class VerticalAssignmentEmailTests(TestCase): | |
def setUp(self): | ||
self.group_name = settings.VERTICALS_MANAGEMENT_GROUPS[0] | ||
self.course = CourseFactory(title="Test Course", draft=False) | ||
self.recipients = ["[email protected]", "[email protected]"] | ||
self.user1 = UserFactory(email="[email protected]") | ||
self.user2 = UserFactory(email="[email protected]") | ||
self.recipients = [self.user1, self.user2] | ||
self.logger = logging.getLogger("course_discovery.apps.tagging.emails") | ||
|
||
def test_email_sent_to_recipients(self): | ||
""" | ||
Test that an email is sent to the specified recipients with the correct subject | ||
Test that an email is sent to the specified recipients with the correct subject. | ||
""" | ||
send_email_for_course_vertical_assignment(self.course, self.recipients) | ||
|
||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
email = mail.outbox[0] | ||
self.assertEqual(email.to, self.recipients) | ||
self.assertEqual(email.to, [self.user1.email, self.user2.email]) | ||
expected_subject = f"Action Required: Assign Vertical and Sub-vertical for Course '{self.course.title}'" | ||
self.assertEqual(email.subject, expected_subject) | ||
|
||
|
@@ -42,3 +46,20 @@ def test_email_send_failure_logs_exception(self, mock_send): | |
send_email_for_course_vertical_assignment(self.course, self.recipients) | ||
|
||
self.assertIn("Failed to send vertical assignment email", log_context.output[0]) | ||
|
||
def test_no_email_sent_when_user_notifications_disabled(self): | ||
""" | ||
Test that if a user has disabled email notifications via their UserAttributes, | ||
then no email is sent. | ||
""" | ||
|
||
disabled_user = UserFactory(email="[email protected]") | ||
UserAttributeFactory(user=disabled_user, enable_email_notification=False) | ||
|
||
send_email_for_course_vertical_assignment(self.course, [disabled_user]) | ||
|
||
with self.assertLogs(logger=self.logger, level="ERROR") as log_context: | ||
send_email_for_course_vertical_assignment(self.course, [disabled_user]) | ||
|
||
self.assertEqual(len(mail.outbox), 0) | ||
self.assertIn("No recipients found.", log_context.output[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
32. Retirement Mechanism for Pathways | ||
====================================== | ||
|
||
Status | ||
-------- | ||
Accepted (Feb 2025) | ||
|
||
Context | ||
--------- | ||
Currently, there is no way to mark a pathway as retired. This is often necessary due to changing requirements | ||
for credit recognition on the partner organization's end, or the discontinuation of programs offered by them. | ||
In such cases, these pathways should be hidden from the learner dashboard and any credit requests against them | ||
should not be accepted. | ||
|
||
Decision | ||
---------- | ||
A new field **status** will be added to the pathway model. This field will support three possible values: *unpublished*, | ||
*published* and *retired*. Existing pathways will be assigned the *published* status (through a data migration), while any new pathways will be set | ||
to *unpublished* by default. | ||
|
||
The **status** field will be exposed in the pathways endpoint, and the API will also support filtering by its value. | ||
|
||
Consequences | ||
-------------- | ||
Consuming systems, such as credentials and edx-plaform, will have to ensure that they take the status field in consideration | ||
while processing pathways. Specifically, credentials will need to ensure that it does not allow credit redemption requests | ||
against retired pathways, and edx-platform will need to exclude retired pathways from the programs section of the learner dashboard. | ||
|
||
Alternatives Considered | ||
------------------------- | ||
One alternative considered was to hide retired pathways by default in the API responses. However, this approach | ||
was soon determined to be problematic because it could cause issues on the Credentials side, which has its own | ||
Pathway model (regularly synced with Discovery) having protected constraints with some other models. Additionally, | ||
it is more transparent to place the responsibility of correct usage on the consuming systems, rather than automatically | ||
filtering retired objects on discovery's end. |
Oops, something went wrong.