{"action":"created","comment":{"url":"https://api.github.com/repos/mitocw/edx-platform/pulls/comments/53841718","id":53841718,"diff_hunk":"@@ -108,3 +114,69 @@ def test_add_master_course_staff_to_ccx(self):\n             list_instructor_ccx_course = list_with_level(course_ccx, 'instructor')\n             self.assertEqual(len(list_instructor_ccx_course), len(list_instructor_master_course))\n             self.assertEqual(list_instructor_ccx_course[0].email, list_instructor_master_course[0].email)\n+\n+    def test_add_master_course_staff_to_ccx_display_name(self):\n+        \"\"\"\n+        Test add staff of master course to ccx course.\n+        Specific test to check that a passed display name is in the\n+        subject of the email sent to the enrolled users.\n+        \"\"\"\n+        outbox = self.get_outbox()\n+        # create a unique display name\n+        display_name = 'custom_display_{}'.format(uuid.uuid4())\n+        list_staff_master_course = list_with_level(self.course, 'staff')\n+        list_instructor_master_course = list_with_level(self.course, 'instructor')\n+        self.assertEqual(len(outbox), 0)\n+        # give access to the course staff/instructor\n+        add_master_course_staff_to_ccx(self.course, self.ccx_locator, display_name)\n+        self.assertEqual(len(outbox), len(list_staff_master_course) + len(list_instructor_master_course))\n+        for email in outbox:\n+            self.assertIn(display_name, email.subject)\n+\n+    def test_add_master_course_staff_to_ccx_idempotent(self):\n+        \"\"\"\n+        Test add staff of master course to ccx course multiple time will\n+        not result in multiple enrollments.\n+        \"\"\"\n+        outbox = self.get_outbox()\n+        list_staff_master_course = list_with_level(self.course, 'staff')\n+        list_instructor_master_course = list_with_level(self.course, 'instructor')\n+        self.assertEqual(len(outbox), 0)\n+\n+        # run the assignment the first time\n+        add_master_course_staff_to_ccx(self.course, self.ccx_locator, self.ccx.display_name)\n+        self.assertEqual(len(outbox), len(list_staff_master_course) + len(list_instructor_master_course))\n+        with ccx_course(self.ccx_locator) as course_ccx:\n+            list_staff_ccx_course = list_with_level(course_ccx, 'staff')\n+            list_instructor_ccx_course = list_with_level(course_ccx, 'instructor')\n+        self.assertEqual(len(list_staff_master_course), len(list_staff_ccx_course))","path":"lms/djangoapps/ccx/tests/test_utils.py","position":102,"original_position":102,"commit_id":"72ed9947b61330c516e070fae7c69be1042f0b5d","original_commit_id":"72ed9947b61330c516e070fae7c69be1042f0b5d","user":{"login":"giocalitri","id":1005204,"avatar_url":"https://avatars.githubusercontent.com/u/1005204?v=3","gravatar_id":"","url":"https://api.github.com/users/giocalitri","html_url":"https://github.com/giocalitri","followers_url":"https://api.github.com/users/giocalitri/followers","following_url":"https://api.github.com/users/giocalitri/following{/other_user}","gists_url":"https://api.github.com/users/giocalitri/gists{/gist_id}","starred_url":"https://api.github.com/users/giocalitri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giocalitri/subscriptions","organizations_url":"https://api.github.com/users/giocalitri/orgs","repos_url":"https://api.github.com/users/giocalitri/repos","events_url":"https://api.github.com/users/giocalitri/events{/privacy}","received_events_url":"https://api.github.com/users/giocalitri/received_events","type":"User","site_admin":false},"body":"I actually tried and for some reason it was failing","created_at":"2016-02-23T20:08:53Z","updated_at":"2016-02-23T20:08:53Z","html_url":"https://github.com/mitocw/edx-platform/pull/207#discussion_r53841718","pull_request_url":"https://api.github.com/repos/mitocw/edx-platform/pulls/207","_links":{"self":{"href":"https://api.github.com/repos/mitocw/edx-platform/pulls/comments/53841718"},"html":{"href":"https://github.com/mitocw/edx-platform/pull/207#discussion_r53841718"},"pull_request":{"href":"https://api.github.com/repos/mitocw/edx-platform/pulls/207"}}},"pull_request":{"url":"https://api.github.com/repos/mitocw/edx-platform/pulls/207","id":60220881,"html_url":"https://github.com/mitocw/edx-platform/pull/207","diff_url":"https://github.com/mitocw/edx-platform/pull/207.diff","patch_url":"https://github.com/mitocw/edx-platform/pull/207.patch","issue_url":"https://api.github.com/repos/mitocw/edx-platform/issues/207","number":207,"state":"open","locked":false,"title":"Staff and instructor users of the master course are added to CCX created via REST APIs","user":{"login":"giocalitri","id":1005204,"avatar_url":"https://avatars.githubusercontent.com/u/1005204?v=3","gravatar_id":"","url":"https://api.github.com/users/giocalitri","html_url":"https://github.com/giocalitri","followers_url":"https://api.github.com/users/giocalitri/followers","following_url":"https://api.github.com/users/giocalitri/following{/other_user}","gists_url":"https://api.github.com/users/giocalitri/gists{/gist_id}","starred_url":"https://api.github.com/users/giocalitri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giocalitri/subscriptions","organizations_url":"https://api.github.com/users/giocalitri/orgs","repos_url":"https://api.github.com/users/giocalitri/repos","events_url":"https://api.github.com/users/giocalitri/events{/privacy}","received_events_url":"https://api.github.com/users/giocalitri/received_events","type":"User","site_admin":false},"body":"#### What are the relevant tickets?\r\nfixes https://github.com/mitocw/edx-platform/issues/205\r\n\r\n#### What's this PR do?\r\nAdds the master course staff users to a new CCX created via the CCX REST APIs \r\n\r\n#### Where should the reviewer start?\r\nThe added functionality is in `lms.djangoapps.ccx.api.v0.views`, but there has been a significant change of code in `lms.djangoapps.ccx.utils`.\r\n\r\n#### How should this be manually tested?\r\nA staff user on a master course should be able to view and access a CCX created via REST API using the normal dashboard.\r\n\r\n#### Any background context you want to provide?\r\nThe added functionality of this PR is the equivalent of what https://github.com/edx/edx-platform/pull/10877 did with `lms.djangoapps.ccx.views`.\r\n\r\n#### What gif best describes this PR or how it makes you feel?\r\n![](http://i.giphy.com/vDLjgcJXzPm0M.gif)","created_at":"2016-02-22T18:49:30Z","updated_at":"2016-02-23T20:08:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"948b2b379934ada43d3aa16b114835ba97c69bd1","assignee":{"login":"noisecapella","id":863262,"avatar_url":"https://avatars.githubusercontent.com/u/863262?v=3","gravatar_id":"","url":"https://api.github.com/users/noisecapella","html_url":"https://github.com/noisecapella","followers_url":"https://api.github.com/users/noisecapella/followers","following_url":"https://api.github.com/users/noisecapella/following{/other_user}","gists_url":"https://api.github.com/users/noisecapella/gists{/gist_id}","starred_url":"https://api.github.com/users/noisecapella/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noisecapella/subscriptions","organizations_url":"https://api.github.com/users/noisecapella/orgs","repos_url":"https://api.github.com/users/noisecapella/repos","events_url":"https://api.github.com/users/noisecapella/events{/privacy}","received_events_url":"https://api.github.com/users/noisecapella/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mitocw/edx-platform/pulls/207/commits","review_comments_url":"https://api.github.com/repos/mitocw/edx-platform/pulls/207/comments","review_comment_url":"https://api.github.com/repos/mitocw/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mitocw/edx-platform/issues/207/comments","statuses_url":"https://api.github.com/repos/mitocw/edx-platform/statuses/72ed9947b61330c516e070fae7c69be1042f0b5d","head":{"label":"mitocw:gdm_staff_in_ccx_#205","ref":"gdm_staff_in_ccx_#205","sha":"72ed9947b61330c516e070fae7c69be1042f0b5d","user":{"login":"mitocw","id":3009146,"avatar_url":"https://avatars.githubusercontent.com/u/3009146?v=3","gravatar_id":"","url":"https://api.github.com/users/mitocw","html_url":"https://github.com/mitocw","followers_url":"https://api.github.com/users/mitocw/followers","following_url":"https://api.github.com/users/mitocw/following{/other_user}","gists_url":"https://api.github.com/users/mitocw/gists{/gist_id}","starred_url":"https://api.github.com/users/mitocw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitocw/subscriptions","organizations_url":"https://api.github.com/users/mitocw/orgs","repos_url":"https://api.github.com/users/mitocw/repos","events_url":"https://api.github.com/users/mitocw/events{/privacy}","received_events_url":"https://api.github.com/users/mitocw/received_events","type":"Organization","site_admin":false},"repo":{"id":17842334,"name":"edx-platform","full_name":"mitocw/edx-platform","owner":{"login":"mitocw","id":3009146,"avatar_url":"https://avatars.githubusercontent.com/u/3009146?v=3","gravatar_id":"","url":"https://api.github.com/users/mitocw","html_url":"https://github.com/mitocw","followers_url":"https://api.github.com/users/mitocw/followers","following_url":"https://api.github.com/users/mitocw/following{/other_user}","gists_url":"https://api.github.com/users/mitocw/gists{/gist_id}","starred_url":"https://api.github.com/users/mitocw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitocw/subscriptions","organizations_url":"https://api.github.com/users/mitocw/orgs","repos_url":"https://api.github.com/users/mitocw/repos","events_url":"https://api.github.com/users/mitocw/events{/privacy}","received_events_url":"https://api.github.com/users/mitocw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitocw/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/mitocw/edx-platform","forks_url":"https://api.github.com/repos/mitocw/edx-platform/forks","keys_url":"https://api.github.com/repos/mitocw/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitocw/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitocw/edx-platform/teams","hooks_url":"https://api.github.com/repos/mitocw/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/mitocw/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/mitocw/edx-platform/events","assignees_url":"https://api.github.com/repos/mitocw/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/mitocw/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/mitocw/edx-platform/tags","blobs_url":"https://api.github.com/repos/mitocw/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitocw/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitocw/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitocw/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitocw/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/mitocw/edx-platform/languages","stargazers_url":"https://api.github.com/repos/mitocw/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/mitocw/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/mitocw/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/mitocw/edx-platform/subscription","commits_url":"https://api.github.com/repos/mitocw/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitocw/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitocw/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitocw/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitocw/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/mitocw/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitocw/edx-platform/merges","archive_url":"https://api.github.com/repos/mitocw/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitocw/edx-platform/downloads","issues_url":"https://api.github.com/repos/mitocw/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/mitocw/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/mitocw/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/mitocw/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitocw/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/mitocw/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/mitocw/edx-platform/deployments","created_at":"2014-03-17T20:32:05Z","updated_at":"2016-01-11T19:42:28Z","pushed_at":"2016-02-23T19:59:32Z","git_url":"git://github.com/mitocw/edx-platform.git","ssh_url":"git@github.com:mitocw/edx-platform.git","clone_url":"https://github.com/mitocw/edx-platform.git","svn_url":"https://github.com/mitocw/edx-platform","homepage":"http://code.edx.org/","size":598629,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":86,"forks":1,"open_issues":86,"watchers":3,"default_branch":"master"}},"base":{"label":"mitocw:master","ref":"master","sha":"a1301ded69f1927d21df998f70739342a6ac0eb9","user":{"login":"mitocw","id":3009146,"avatar_url":"https://avatars.githubusercontent.com/u/3009146?v=3","gravatar_id":"","url":"https://api.github.com/users/mitocw","html_url":"https://github.com/mitocw","followers_url":"https://api.github.com/users/mitocw/followers","following_url":"https://api.github.com/users/mitocw/following{/other_user}","gists_url":"https://api.github.com/users/mitocw/gists{/gist_id}","starred_url":"https://api.github.com/users/mitocw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitocw/subscriptions","organizations_url":"https://api.github.com/users/mitocw/orgs","repos_url":"https://api.github.com/users/mitocw/repos","events_url":"https://api.github.com/users/mitocw/events{/privacy}","received_events_url":"https://api.github.com/users/mitocw/received_events","type":"Organization","site_admin":false},"repo":{"id":17842334,"name":"edx-platform","full_name":"mitocw/edx-platform","owner":{"login":"mitocw","id":3009146,"avatar_url":"https://avatars.githubusercontent.com/u/3009146?v=3","gravatar_id":"","url":"https://api.github.com/users/mitocw","html_url":"https://github.com/mitocw","followers_url":"https://api.github.com/users/mitocw/followers","following_url":"https://api.github.com/users/mitocw/following{/other_user}","gists_url":"https://api.github.com/users/mitocw/gists{/gist_id}","starred_url":"https://api.github.com/users/mitocw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mitocw/subscriptions","organizations_url":"https://api.github.com/users/mitocw/orgs","repos_url":"https://api.github.com/users/mitocw/repos","events_url":"https://api.github.com/users/mitocw/events{/privacy}","received_events_url":"https://api.github.com/users/mitocw/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mitocw/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/mitocw/edx-platform","forks_url":"https://api.github.com/repos/mitocw/edx-platform/forks","keys_url":"https://api.github.com/repos/mitocw/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mitocw/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mitocw/edx-platform/teams","hooks_url":"https://api.github.com/repos/mitocw/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/mitocw/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/mitocw/edx-platform/events","assignees_url":"https://api.github.com/repos/mitocw/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/mitocw/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/mitocw/edx-platform/tags","blobs_url":"https://api.github.com/repos/mitocw/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mitocw/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mitocw/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/mitocw/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mitocw/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/mitocw/edx-platform/languages","stargazers_url":"https://api.github.com/repos/mitocw/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/mitocw/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/mitocw/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/mitocw/edx-platform/subscription","commits_url":"https://api.github.com/repos/mitocw/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/mitocw/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/mitocw/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/mitocw/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/mitocw/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/mitocw/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mitocw/edx-platform/merges","archive_url":"https://api.github.com/repos/mitocw/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mitocw/edx-platform/downloads","issues_url":"https://api.github.com/repos/mitocw/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/mitocw/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/mitocw/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/mitocw/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mitocw/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/mitocw/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/mitocw/edx-platform/deployments","created_at":"2014-03-17T20:32:05Z","updated_at":"2016-01-11T19:42:28Z","pushed_at":"2016-02-23T19:59:32Z","git_url":"git://github.com/mitocw/edx-platform.git","ssh_url":"git@github.com:mitocw/edx-platform.git","clone_url":"https://github.com/mitocw/edx-platform.git","svn_url":"https://github.com/mitocw/edx-platform","homepage":"http://code.edx.org/","size":598629,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":86,"forks":1,"open_issues":86,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mitocw/edx-platform/pulls/207"},"html":{"href":"https://github.com/mitocw/edx-platform/pull/207"},"issue":{"href":"https://api.github.com/repos/mitocw/edx-platform/issues/207"},"comments":{"href":"https://api.github.com/repos/mitocw/edx-platform/issues/207/comments"},"review_comments":{"href":"https://api.github.com/repos/mitocw/edx-platform/pulls/207/comments"},"review_comment":{"href":"https://api.github.com/repos/mitocw/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mitocw/edx-platform/pulls/207/commits"},"statuses":{"href":"https://api.github.com/repos/mitocw/edx-platform/statuses/72ed9947b61330c516e070fae7c69be1042f0b5d"}}}}