{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/33575509","id":33575509,"diff_hunk":"@@ -0,0 +1,85 @@\n+\"\"\"\n+This file contains all the classes used by has_access for error handling\n+\"\"\"\n+\n+\n+class AccessResponse(object):\n+    \"\"\"Class that represents a response from a has_access permission check.\"\"\"\n+    def __init__(self, has_access, error_code=None, developer_message=None, user_message=None):\n+        \"\"\"\n+        :param has_access (bool): if the user is granted access or not\n+        :param error_code (String): optional - default is None. unique identifier for the specific type of error\n+        :param developer_message (String): optional - default is None. message to show the developer\n+        :param user_message (String): optional - default is None. message to show the user\n+        \"\"\"\n+        self.has_access = has_access\n+        self.error_code = error_code\n+        self.developer_message = developer_message\n+        self.user_message = user_message\n+        if has_access:\n+            assert error_code is None\n+\n+    def __nonzero__(self):\n+        \"\"\"Overrides bool() to correct truth value testing\"\"\"\n+        return self.has_access\n+\n+    def to_json(self):\n+        \"\"\"Returns json representation of this AccessResponse\"\"\"\n+        return {\n+            \"has_access\": self.has_access,\n+            \"error_code\": self.error_code,\n+            \"developer_message\": self.developer_message,\n+            \"user_message\": self.user_message\n+        }\n+\n+\n+class AccessError(AccessResponse):\n+    \"\"\"\n+    Class that holds information about the error in the case of an access denial in has_access.\n+    Contains the error code, user and developer messages. Subclasses represent specific errors.\n+    \"\"\"\n+    def __init__(self, error_code, developer_message, user_message):\n+        \"\"\"\n+        :param: error_code (String): unique identifier for the specific type of error\n+        :param: developer_message (String): message to show the developer\n+        :param: user_message (String): message to show the user\n+\n+        \"\"\"\n+        super(AccessError, self).__init__(False, error_code, developer_message, user_message)\n+\n+\n+class StartDateError(AccessError):\n+    \"\"\"Access denied because the course has not started yet and the user is not staff\"\"\"\n+    def __init__(self, start_message):","path":"lms/djangoapps/courseware/access_response.py","position":53,"original_position":53,"commit_id":"d959992b7427aab6cd1260716b346e5b1f97f1a5","original_commit_id":"d959992b7427aab6cd1260716b346e5b1f97f1a5","user":{"login":"tlindaliu","id":7157789,"avatar_url":"https://avatars.githubusercontent.com/u/7157789?v=3","gravatar_id":"","url":"https://api.github.com/users/tlindaliu","html_url":"https://github.com/tlindaliu","followers_url":"https://api.github.com/users/tlindaliu/followers","following_url":"https://api.github.com/users/tlindaliu/following{/other_user}","gists_url":"https://api.github.com/users/tlindaliu/gists{/gist_id}","starred_url":"https://api.github.com/users/tlindaliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlindaliu/subscriptions","organizations_url":"https://api.github.com/users/tlindaliu/orgs","repos_url":"https://api.github.com/users/tlindaliu/repos","events_url":"https://api.github.com/users/tlindaliu/events{/privacy}","received_events_url":"https://api.github.com/users/tlindaliu/received_events","type":"User","site_admin":false},"body":"I ended up doing the start message logic in this PR, such that the StartDateError object is created with the correct start message (advertised_start or start or a default). ","created_at":"2015-06-30T14:04:53Z","updated_at":"2015-06-30T14:04:53Z","html_url":"https://github.com/edx/edx-platform/pull/8693#discussion_r33575509","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/8693","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/33575509"},"html":{"href":"https://github.com/edx/edx-platform/pull/8693#discussion_r33575509"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8693"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/8693","id":38677373,"html_url":"https://github.com/edx/edx-platform/pull/8693","diff_url":"https://github.com/edx/edx-platform/pull/8693.diff","patch_url":"https://github.com/edx/edx-platform/pull/8693.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/8693","number":8693,"state":"open","locked":false,"title":"Lliu/has access changes","user":{"login":"tlindaliu","id":7157789,"avatar_url":"https://avatars.githubusercontent.com/u/7157789?v=3","gravatar_id":"","url":"https://api.github.com/users/tlindaliu","html_url":"https://github.com/tlindaliu","followers_url":"https://api.github.com/users/tlindaliu/followers","following_url":"https://api.github.com/users/tlindaliu/following{/other_user}","gists_url":"https://api.github.com/users/tlindaliu/gists{/gist_id}","starred_url":"https://api.github.com/users/tlindaliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tlindaliu/subscriptions","organizations_url":"https://api.github.com/users/tlindaliu/orgs","repos_url":"https://api.github.com/users/tlindaliu/repos","events_url":"https://api.github.com/users/tlindaliu/events{/privacy}","received_events_url":"https://api.github.com/users/tlindaliu/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-26T18:39:39Z","updated_at":"2015-06-30T14:04:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"071be08f19322498a33a3ba92f09355869ad6700","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/8693/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/8693/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/8693/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/d959992b7427aab6cd1260716b346e5b1f97f1a5","head":{"label":"edx:lliu/has-access-changes","ref":"lliu/has-access-changes","sha":"d959992b7427aab6cd1260716b346e5b1f97f1a5","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-06-30T10:56:43Z","pushed_at":"2015-06-30T14:03:57Z","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":2068655,"stargazers_count":2016,"watchers_count":2016,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1156,"mirror_url":null,"open_issues_count":159,"forks":1156,"open_issues":159,"watchers":2016,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"454986a0299a730514135459e914e5a85dbfd177","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-06-30T10:56:43Z","pushed_at":"2015-06-30T14:03:57Z","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":2068655,"stargazers_count":2016,"watchers_count":2016,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1156,"mirror_url":null,"open_issues_count":159,"forks":1156,"open_issues":159,"watchers":2016,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8693"},"html":{"href":"https://github.com/edx/edx-platform/pull/8693"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8693"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8693/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8693/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/8693/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/d959992b7427aab6cd1260716b346e5b1f97f1a5"}}}}