{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/31572257","id":31572257,"diff_hunk":"@@ -430,11 +427,20 @@ def _is_enrollment_code_an_update(course, user, redemption_code):\n def use_registration_code(course_reg, user):\n     \"\"\"\n     This method utilize course registration code.\n+    If the registration code is invalid, it returns an error.\n     If the registration code is already redeemed, it returns an error.\n     Else, it identifies and removes the applicable OrderItem from the Order\n     and redirects the user to the Registration code redemption page.\n     \"\"\"\n-    if RegistrationCodeRedemption.is_registration_code_redeemed(course_reg):\n+    if not course_reg.is_valid:\n+        log.warning(u\"The registration code '%s' is no longer valid.\", course_reg.code)\n+        return HttpResponseBadRequest(\n+            _(\"The registration code '{registration_code}' is not longer valid.\").format(\n+                registration_code=course_reg.code\n+            )\n+        )\n+\n+    if RegistrationCodeRedemption.is_registration_code_redeemed(course_reg.code):\n         log.warning(u\"Registration code '%s' already used\", course_reg.code)","path":"lms/djangoapps/shoppingcart/views.py","position":42,"original_position":42,"commit_id":"a0154d0e3079913732bf1451d04db120e4161cec","original_commit_id":"a0154d0e3079913732bf1451d04db120e4161cec","user":{"login":"srpearce","id":3493253,"avatar_url":"https://avatars.githubusercontent.com/u/3493253?v=3","gravatar_id":"","url":"https://api.github.com/users/srpearce","html_url":"https://github.com/srpearce","followers_url":"https://api.github.com/users/srpearce/followers","following_url":"https://api.github.com/users/srpearce/following{/other_user}","gists_url":"https://api.github.com/users/srpearce/gists{/gist_id}","starred_url":"https://api.github.com/users/srpearce/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srpearce/subscriptions","organizations_url":"https://api.github.com/users/srpearce/orgs","repos_url":"https://api.github.com/users/srpearce/repos","events_url":"https://api.github.com/users/srpearce/events{/privacy}","received_events_url":"https://api.github.com/users/srpearce/received_events","type":"User","site_admin":false},"body":"This enrollment code ({%s}) has already been used.\r\n\r\n(Change the single quotation marks to parentheses.)","created_at":"2015-06-02T21:17:33Z","updated_at":"2015-06-02T21:17:33Z","html_url":"https://github.com/edx/edx-platform/pull/8292#discussion_r31572257","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/31572257"},"html":{"href":"https://github.com/edx/edx-platform/pull/8292#discussion_r31572257"},"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-02T21:17:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"758daa4132b8fea40e3840472e291e200c74a8ba","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-02T21:16:43Z","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-02T21:16:43Z","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"}}}}