{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/45975360","id":45975360,"diff_hunk":"@@ -2910,3 +2910,98 @@ def generate_certificate_exceptions(request, course_id, generate_for=None):\n     }\n \n     return JsonResponse(response_payload)\n+\n+\n+USER_INDEX = 0\n+NOTES_INDEX = 1\n+\n+\n+@csrf_exempt\n+@cache_control(no_cache=True, no_store=True, must_revalidate=True)\n+@require_global_staff\n+@require_POST\n+def generate_bulk_certificate_exceptions(request, course_id):  # pylint: disable=invalid-name\n+    \"\"\"\n+    Add Students to certificate white list from the uploaded csv file.\n+    \"\"\"\n+    course_key = CourseKey.from_string(course_id)\n+    students, warnings, errors, success = ([] for __ in range(4))\n+    if 'students_list' in request.FILES:\n+        try:\n+            upload_file = request.FILES.get('students_list')\n+            if upload_file.name.endswith('.csv'):\n+                students = [row for row in csv.reader(upload_file.read().splitlines())]\n+            else:\n+                errors.append({\n+                    'response': _('-- Make sure that the file you upload is in CSV format with no '\n+                                  'extraneous characters or rows.')\n+                })\n+\n+        except Exception:  # pylint: disable=broad-except\n+            errors.append({\n+                'response': _('-- Could not read uploaded file.')\n+            })\n+        finally:\n+            upload_file.close()\n+\n+        row_num = 0\n+        for student in students:\n+            row_num += 1\n+            # verify that we have exactly two column in every row either email or username and notes but allow for\n+            # blank lines\n+            if len(student) != 2:\n+                if len(student) > 0:\n+                    errors.append({\n+                        'response': _('-- Data in row# {num} must have exactly two columns, '\n+                                      'either an email or a username and notes.').format(num=row_num)\n+                    })\n+                    log.info(u'invalid data/format in csv row# %s', row_num)\n+                continue\n+            user = student[USER_INDEX]\n+            try:\n+                db_user = get_user_by_username_or_email(user)","path":"lms/djangoapps/instructor/views/api.py","position":62,"original_position":62,"commit_id":"5c3dbc61e76a121a0030faa0fe88989d9502a30a","original_commit_id":"5c3dbc61e76a121a0030faa0fe88989d9502a30a","user":{"login":"ziafazal","id":434995,"avatar_url":"https://avatars.githubusercontent.com/u/434995?v=3","gravatar_id":"","url":"https://api.github.com/users/ziafazal","html_url":"https://github.com/ziafazal","followers_url":"https://api.github.com/users/ziafazal/followers","following_url":"https://api.github.com/users/ziafazal/following{/other_user}","gists_url":"https://api.github.com/users/ziafazal/gists{/gist_id}","starred_url":"https://api.github.com/users/ziafazal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ziafazal/subscriptions","organizations_url":"https://api.github.com/users/ziafazal/orgs","repos_url":"https://api.github.com/users/ziafazal/repos","events_url":"https://api.github.com/users/ziafazal/events{/privacy}","received_events_url":"https://api.github.com/users/ziafazal/received_events","type":"User","site_admin":false},"body":"i think name of this variable should be `user` instead of `db_user`.","created_at":"2015-11-26T12:54:31Z","updated_at":"2015-11-26T12:54:31Z","html_url":"https://github.com/edx/edx-platform/pull/10750#discussion_r45975360","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/10750","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/45975360"},"html":{"href":"https://github.com/edx/edx-platform/pull/10750#discussion_r45975360"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10750"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/10750","id":51897190,"html_url":"https://github.com/edx/edx-platform/pull/10750","diff_url":"https://github.com/edx/edx-platform/pull/10750.diff","patch_url":"https://github.com/edx/edx-platform/pull/10750.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/10750","number":10750,"state":"open","locked":false,"title":"SOL-1417 Certs: Allow CSV upload for Cert Exceptions","user":{"login":"asadiqbal08","id":7334669,"avatar_url":"https://avatars.githubusercontent.com/u/7334669?v=3","gravatar_id":"","url":"https://api.github.com/users/asadiqbal08","html_url":"https://github.com/asadiqbal08","followers_url":"https://api.github.com/users/asadiqbal08/followers","following_url":"https://api.github.com/users/asadiqbal08/following{/other_user}","gists_url":"https://api.github.com/users/asadiqbal08/gists{/gist_id}","starred_url":"https://api.github.com/users/asadiqbal08/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asadiqbal08/subscriptions","organizations_url":"https://api.github.com/users/asadiqbal08/orgs","repos_url":"https://api.github.com/users/asadiqbal08/repos","events_url":"https://api.github.com/users/asadiqbal08/events{/privacy}","received_events_url":"https://api.github.com/users/asadiqbal08/received_events","type":"User","site_admin":false},"body":"[SOL-1417](https://openedx.atlassian.net/browse/SOL-1417)\r\nIn Certificates Exceptions, add a new feature that allows PMs to upload a CSV file of usernames or email addresses to be added to the certificates exception white list.\r\n\r\nUI with possible messages to support SOL-1417. \r\n\r\n<img width=\"1198\" alt=\"screen shot 2015-11-26 at 3 21 35 pm\" src=\"https://cloud.githubusercontent.com/assets/7334669/11421294/ae8cf378-9455-11e5-95c3-112cb24b4895.png\">\r\n<img width=\"1145\" alt=\"screen shot 2015-11-26 at 3 21 06 pm\" src=\"https://cloud.githubusercontent.com/assets/7334669/11421293/ae8beb86-9455-11e5-9f87-5eb41814d182.png\">\r\n<img width=\"1212\" alt=\"screen shot 2015-11-26 at 3 20 52 pm\" src=\"https://cloud.githubusercontent.com/assets/7334669/11421295/ae8fcd1e-9455-11e5-9356-4b0f390f9bcd.png\">\r\n\r\n\r\n\r\n\r\n\r\n##### We need to update the UI in [SOL-1418](https://openedx.atlassian.net/browse/SOL-1418) so expected JS will be updated in this ticket. So we can create a sub-task under SOL-1418 to support Jasmine tests.\r\n\r\n@ziafazal please review it.\r\n@mattdrayer FYI","created_at":"2015-11-26T10:46:10Z","updated_at":"2015-11-26T12:54:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d125c541a547addac50085b3b80016481aa3dad9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/10750/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/10750/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/10750/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/5c3dbc61e76a121a0030faa0fe88989d9502a30a","head":{"label":"edx:asadiqbal08/SOL-1417-CSV","ref":"asadiqbal08/SOL-1417-CSV","sha":"5c3dbc61e76a121a0030faa0fe88989d9502a30a","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","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,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","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}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-11-25T18:57:02Z","pushed_at":"2015-11-26T12:42:11Z","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":626124,"stargazers_count":2258,"watchers_count":2258,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1386,"mirror_url":null,"open_issues_count":158,"forks":1386,"open_issues":158,"watchers":2258,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"46150800c0fd777d69ba61b6cf6983aeb084c80c","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","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,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","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}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-11-25T18:57:02Z","pushed_at":"2015-11-26T12:42:11Z","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":626124,"stargazers_count":2258,"watchers_count":2258,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1386,"mirror_url":null,"open_issues_count":158,"forks":1386,"open_issues":158,"watchers":2258,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10750"},"html":{"href":"https://github.com/edx/edx-platform/pull/10750"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10750"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/10750/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/10750/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/10750/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/5c3dbc61e76a121a0030faa0fe88989d9502a30a"}}}}