Commit c72e8479 by Clinton Blackburn

Added support for filtering programs by marketing slug

This will ultimately be used by the marketing site to retrieve program data without having to store a separate reference (e.g. UUID).

LEARNER-2053
parent 70053336
......@@ -162,7 +162,7 @@ class ProgramFilter(FilterSetMixin, filters.FilterSet):
class Meta:
model = Program
fields = ('hidden', 'marketable', 'status', 'type', 'types',)
fields = ('hidden', 'marketable', 'marketing_slug', 'status', 'type', 'types',)
class OrganizationFilter(filters.FilterSet):
......
......@@ -247,6 +247,22 @@ class ProgramViewSetTests(SerializationMixin, APITestCase):
url = self.list_path + '?hidden=0'
self.assert_list_results(url, [not_hidden], 10)
def test_filter_by_marketing_slug(self):
""" The endpoint should support filtering programs by marketing slug. """
SLUG = 'test-program'
# This program should not be included in the results below because it never matches the filter.
self.create_program()
url = '{root}?marketing_slug={slug}'.format(root=self.list_path, slug=SLUG)
self.assert_list_results(url, [], 5)
program = self.create_program()
program.marketing_slug = SLUG
program.save()
self.assert_list_results(url, [program], 14)
def test_list_exclude_utm(self):
""" Verify the endpoint returns marketing URLs without UTM parameters. """
url = self.list_path + '?exclude_utm=1'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment