GitHub PullRequestReviewCommentEvent at 2014-09-16 01:58:46
Repository: edx-platform
Actor: chrisndodge
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/17580016","id":17580016,"diff_hunk":"@@ -168,6 +173,90 @@ def use_code(request):\n     return use_coupon_code(coupon, request.user)\n \n \n+def get_reg_code_validity(registration_code, request, limiter):\n+    \"\"\"\n+    This function checks if the registration code is valid, and then checks if it was already redeemed.\n+    \"\"\"\n+    reg_code_already_redeemed = False\n+    course_registration = None\n+    try:\n+        course_registration = CourseRegistrationCode.objects.get(code=registration_code)\n+    except CourseRegistrationCode.DoesNotExist:\n+        reg_code_is_valid = False\n+    else:\n+        reg_code_is_valid = True\n+        try:\n+            RegistrationCodeRedemption.objects.get(registration_code__code=registration_code)\n+        except RegistrationCodeRedemption.DoesNotExist:\n+            reg_code_already_redeemed = False\n+        else:\n+            reg_code_already_redeemed = True\n+\n+    if not reg_code_is_valid:\n+        #tick the rate limiter counter\n+        AUDIT_LOG.info(\"Redemption of a non existing RegistrationCode {code}\".format(code=registration_code))\n+        limiter.tick_bad_request_counter(request)\n+        raise Http404()\n+\n+    return reg_code_is_valid, reg_code_already_redeemed, course_registration\n+\n+\n+@require_http_methods([\"GET\", \"POST\"])\n+@login_required\n+def register_code_redemption(request, registration_code):\n+    \"\"\"\n+    This view allows the student to redeem the registration code\n+    and enroll in the course.\n+    \"\"\"\n+\n+    # Add some rate limiting here by re-using the RateLimitMixin as a helper class\n+    site_name = microsite.get_value('SITE_NAME', 'localhost')\n+    limiter = BadRequestRateLimiter()\n+    if limiter.is_rate_limit_exceeded(request):\n+        AUDIT_LOG.warning(\"Rate limit exceeded in registration code redemption.\")\n+        return HttpResponseForbidden()\n+\n+    template_to_render = 'shoppingcart/registration_code_receipt.html'\n+    if request.method == \"GET\":\n+        reg_code_is_valid, reg_code_already_redeemed, course_registration = get_reg_code_validity(registration_code,\n+                                                                                                  request, limiter)\n+        course = get_course_by_id(getattr(course_registration, 'course_id'), depth=None)\n+        context = {\n+            'reg_code_already_redeemed': reg_code_already_redeemed,\n+            'reg_code_is_valid': reg_code_is_valid,\n+            'reg_code': registration_code,\n+            'site_name': site_name,\n+            'course': course,\n+            'registered_for_course': registered_for_course(course, request.user)\n+        }\n+        return render_to_response(template_to_render, context)\n+    elif request.method == \"POST\":\n+        reg_code_is_valid, reg_code_already_redeemed, course_registration = get_reg_code_validity(registration_code,\n+                                                                                                  request, limiter)\n+\n+        course = get_course_by_id(getattr(course_registration, 'course_id'), depth=None)","path":"lms/djangoapps/shoppingcart/views.py","position":91,"original_position":91,"commit_id":"156651ec19cec7bfe302c41c1a5c0cabd2d057ee","original_commit_id":"156651ec19cec7bfe302c41c1a5c0cabd2d057ee","user":{"login":"chrisndodge","id":2362917,"avatar_url":"https://avatars.githubusercontent.com/u/2362917?v=2","gravatar_id":"fe50c3cee767d6d7fcc25a7d4afab1c4","url":"https://api.github.com/users/chrisndodge","html_url":"https://github.com/chrisndodge","followers_url":"https://api.github.com/users/chrisndodge/followers","following_url":"https://api.github.com/users/chrisndodge/following{/other_user}","gists_url":"https://api.github.com/users/chrisndodge/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisndodge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisndodge/subscriptions","organizations_url":"https://api.github.com/users/chrisndodge/orgs","repos_url":"https://api.github.com/users/chrisndodge/repos","events_url":"https://api.github.com/users/chrisndodge/events{/privacy}","received_events_url":"https://api.github.com/users/chrisndodge/received_events","type":"User","site_admin":false},"body":"ditto please use depth=0","created_at":"2014-09-16T01:58:46Z","updated_at":"2014-09-16T01:58:46Z","html_url":"https://github.com/edx/edx-platform/pull/5050#discussion_r17580016","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/5050","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/17580016"},"html":{"href":"https://github.com/edx/edx-platform/pull/5050#discussion_r17580016"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/5050"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/5050","id":20674348,"html_url":"https://github.com/edx/edx-platform/pull/5050","diff_url":"https://github.com/edx/edx-platform/pull/5050.diff","patch_url":"https://github.com/edx/edx-platform/pull/5050.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/5050","number":5050,"state":"open","locked":false,"title":"Ex-74 Registration Code redemption","user":{"login":"muhhshoaib","id":7291787,"avatar_url":"https://avatars.githubusercontent.com/u/7291787?v=2","gravatar_id":"1204702d3684990c8246f9995f129ed0","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":"@chrisndodge we have added the functionality related to EX-74, Kindly review the changes and let us know if anything is missing \r\n\r\nThanks","created_at":"2014-09-03T12:53:24Z","updated_at":"2014-09-16T01:58:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a3bee2d691bf31574c43514a5221943eaf16093","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/5050/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/5050/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/5050/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/156651ec19cec7bfe302c41c1a5c0cabd2d057ee","head":{"label":"edx:muhhshoaib/Ex-74-registration-code-redemption","ref":"muhhshoaib/Ex-74-registration-code-redemption","sha":"156651ec19cec7bfe302c41c1a5c0cabd2d057ee","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=2","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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=2","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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":"2014-09-15T12:22:07Z","pushed_at":"2014-09-16T01:18:25Z","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":1613985,"stargazers_count":1419,"watchers_count":1419,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":806,"mirror_url":null,"open_issues_count":102,"forks":806,"open_issues":102,"watchers":1419,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"e18e18a85592aa61da980e4a75af946f18c1d806","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=2","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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=2","gravatar_id":"e1f6c6dc8772c47c0261cd5df2ed2814","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":"2014-09-15T12:22:07Z","pushed_at":"2014-09-16T01:18:25Z","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":1613985,"stargazers_count":1419,"watchers_count":1419,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":806,"mirror_url":null,"open_issues_count":102,"forks":806,"open_issues":102,"watchers":1419,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/5050"},"html":{"href":"https://github.com/edx/edx-platform/pull/5050"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/5050"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/5050/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/5050/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/5050/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/156651ec19cec7bfe302c41c1a5c0cabd2d057ee"}}}}