Skip to content

Commit

Permalink
Updated Person Search API to only fetch records for requesting partner.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulmanann committed Oct 17, 2024
1 parent 8e117eb commit d9c5bba
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions course_discovery/apps/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,7 @@ class Meta:
'marketing_id',
'marketing_url',
'designation',
'partner'
)


Expand Down
3 changes: 1 addition & 2 deletions course_discovery/apps/api/v1/views/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,14 @@ class PersonSearchViewSet(BaseHaystackViewSet):
ordering_fields = ('created', 'full_name',)
permission_classes = (IsAuthenticated,)
index_models = (Person,)
filter_backends = (CatalogDataFilterBackend, HaystackOrderingFilter)
filter_backends = (filters.HaystackFilter, CatalogDataFilterBackend, HaystackOrderingFilter)
detail_serializer_class = serializers.PersonSearchModelSerializer
facet_serializer_class = serializers.PersonFacetSerializer
serializer_class = serializers.PersonSearchSerializer
ensure_published = False
document_uid = 'uuid'
lookup_field = 'uuid'


class PersonTypeaheadSearchView(APIView):
""" Typeahead for people. """
permission_classes = (IsAuthenticated,)
Expand Down
5 changes: 4 additions & 1 deletion course_discovery/apps/course_metadata/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class PersonIndex(BaseIndex, indexes.Indexable):
uuid = indexes.CharField(model_attr='uuid')
salutation = indexes.CharField(model_attr='salutation', null=True)
full_name = indexes.CharField(model_attr='full_name', stored=False, indexed=False)
partner = indexes.CharField(null=True)
partner = indexes.CharField(null=True, faceted=True)
bio = indexes.CharField(model_attr='bio', null=True)
bio_language = indexes.CharField(model_attr='bio_language', null=True)
get_profile_image_url = indexes.CharField(model_attr='get_profile_image_url', null=True)
Expand All @@ -421,6 +421,9 @@ def prepare_organizations(self, obj):
all_organizations = [course_run.course.authoring_organizations.all() for course_run in course_runs]
formatted_organizations = [org.key for orgs in all_organizations for org in orgs]
return formatted_organizations

def prepare_partner(self, obj):
return obj.partner.short_code

def prepare_position(self, obj):
try:
Expand Down

0 comments on commit d9c5bba

Please sign in to comment.