{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/31929592","id":31929592,"diff_hunk":"@@ -191,22 +205,88 @@ def from_json(tab_dict):\n             InvalidTabsException if the given tab doesn't have the right keys.\n         \"\"\"\n         # TODO: don't import openedx capabilities from common\n-        from openedx.core.djangoapps.course_views.course_views import CourseViewTypeManager\n+        from openedx.core.lib.course_tabs import CourseTabPluginManager\n         tab_type_name = tab_dict.get('type')\n         if tab_type_name is None:\n             log.error('No type included in tab_dict: %r', tab_dict)\n             return None\n         try:\n-            tab_type = CourseViewTypeManager.get_plugin(tab_type_name)\n+            tab_type = CourseTabPluginManager.get_plugin(tab_type_name)\n         except PluginError:\n             log.exception(\n                 \"Unknown tab type %r Known types: %r.\",\n                 tab_type_name,\n-                CourseViewTypeManager.get_course_view_types()\n+                CourseTabPluginManager.get_tab_types()\n             )\n             return None\n+\n         tab_type.validate(tab_dict)\n-        return tab_type.create_tab(tab_dict=tab_dict)\n+        return tab_type(tab_dict=tab_dict)\n+\n+\n+class StaticTab(CourseTab):\n+    \"\"\"\n+    A custom tab.\n+    \"\"\"\n+    type = 'static_tab'\n+    is_default = False    # A static tab is never added to a course by default\n+    allow_multiple = True\n+\n+    def __init__(self, tab_dict=None, name=None, url_slug=None):\n+        def link_func(course, reverse_func):\n+            \"\"\" Returns a url for a given course and reverse function. \"\"\"\n+            return reverse_func(self.type, args=[course.id.to_deprecated_string(), self.url_slug])\n+\n+        self.url_slug = tab_dict['url_slug'] if tab_dict else url_slug\n+\n+        if tab_dict is None:\n+            tab_dict = dict()\n+\n+        if name is not None:\n+            tab_dict['name'] = name\n+\n+        tab_dict['link_func'] = link_func\n+        tab_dict['tab_id'] = 'static_tab_{0}'.format(self.url_slug)\n+\n+        super(StaticTab, self).__init__(tab_dict)\n+\n+    @classmethod\n+    def is_enabled(cls, course, user=None):  # pylint: disable=unused-argument\n+        \"\"\"\n+        Static tabs are viewable to everyone, even anonymous users.\n+        \"\"\"\n+        return True\n+\n+    @classmethod\n+    def validate(cls, tab_dict, raise_error=True):\n+        \"\"\"\n+        Ensures that the specified tab_dict is valid.\n+        \"\"\"\n+        return (super(StaticTab, cls).validate(tab_dict, raise_error)\n+                and key_checker(['name', 'url_slug'])(tab_dict, raise_error))\n+\n+    def __getitem__(self, key):\n+        if key == 'url_slug':\n+            return self.url_slug\n+        else:\n+            return super(StaticTab, self).__getitem__(key)","path":"common/lib/xmodule/xmodule/tabs.py","position":199,"original_position":199,"commit_id":"ec54aac3791825cbbf0b56fcf6a234f1bca67759","original_commit_id":"ec54aac3791825cbbf0b56fcf6a234f1bca67759","user":{"login":"dan-f","id":2146312,"avatar_url":"https://avatars.githubusercontent.com/u/2146312?v=3","gravatar_id":"","url":"https://api.github.com/users/dan-f","html_url":"https://github.com/dan-f","followers_url":"https://api.github.com/users/dan-f/followers","following_url":"https://api.github.com/users/dan-f/following{/other_user}","gists_url":"https://api.github.com/users/dan-f/gists{/gist_id}","starred_url":"https://api.github.com/users/dan-f/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dan-f/subscriptions","organizations_url":"https://api.github.com/users/dan-f/orgs","repos_url":"https://api.github.com/users/dan-f/repos","events_url":"https://api.github.com/users/dan-f/events{/privacy}","received_events_url":"https://api.github.com/users/dan-f/received_events","type":"User","site_admin":false},"body":"I'm asking why we're overriding this method. By default, calling `static_tab.url_slug` on an instance of `StaticTab` would return self.url_slug. calling `static_tab.some_property` would find `some_property` on static_tab which could have been either set by the child class or the parent class.","created_at":"2015-06-08T15:57:49Z","updated_at":"2015-06-08T15:57:49Z","html_url":"https://github.com/edx/edx-platform/pull/8367#discussion_r31929592","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/8367","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/31929592"},"html":{"href":"https://github.com/edx/edx-platform/pull/8367#discussion_r31929592"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8367"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/8367","id":36950010,"html_url":"https://github.com/edx/edx-platform/pull/8367","diff_url":"https://github.com/edx/edx-platform/pull/8367.diff","patch_url":"https://github.com/edx/edx-platform/pull/8367.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/8367","number":8367,"state":"open","locked":false,"title":"Refactor and merge CourseViewType and CourseTab.","user":{"login":"dianakhuang","id":2952947,"avatar_url":"https://avatars.githubusercontent.com/u/2952947?v=3","gravatar_id":"","url":"https://api.github.com/users/dianakhuang","html_url":"https://github.com/dianakhuang","followers_url":"https://api.github.com/users/dianakhuang/followers","following_url":"https://api.github.com/users/dianakhuang/following{/other_user}","gists_url":"https://api.github.com/users/dianakhuang/gists{/gist_id}","starred_url":"https://api.github.com/users/dianakhuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dianakhuang/subscriptions","organizations_url":"https://api.github.com/users/dianakhuang/orgs","repos_url":"https://api.github.com/users/dianakhuang/repos","events_url":"https://api.github.com/users/dianakhuang/events{/privacy}","received_events_url":"https://api.github.com/users/dianakhuang/received_events","type":"User","site_admin":false},"body":"Merges `CourseViewType` into `CourseTab` and updates all the corresponding tabs.\r\n\r\nTNL-2321","created_at":"2015-06-04T16:02:30Z","updated_at":"2015-06-08T15:57:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b87b9f8ae28413e18a801529f0dfe598673c94da","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/8367/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/8367/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/8367/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/ec54aac3791825cbbf0b56fcf6a234f1bca67759","head":{"label":"edx:diana/merge-course-view-and-tab","ref":"diana/merge-course-view-and-tab","sha":"ec54aac3791825cbbf0b56fcf6a234f1bca67759","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-06T23:11:50Z","pushed_at":"2015-06-08T15:57: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":1907053,"stargazers_count":1964,"watchers_count":1964,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1129,"mirror_url":null,"open_issues_count":180,"forks":1129,"open_issues":180,"watchers":1964,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"6c2df96c5f0d53166163d5718718171f62165279","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-06T23:11:50Z","pushed_at":"2015-06-08T15:57: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":1907053,"stargazers_count":1964,"watchers_count":1964,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1129,"mirror_url":null,"open_issues_count":180,"forks":1129,"open_issues":180,"watchers":1964,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8367"},"html":{"href":"https://github.com/edx/edx-platform/pull/8367"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8367"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8367/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8367/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/8367/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/ec54aac3791825cbbf0b56fcf6a234f1bca67759"}}}}