{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/31569873","id":31569873,"diff_hunk":"@@ -52,5 +57,139 @@ var edx = edx || {};\n              }\n            });\n         });\n+\n+        String.prototype.capitalizeFirstLetter = function() {\n+            return this.charAt(0).toUpperCase() + this.slice(1);\n+        };\n+        lookup_button.click(function () {\n+            registration_code_status_form_error.attr('style', 'display: none');\n+\n+            lookup_button.attr('disabled', true);\n+            var url = $(this).data('endpoint');\n+            var lookup_registration_code = $('#set_regcode_status_form input[name=\"regcode_code\"]').val();\n+            if (lookup_registration_code == '') {\n+                registration_code_status_form_error.attr('style', 'display: block !important');\n+                registration_code_status_form_error.text(gettext('Please enter the Enrollment Code.'));\n+                lookup_button.removeAttr('disabled');\n+                return false;\n+            }\n+            $.ajax({\n+                type: \"POST\",\n+                data: {\n+                    \"registration_code\"  : lookup_registration_code\n+                },\n+                url: url,\n+                success: function (data) {\n+                    lookup_button.removeAttr('disabled');\n+                    if (data.is_registration_code_exists == 'false') {\n+                        registration_code_status_form_error.attr('style', 'display: none');\n+                        registration_code_status_form_error.attr('style', 'display: block !important');\n+                        registration_code_status_form_error.text(gettext(data.message));\n+                    }\n+                    else {\n+                        var is_registration_code_valid = data.is_registration_code_valid.toString().capitalizeFirstLetter();\n+                        var is_registration_code_redeemed = data.is_registration_code_redeemed.toString().capitalizeFirstLetter();\n+                        var actions_links = '';\n+                        var actions = [];\n+                        if (is_registration_code_valid == 'True') {\n+                            actions.push(\n+                                {\n+                                    'action_url': data.registration_code_detail_url,\n+                                    'action_name': 'Mark as Invalid',\n+                                    'registration_code': lookup_registration_code,\n+                                    'action_type': 'invalidate_registration_code'\n+                                }\n+                            );\n+                        }\n+                        else {\n+                            actions.push(\n+                                {\n+                                    'action_url': data.registration_code_detail_url,\n+                                    'action_name': 'Mark as Valid',\n+                                    'registration_code': lookup_registration_code,\n+                                    'action_type': 'validate_registration_code'\n+                                }\n+                            );\n+                        }\n+                        if (is_registration_code_redeemed == 'True') {\n+                            actions.push(\n+                                {\n+                                    'action_url': data.registration_code_detail_url,\n+                                    'action_name': 'Mark as UnRedeem',\n+                                    'registration_code': lookup_registration_code,\n+                                    'action_type': 'unredeem_registration_code'\n+                                }\n+                            );\n+                        }\n+\n+                        for ( var i = 0; i < actions.length; i++ ) {\n+                            actions_links += '<a class=\"registration_code_action_link\" data-registration-code=\"'+\n+                            actions[i][\"registration_code\"] +'\" data-action-type=\"'+ actions[i][\"action_type\"] +'\"' +\n+                            ' href=\"#\" data-endpoint=\"' + actions[i][\"action_url\"] +'\">' +\n+                            actions[i][\"action_name\"] + '</a>';\n+                        }\n+                        var registration_code_lookup_actions = $('<table width=\"100%\" class=\"tb_registration_code_status\">' +\n+                            '<thead> <th width=\"15%\">' + gettext('Code') + '</th> <th width=\"20%\">'+ gettext('Redeemed') + '</th>'+\n+                            '<th width=\"14%\">' + gettext('Valid') + '</th> <th>' + gettext('Actions') + '</th></thead><tbody><tr>'+\n+                            '<td>' + lookup_registration_code + '</td>' +\n+                            '<td>' + is_registration_code_redeemed +'</td>' +\n+                            '<td>' + is_registration_code_valid + '</td><td>' +\n+                            actions_links +\n+                            '</td></tr> </tbody> </table>'\n+                        );\n+                        // before insertAfter do this.\n+                        // remove the first element after the registration_code_status_form\n+                        // so it doesn't duplicate the registration_code_lookup_actions in the UI.\n+                        registration_code_status_form.next().remove();\n+\n+                        registration_code_lookup_actions.insertAfter(registration_code_status_form);\n+                    }\n+                },\n+                error: function(jqXHR, textStatus, errorThrown) {\n+                    var data = $.parseJSON(jqXHR.responseText);\n+                    registration_code_status_form_error.attr('style', 'display: none');\n+                    lookup_button.removeAttr('disabled');\n+                    registration_code_status_form_error.attr('style', 'display: block !important');\n+                    registration_code_status_form_error.text(gettext(data.message));\n+                }\n+            });\n+        });\n+        $(\"section#invalidate_registration_code_modal\").on('click', 'a.registration_code_action_link', function(event) {\n+            event.preventDefault();\n+            registration_code_status_form_error.attr('style', 'display: none');\n+            lookup_button.attr('disabled', true);\n+            var url = $(this).data('endpoint');\n+            var action_type = $(this).data('action-type');\n+            var registration_code = $(this).data('registration-code');\n+            $.ajax({\n+                type: \"POST\",\n+                data: {\n+                    \"registration_code\": registration_code,\n+                    \"action_type\": action_type\n+                },\n+                url: url,\n+                success: function (data) {\n+                    $('#set_regcode_status_form input[name=\"regcode_code\"]').val('');\n+                    registration_code_status_form.next().remove();\n+                    registration_code_status_form_error.attr('style', 'display: none');\n+                    registration_code_status_form_success.attr('style', 'display: none');\n+                    lookup_button.removeAttr('disabled');\n+                    registration_code_status_form_success.attr('style', 'display: block !important');\n+                    registration_code_status_form_success.text(gettext(data.message));\n+                    registration_code_status_form_success.fadeOut(4000 , function(){\n+                        registration_code_status_form_success.attr('style', 'display: none');","path":"lms/static/js/instructor_dashboard/ecommerce.js","position":145,"original_position":145,"commit_id":"a0154d0e3079913732bf1451d04db120e4161cec","original_commit_id":"a0154d0e3079913732bf1451d04db120e4161cec","user":{"login":"clintonb","id":910510,"avatar_url":"https://avatars.githubusercontent.com/u/910510?v=3","gravatar_id":"","url":"https://api.github.com/users/clintonb","html_url":"https://github.com/clintonb","followers_url":"https://api.github.com/users/clintonb/followers","following_url":"https://api.github.com/users/clintonb/following{/other_user}","gists_url":"https://api.github.com/users/clintonb/gists{/gist_id}","starred_url":"https://api.github.com/users/clintonb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintonb/subscriptions","organizations_url":"https://api.github.com/users/clintonb/orgs","repos_url":"https://api.github.com/users/clintonb/repos","events_url":"https://api.github.com/users/clintonb/events{/privacy}","received_events_url":"https://api.github.com/users/clintonb/received_events","type":"User","site_admin":false},"body":"If you are fading out, why are you hiding via CSS and jQuery (below)?","created_at":"2015-06-02T20:53:33Z","updated_at":"2015-06-02T20:53:33Z","html_url":"https://github.com/edx/edx-platform/pull/8292#discussion_r31569873","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/8292","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/31569873"},"html":{"href":"https://github.com/edx/edx-platform/pull/8292#discussion_r31569873"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8292"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/8292","id":36609294,"html_url":"https://github.com/edx/edx-platform/pull/8292","diff_url":"https://github.com/edx/edx-platform/pull/8292.diff","patch_url":"https://github.com/edx/edx-platform/pull/8292.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/8292","number":8292,"state":"open","locked":false,"title":"SOL 916 invalidate revalidate registration codes","user":{"login":"muhhshoaib","id":7291787,"avatar_url":"https://avatars.githubusercontent.com/u/7291787?v=3","gravatar_id":"","url":"https://api.github.com/users/muhhshoaib","html_url":"https://github.com/muhhshoaib","followers_url":"https://api.github.com/users/muhhshoaib/followers","following_url":"https://api.github.com/users/muhhshoaib/following{/other_user}","gists_url":"https://api.github.com/users/muhhshoaib/gists{/gist_id}","starred_url":"https://api.github.com/users/muhhshoaib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muhhshoaib/subscriptions","organizations_url":"https://api.github.com/users/muhhshoaib/orgs","repos_url":"https://api.github.com/users/muhhshoaib/repos","events_url":"https://api.github.com/users/muhhshoaib/events{/privacy}","received_events_url":"https://api.github.com/users/muhhshoaib/received_events","type":"User","site_admin":false},"body":"SOL-916 As a course administrator, I would like to be able to query, invalidate, and re-validate registration codes.\r\n\r\nJIRA: https://openedx.atlassian.net/browse/SOL-916\r\n\r\nSANDBOX: regcode.m.sandbox.edx.org  (staff account has access to the eCommerce tab on the edX Demo Course)\r\n\r\nYou can view the UI in the E-Commerce Tab in Instructor Dashboard (Registration Codes section).\r\n![screen shot 2015-06-02 at 5 15 44 pm](https://cloud.githubusercontent.com/assets/7291787/7935505/ff43db6a-094a-11e5-8dce-1aea02ea50f8.png)","created_at":"2015-06-01T08:51:03Z","updated_at":"2015-06-02T20:53:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"18558f54b7f6aebb3ca8f1a018fc8a5c70389bc7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/8292/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/8292/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/8292/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/a0154d0e3079913732bf1451d04db120e4161cec","head":{"label":"edx:muhhshoaib/SOL-916-invalidate-revalidate-registration-codes","ref":"muhhshoaib/SOL-916-invalidate-revalidate-registration-codes","sha":"a0154d0e3079913732bf1451d04db120e4161cec","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":"Open edX, the edX platform that powers http://edx.org","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-06-02T16:03:12Z","pushed_at":"2015-06-02T20:51:44Z","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://openedx.org/","size":1968621,"stargazers_count":1955,"watchers_count":1955,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1124,"mirror_url":null,"open_issues_count":190,"forks":1124,"open_issues":190,"watchers":1955,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"de3cccdbe483d8b116065f6fc2b2f9a226929d79","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":"Open edX, the edX platform that powers http://edx.org","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-06-02T16:03:12Z","pushed_at":"2015-06-02T20:51:44Z","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://openedx.org/","size":1968621,"stargazers_count":1955,"watchers_count":1955,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1124,"mirror_url":null,"open_issues_count":190,"forks":1124,"open_issues":190,"watchers":1955,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8292"},"html":{"href":"https://github.com/edx/edx-platform/pull/8292"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8292"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8292/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8292/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/8292/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/a0154d0e3079913732bf1451d04db120e4161cec"}}}}