{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/43981387","id":43981387,"diff_hunk":"@@ -463,25 +488,46 @@ OpenAssessment.ResponseView.prototype = {\n \n     /**\n      When selecting a file for upload, do some quick client-side validation\n-     to ensure that it is an image, and is not larger than the maximum file\n-     size.\n+     to ensure that it is an image, a PDF or other allowed types, and is not\n+     larger than the maximum file size.\n \n      Args:\n         files (list): A collection of files used for upload. This function assumes\n             there is only one file being uploaded at any time. This file must\n-            be less than 5 MB and an image.\n+            be less than 5 MB and an image, PDF or other allowed types.\n+        uploadType (string): uploaded file type allowed, could be none, image,\n+            file or custom.\n \n      **/\n-    prepareUpload: function(files) {\n+    prepareUpload: function(files, uploadType) {\n         this.files = null;\n-        this.imageType = files[0].type;\n+        this.fileType = files[0].type;\n+        var ext = files[0].name.split('.').pop().toLowerCase();\n+\n         if (files[0].size > this.MAX_FILE_SIZE) {\n             this.baseView.toggleActionError(\n-                'upload', gettext(\"File size must be 5MB or less.\")\n+                'upload',\n+                gettext(\"File size must be 5MB or less.\")\n             );\n-        } else if (this.imageType.substring(0,6) !== 'image/') {\n+        } else if (uploadType === \"image\" && this.data.ALLOWED_IMAGE_MIME_TYPES.indexOf(this.fileType) === -1) {\n             this.baseView.toggleActionError(\n-                'upload', gettext(\"File must be an image.\")\n+                'upload',\n+                gettext(\"You can upload files with these file types: \") + \"JPG, PNG or GIF\"","path":"openassessment/xblock/static/js/src/lms/oa_response.js","position":145,"original_position":145,"commit_id":"37c1176a8df806cf9cba0390052ba2b570472c91","original_commit_id":"3e881f0bc546befae69008d128539a70e4097625","user":{"login":"muzaffaryousaf","id":2994509,"avatar_url":"https://avatars.githubusercontent.com/u/2994509?v=3","gravatar_id":"","url":"https://api.github.com/users/muzaffaryousaf","html_url":"https://github.com/muzaffaryousaf","followers_url":"https://api.github.com/users/muzaffaryousaf/followers","following_url":"https://api.github.com/users/muzaffaryousaf/following{/other_user}","gists_url":"https://api.github.com/users/muzaffaryousaf/gists{/gist_id}","starred_url":"https://api.github.com/users/muzaffaryousaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muzaffaryousaf/subscriptions","organizations_url":"https://api.github.com/users/muzaffaryousaf/orgs","repos_url":"https://api.github.com/users/muzaffaryousaf/repos","events_url":"https://api.github.com/users/muzaffaryousaf/events{/privacy}","received_events_url":"https://api.github.com/users/muzaffaryousaf/received_events","type":"User","site_admin":false},"body":"Thanks @andy-armstrong for pointing this out.","created_at":"2015-11-05T06:57:30Z","updated_at":"2015-11-05T06:57:30Z","html_url":"https://github.com/edx/edx-ora2/pull/749#discussion_r43981387","pull_request_url":"https://api.github.com/repos/edx/edx-ora2/pulls/749","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/comments/43981387"},"html":{"href":"https://github.com/edx/edx-ora2/pull/749#discussion_r43981387"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/749"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-ora2/pulls/749","id":49546201,"html_url":"https://github.com/edx/edx-ora2/pull/749","diff_url":"https://github.com/edx/edx-ora2/pull/749.diff","patch_url":"https://github.com/edx/edx-ora2/pull/749.patch","issue_url":"https://api.github.com/repos/edx/edx-ora2/issues/749","number":749,"state":"closed","locked":false,"title":"Add support for file upload","user":{"login":"muzaffaryousaf","id":2994509,"avatar_url":"https://avatars.githubusercontent.com/u/2994509?v=3","gravatar_id":"","url":"https://api.github.com/users/muzaffaryousaf","html_url":"https://github.com/muzaffaryousaf","followers_url":"https://api.github.com/users/muzaffaryousaf/followers","following_url":"https://api.github.com/users/muzaffaryousaf/following{/other_user}","gists_url":"https://api.github.com/users/muzaffaryousaf/gists{/gist_id}","starred_url":"https://api.github.com/users/muzaffaryousaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muzaffaryousaf/subscriptions","organizations_url":"https://api.github.com/users/muzaffaryousaf/orgs","repos_url":"https://api.github.com/users/muzaffaryousaf/repos","events_url":"https://api.github.com/users/muzaffaryousaf/events{/privacy}","received_events_url":"https://api.github.com/users/muzaffaryousaf/received_events","type":"User","site_admin":false},"body":"- Allow image, pdf-image, or custom file types\r\n- Global black list extensions to prevent unsafe file types\r\n- Custom file upload is white listed only","created_at":"2015-11-03T11:49:38Z","updated_at":"2015-11-05T06:57:30Z","closed_at":"2015-11-04T11:43:36Z","merged_at":"2015-11-04T11:43:36Z","merge_commit_sha":"6a41091bcb0f355d56c537d243548c4d1638f8d2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-ora2/pulls/749/commits","review_comments_url":"https://api.github.com/repos/edx/edx-ora2/pulls/749/comments","review_comment_url":"https://api.github.com/repos/edx/edx-ora2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-ora2/issues/749/comments","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/37c1176a8df806cf9cba0390052ba2b570472c91","head":{"label":"edx:muzaffar/os-file-upload","ref":"muzaffar/os-file-upload","sha":"37c1176a8df806cf9cba0390052ba2b570472c91","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":15404425,"name":"edx-ora2","full_name":"edx/edx-ora2","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-ora2","description":"Open Response Assessment Suite","fork":false,"url":"https://api.github.com/repos/edx/edx-ora2","forks_url":"https://api.github.com/repos/edx/edx-ora2/forks","keys_url":"https://api.github.com/repos/edx/edx-ora2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ora2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ora2/teams","hooks_url":"https://api.github.com/repos/edx/edx-ora2/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ora2/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ora2/events","assignees_url":"https://api.github.com/repos/edx/edx-ora2/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ora2/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ora2/tags","blobs_url":"https://api.github.com/repos/edx/edx-ora2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ora2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ora2/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ora2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ora2/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ora2/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ora2/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ora2/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ora2/subscription","commits_url":"https://api.github.com/repos/edx/edx-ora2/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ora2/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ora2/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ora2/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-ora2/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ora2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ora2/merges","archive_url":"https://api.github.com/repos/edx/edx-ora2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ora2/downloads","issues_url":"https://api.github.com/repos/edx/edx-ora2/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ora2/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ora2/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ora2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ora2/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ora2/releases{/id}","created_at":"2013-12-23T20:54:54Z","updated_at":"2015-10-17T16:38:47Z","pushed_at":"2015-11-04T16:02:38Z","git_url":"git://github.com/edx/edx-ora2.git","ssh_url":"git@github.com:edx/edx-ora2.git","clone_url":"https://github.com/edx/edx-ora2.git","svn_url":"https://github.com/edx/edx-ora2","homepage":"","size":115533,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":68,"mirror_url":null,"open_issues_count":10,"forks":68,"open_issues":10,"watchers":28,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"c425531e1e8565c47c5964f234d55905055eee1a","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":15404425,"name":"edx-ora2","full_name":"edx/edx-ora2","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-ora2","description":"Open Response Assessment Suite","fork":false,"url":"https://api.github.com/repos/edx/edx-ora2","forks_url":"https://api.github.com/repos/edx/edx-ora2/forks","keys_url":"https://api.github.com/repos/edx/edx-ora2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-ora2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-ora2/teams","hooks_url":"https://api.github.com/repos/edx/edx-ora2/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-ora2/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-ora2/events","assignees_url":"https://api.github.com/repos/edx/edx-ora2/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-ora2/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-ora2/tags","blobs_url":"https://api.github.com/repos/edx/edx-ora2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-ora2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-ora2/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-ora2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-ora2/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-ora2/languages","stargazers_url":"https://api.github.com/repos/edx/edx-ora2/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-ora2/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-ora2/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-ora2/subscription","commits_url":"https://api.github.com/repos/edx/edx-ora2/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-ora2/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-ora2/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-ora2/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-ora2/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-ora2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-ora2/merges","archive_url":"https://api.github.com/repos/edx/edx-ora2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-ora2/downloads","issues_url":"https://api.github.com/repos/edx/edx-ora2/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-ora2/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-ora2/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-ora2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-ora2/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-ora2/releases{/id}","created_at":"2013-12-23T20:54:54Z","updated_at":"2015-10-17T16:38:47Z","pushed_at":"2015-11-04T16:02:38Z","git_url":"git://github.com/edx/edx-ora2.git","ssh_url":"git@github.com:edx/edx-ora2.git","clone_url":"https://github.com/edx/edx-ora2.git","svn_url":"https://github.com/edx/edx-ora2","homepage":"","size":115533,"stargazers_count":28,"watchers_count":28,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":68,"mirror_url":null,"open_issues_count":10,"forks":68,"open_issues":10,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/749"},"html":{"href":"https://github.com/edx/edx-ora2/pull/749"},"issue":{"href":"https://api.github.com/repos/edx/edx-ora2/issues/749"},"comments":{"href":"https://api.github.com/repos/edx/edx-ora2/issues/749/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/749/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-ora2/pulls/749/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-ora2/statuses/37c1176a8df806cf9cba0390052ba2b570472c91"}}}}