{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/205762882","pull_request_review_id":141099568,"id":205762882,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNTc2Mjg4Mg==","diff_hunk":"@@ -0,0 +1,62 @@\n+import logging\n+import csv\n+\n+from django.core.exceptions import ObjectDoesNotExist\n+from django.core.management.base import BaseCommand, CommandError\n+from django.db.models import Q\n+from opaque_keys import InvalidKeyError\n+from opaque_keys.edx.keys import CourseKey\n+\n+from student.models import CourseEnrollment, User\n+\n+\n+logger = logging.getLogger(__name__)  # pylint: disable=invalid-name\n+\n+\n+class Command(BaseCommand):\n+\n+    help = \"\"\"\"\n+    Un-enroll bulk users from the courses.\n+    It expect that the data will be provided in a csv file format with\n+    first row being the header and columns will be as follows:\n+    user_id, username, email, course_id, is_verified, verification_date\n+    \"\"\"\n+\n+    def add_arguments(self, parser):\n+        parser.add_argument('-p', '--csv_path',\n+                            metavar='csv_path',\n+                            dest='csv_path',\n+                            required=True,\n+                            help='Path to CSV file.')\n+\n+    def handle(self, *args, **options):\n+        csv_path = options['csv_path']\n+        with open(csv_path, 'rb') as csvfile:\n+            reader = csv.DictReader(csvfile)\n+            for row in reader:\n+                username = row['username']","path":"common/djangoapps/student/management/commands/bulk_unenroll.py","position":null,"original_position":37,"commit_id":"9bd1bf506b4eea5494f1f8a3bed48f2107b0e8c1","original_commit_id":"275bc261b4d22ffbf0cfd25e25d816705ed81d0f","user":{"login":"robrap","id":14576445,"node_id":"MDQ6VXNlcjE0NTc2NDQ1","avatar_url":"https://avatars2.githubusercontent.com/u/14576445?v=4","gravatar_id":"","url":"https://api.github.com/users/robrap","html_url":"https://github.com/robrap","followers_url":"https://api.github.com/users/robrap/followers","following_url":"https://api.github.com/users/robrap/following{/other_user}","gists_url":"https://api.github.com/users/robrap/gists{/gist_id}","starred_url":"https://api.github.com/users/robrap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robrap/subscriptions","organizations_url":"https://api.github.com/users/robrap/orgs","repos_url":"https://api.github.com/users/robrap/repos","events_url":"https://api.github.com/users/robrap/events{/privacy}","received_events_url":"https://api.github.com/users/robrap/received_events","type":"User","site_admin":false},"body":"Are these csv files manually or automatically generated?\r\n\r\nIf automatic, maybe this is overkill.  If manual, could you at least run a manual test with a csv with two users on the same line (e.g. with no `\\n` in between), and report back what it does?  Does it error out?  Does it silently skip the second one?  You can have the second one be an error case to better know.  Or, you could just write a unit test.\r\n\r\nNote: I'm not going to be the user of this script, and I'm not exactly clear on why I was asked to review this PR, so I think it makes sense for someone else to decide on what is good enough and what is overkill.","created_at":"2018-07-27T12:54:25Z","updated_at":"2018-07-27T12:54:25Z","html_url":"https://github.com/edx/edx-platform/pull/18622#discussion_r205762882","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/18622","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/205762882"},"html":{"href":"https://github.com/edx/edx-platform/pull/18622#discussion_r205762882"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/18622"}},"in_reply_to_id":205479880},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/18622","id":203235809,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzMjM1ODA5","html_url":"https://github.com/edx/edx-platform/pull/18622","diff_url":"https://github.com/edx/edx-platform/pull/18622.diff","patch_url":"https://github.com/edx/edx-platform/pull/18622.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/18622","number":18622,"state":"open","locked":false,"title":"Added Management command for bulk unenrollment of users","user":{"login":"ahsan-ul-haq","id":7567613,"node_id":"MDQ6VXNlcjc1Njc2MTM=","avatar_url":"https://avatars0.githubusercontent.com/u/7567613?v=4","gravatar_id":"","url":"https://api.github.com/users/ahsan-ul-haq","html_url":"https://github.com/ahsan-ul-haq","followers_url":"https://api.github.com/users/ahsan-ul-haq/followers","following_url":"https://api.github.com/users/ahsan-ul-haq/following{/other_user}","gists_url":"https://api.github.com/users/ahsan-ul-haq/gists{/gist_id}","starred_url":"https://api.github.com/users/ahsan-ul-haq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahsan-ul-haq/subscriptions","organizations_url":"https://api.github.com/users/ahsan-ul-haq/orgs","repos_url":"https://api.github.com/users/ahsan-ul-haq/repos","events_url":"https://api.github.com/users/ahsan-ul-haq/events{/privacy}","received_events_url":"https://api.github.com/users/ahsan-ul-haq/received_events","type":"User","site_admin":false},"body":"LEARNER-5852\r\n@edx/learner-spartans please review.","created_at":"2018-07-23T14:22:25Z","updated_at":"2018-07-27T12:54:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a7219fcd0c544077c1e4b3f3a4b39110f8cce7c7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/18622/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/18622/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/18622/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/9bd1bf506b4eea5494f1f8a3bed48f2107b0e8c1","head":{"label":"edx:ahsan/LEARNER-5852-Student-un-enroll-refund-for-verified-learners","ref":"ahsan/LEARNER-5852-Student-un-enroll-refund-for-verified-learners","sha":"9bd1bf506b4eea5494f1f8a3bed48f2107b0e8c1","user":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"node_id":"MDEwOlJlcG9zaXRvcnkxMDM5MTA3Mw==","name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2018-07-27T09:57:39Z","pushed_at":"2018-07-27T12:43:00Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":954284,"stargazers_count":3785,"watchers_count":3785,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2133,"mirror_url":null,"archived":false,"open_issues_count":190,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":2133,"open_issues":190,"watchers":3785,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"8b9048bf8c1df1b91a41e74dcc00449f5a73793c","user":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"node_id":"MDEwOlJlcG9zaXRvcnkxMDM5MTA3Mw==","name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxNzk4NDE=","avatar_url":"https://avatars3.githubusercontent.com/u/3179841?v=4","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-platform/deployments","created_at":"2013-05-30T20:20:38Z","updated_at":"2018-07-27T09:57:39Z","pushed_at":"2018-07-27T12:43:00Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":954284,"stargazers_count":3785,"watchers_count":3785,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2133,"mirror_url":null,"archived":false,"open_issues_count":190,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":2133,"open_issues":190,"watchers":3785,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/18622"},"html":{"href":"https://github.com/edx/edx-platform/pull/18622"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/18622"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/18622/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/18622/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/18622/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/9bd1bf506b4eea5494f1f8a3bed48f2107b0e8c1"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"robrap"}}