Skip to content

Commit

Permalink
Link Instructors with multiple courses (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy authored Mar 12, 2021
1 parent b3fcb83 commit 4e7ac04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions course_discovery/apps/course_metadata/data_loaders/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from course_discovery.apps.course_metadata.data_loaders import AbstractDataLoader
from course_discovery.apps.course_metadata.data_loaders.course_type import calculate_course_type
from course_discovery.apps.course_metadata.models import (
Course, CourseEntitlement, CourseRun, CourseRunType, CourseType, Organization, Program, ProgramType, Seat, SeatType,
Subject, Video, Person, PersonSocialNetwork
Course, CourseEntitlement, CourseRun, CourseRunType, CourseType, Organization, Person, PersonSocialNetwork, Program,
ProgramType, Seat, SeatType, Subject, Video
)
from course_discovery.apps.course_metadata.utils import push_to_ecommerce_for_course_run, subtract_deadline_delta

Expand Down Expand Up @@ -973,7 +973,6 @@ def _add_course_instructors(self, course_instructors, course_run):
url=instructor_social['url'],
)

course_run.staff.add(instructor)
else:
for key, value in course_instructor.items():
setattr(instructor, key, value)
Expand All @@ -986,6 +985,9 @@ def _add_course_instructors(self, course_instructors, course_run):

PersonSocialNetwork.objects.bulk_update(socials, ['url'])

if not course_run.staff.filter(uuid=instructor.uuid).exists():
course_run.staff.add(instructor)

def _process_response(self, response):
"""
Process the response from the WordPress.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from course_discovery.apps.course_metadata.data_loaders.tests import JPEG, JSON, mock_data
from course_discovery.apps.course_metadata.data_loaders.tests.mixins import DataLoaderTestMixin
from course_discovery.apps.course_metadata.models import (
Course, CourseEntitlement, CourseRun, CourseRunType, CourseType, Organization, Person, Program, ProgramType, Seat, SeatType
Course, CourseEntitlement, CourseRun, CourseRunType, CourseType, Organization, Person, Program, ProgramType, Seat,
SeatType
)
from course_discovery.apps.course_metadata.tests.factories import (
CourseEntitlementFactory, CourseFactory, CourseRunFactory, OrganizationFactory, SeatFactory, SeatTypeFactory
Expand Down

0 comments on commit 4e7ac04

Please sign in to comment.