{"action":"created","comment":{"url":"https://api.github.com/repos/StepicOrg/summary/pulls/comments/102494365","pull_request_review_id":23250913,"id":102494365,"diff_hunk":"@@ -185,49 +186,29 @@ def __init__(self, client_id, client_secret):\n         self.session.headers.update({'Authorization': 'Bearer ' + self.token})\n \n     def get_course(self, course_id):\n-        response = self.session.get('{base_url}/api/courses/{id}'.format(base_url=settings.STEPIK_BASE_URL,\n-                                                                         id=course_id))\n-        if not response:\n-            raise CreateSynopsisError('Failed to get courses page from stepik, status code = {status_code}'\n-                                      .format(status_code=response.status_code))\n-\n-        return response.json()['courses'][0]\n-\n-    def get_lesson(self, lesson_id):\n-        response = self.session.get('{base_url}/api/lessons/{id}'.format(base_url=settings.STEPIK_BASE_URL,\n-                                                                         id=lesson_id))\n-        if not response:\n-            raise CreateSynopsisError('Failed to get lessons page from stepik, status code = {status_code}'\n-                                      .format(status_code=response.status_code))\n-\n-        return response.json()['lessons'][0]\n+        return self._get_object('course', course_id)\n \n-    def get_lessons_by_course(self, course_id):\n-        lessons = []\n-        cur_page = 1\n-        while True:\n-            response = self.session.get('{base_url}/api/lessons?course={course_id}&page={page}'\n-                                        .format(base_url=settings.STEPIK_BASE_URL,\n-                                                course_id=course_id,\n-                                                page=cur_page))\n-            if not response:\n-                raise CreateSynopsisError('Failed to get lessons page from stepik, status code = {status_code}'\n-                                          .format(status_code=response.status_code))\n-            lessons.extend(response.json()['lessons'])\n+    def get_section(self, section_id):\n+        return self._get_object('section', section_id)\n \n-            if not response.json()['meta']['has_next']:\n-                return lessons\n+    def get_unit(self, unit_id):\n+        return self._get_object('unit', unit_id)\n \n-            cur_page += 1\n+    def get_lesson(self, lesson_id):\n+        return self._get_object('lesson', lesson_id)\n \n     def get_step(self, step_id):\n-        response = self.session.get('{base_url}/api/steps/{id}'.format(base_url=settings.STEPIK_BASE_URL,\n-                                                                       id=step_id))\n+        return self._get_object('step', step_id)\n+\n+    def _get_object(self, object_type, object_id):\n+        response = self.session.get('{base_url}/api/{type}s/{id}'.format(base_url=settings.STEPIK_BASE_URL,","path":"utils.py","position":null,"original_position":62,"commit_id":"bb6b1cf6becc689afeaa67a1a89abcaacc7a8993","original_commit_id":"c8790b09b1072cd8ad026bf2f53f54a5acba48a4","user":{"login":"kostya93","id":2398884,"avatar_url":"https://avatars.githubusercontent.com/u/2398884?v=3","gravatar_id":"","url":"https://api.github.com/users/kostya93","html_url":"https://github.com/kostya93","followers_url":"https://api.github.com/users/kostya93/followers","following_url":"https://api.github.com/users/kostya93/following{/other_user}","gists_url":"https://api.github.com/users/kostya93/gists{/gist_id}","starred_url":"https://api.github.com/users/kostya93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kostya93/subscriptions","organizations_url":"https://api.github.com/users/kostya93/orgs","repos_url":"https://api.github.com/users/kostya93/repos","events_url":"https://api.github.com/users/kostya93/events{/privacy}","received_events_url":"https://api.github.com/users/kostya93/received_events","type":"User","site_admin":false},"body":"@psviderski Убрал. А еще узнал новое слово)","created_at":"2017-02-22T15:45:39Z","updated_at":"2017-02-22T15:45:39Z","html_url":"https://github.com/StepicOrg/summary/pull/10#discussion_r102494365","pull_request_url":"https://api.github.com/repos/StepicOrg/summary/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/StepicOrg/summary/pulls/comments/102494365"},"html":{"href":"https://github.com/StepicOrg/summary/pull/10#discussion_r102494365"},"pull_request":{"href":"https://api.github.com/repos/StepicOrg/summary/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/StepicOrg/summary/pulls/10","id":107236817,"html_url":"https://github.com/StepicOrg/summary/pull/10","diff_url":"https://github.com/StepicOrg/summary/pull/10.diff","patch_url":"https://github.com/StepicOrg/summary/pull/10.patch","issue_url":"https://api.github.com/repos/StepicOrg/summary/issues/10","number":10,"state":"open","locked":false,"title":"Add section to wiki structure","user":{"login":"kostya93","id":2398884,"avatar_url":"https://avatars.githubusercontent.com/u/2398884?v=3","gravatar_id":"","url":"https://api.github.com/users/kostya93","html_url":"https://github.com/kostya93","followers_url":"https://api.github.com/users/kostya93/followers","following_url":"https://api.github.com/users/kostya93/following{/other_user}","gists_url":"https://api.github.com/users/kostya93/gists{/gist_id}","starred_url":"https://api.github.com/users/kostya93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kostya93/subscriptions","organizations_url":"https://api.github.com/users/kostya93/orgs","repos_url":"https://api.github.com/users/kostya93/repos","events_url":"https://api.github.com/users/kostya93/events{/privacy}","received_events_url":"https://api.github.com/users/kostya93/received_events","type":"User","site_admin":false},"body":"Сейчас на вики есть 3 типа страниц:\r\n- курс\r\n- урок\r\n- шаг\r\n\r\nИерархия осуществляется за счет механизма категорий. Сортировка страниц внутри категорий происходит в лексикографическом порядке.\r\n\r\nПроблемы:\r\n- уроки внутри курса имеют неправильный порядок\r\n- если уроков много - это сложно воспринимать (т.к. на одном уровне иерархии очень много элементов)\r\n- шаги внутри урока имеют неправильный порядок, если их > 9 (т.к. Step 10 идет раньше чем Step 2)\r\n\r\nЧто нужно сделать:\r\n\r\n- [x]   Добавить модули в иерархию\r\n- [x]   Исправить сортировку\r\n\r\nЗадача [EDY-6214](https://vyahhi.myjetbrains.com/youtrack/issue/EDY-6214)","created_at":"2017-02-21T17:19:30Z","updated_at":"2017-02-22T15:45:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3bcf0b0d9deb2c05ff56de3d9f6c03434d3c1002","assignee":{"login":"kostya93","id":2398884,"avatar_url":"https://avatars.githubusercontent.com/u/2398884?v=3","gravatar_id":"","url":"https://api.github.com/users/kostya93","html_url":"https://github.com/kostya93","followers_url":"https://api.github.com/users/kostya93/followers","following_url":"https://api.github.com/users/kostya93/following{/other_user}","gists_url":"https://api.github.com/users/kostya93/gists{/gist_id}","starred_url":"https://api.github.com/users/kostya93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kostya93/subscriptions","organizations_url":"https://api.github.com/users/kostya93/orgs","repos_url":"https://api.github.com/users/kostya93/repos","events_url":"https://api.github.com/users/kostya93/events{/privacy}","received_events_url":"https://api.github.com/users/kostya93/received_events","type":"User","site_admin":false},"assignees":[{"login":"kostya93","id":2398884,"avatar_url":"https://avatars.githubusercontent.com/u/2398884?v=3","gravatar_id":"","url":"https://api.github.com/users/kostya93","html_url":"https://github.com/kostya93","followers_url":"https://api.github.com/users/kostya93/followers","following_url":"https://api.github.com/users/kostya93/following{/other_user}","gists_url":"https://api.github.com/users/kostya93/gists{/gist_id}","starred_url":"https://api.github.com/users/kostya93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kostya93/subscriptions","organizations_url":"https://api.github.com/users/kostya93/orgs","repos_url":"https://api.github.com/users/kostya93/repos","events_url":"https://api.github.com/users/kostya93/events{/privacy}","received_events_url":"https://api.github.com/users/kostya93/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/StepicOrg/summary/pulls/10/commits","review_comments_url":"https://api.github.com/repos/StepicOrg/summary/pulls/10/comments","review_comment_url":"https://api.github.com/repos/StepicOrg/summary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/StepicOrg/summary/issues/10/comments","statuses_url":"https://api.github.com/repos/StepicOrg/summary/statuses/bb6b1cf6becc689afeaa67a1a89abcaacc7a8993","head":{"label":"StepicOrg:feature/add-module-to-wiki-structure","ref":"feature/add-module-to-wiki-structure","sha":"bb6b1cf6becc689afeaa67a1a89abcaacc7a8993","user":{"login":"StepicOrg","id":6727350,"avatar_url":"https://avatars.githubusercontent.com/u/6727350?v=3","gravatar_id":"","url":"https://api.github.com/users/StepicOrg","html_url":"https://github.com/StepicOrg","followers_url":"https://api.github.com/users/StepicOrg/followers","following_url":"https://api.github.com/users/StepicOrg/following{/other_user}","gists_url":"https://api.github.com/users/StepicOrg/gists{/gist_id}","starred_url":"https://api.github.com/users/StepicOrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StepicOrg/subscriptions","organizations_url":"https://api.github.com/users/StepicOrg/orgs","repos_url":"https://api.github.com/users/StepicOrg/repos","events_url":"https://api.github.com/users/StepicOrg/events{/privacy}","received_events_url":"https://api.github.com/users/StepicOrg/received_events","type":"Organization","site_admin":false},"repo":{"id":63328104,"name":"summary","full_name":"StepicOrg/summary","owner":{"login":"StepicOrg","id":6727350,"avatar_url":"https://avatars.githubusercontent.com/u/6727350?v=3","gravatar_id":"","url":"https://api.github.com/users/StepicOrg","html_url":"https://github.com/StepicOrg","followers_url":"https://api.github.com/users/StepicOrg/followers","following_url":"https://api.github.com/users/StepicOrg/following{/other_user}","gists_url":"https://api.github.com/users/StepicOrg/gists{/gist_id}","starred_url":"https://api.github.com/users/StepicOrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StepicOrg/subscriptions","organizations_url":"https://api.github.com/users/StepicOrg/orgs","repos_url":"https://api.github.com/users/StepicOrg/repos","events_url":"https://api.github.com/users/StepicOrg/events{/privacy}","received_events_url":"https://api.github.com/users/StepicOrg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StepicOrg/summary","description":"Autogenerating summary from video course","fork":false,"url":"https://api.github.com/repos/StepicOrg/summary","forks_url":"https://api.github.com/repos/StepicOrg/summary/forks","keys_url":"https://api.github.com/repos/StepicOrg/summary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StepicOrg/summary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StepicOrg/summary/teams","hooks_url":"https://api.github.com/repos/StepicOrg/summary/hooks","issue_events_url":"https://api.github.com/repos/StepicOrg/summary/issues/events{/number}","events_url":"https://api.github.com/repos/StepicOrg/summary/events","assignees_url":"https://api.github.com/repos/StepicOrg/summary/assignees{/user}","branches_url":"https://api.github.com/repos/StepicOrg/summary/branches{/branch}","tags_url":"https://api.github.com/repos/StepicOrg/summary/tags","blobs_url":"https://api.github.com/repos/StepicOrg/summary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StepicOrg/summary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StepicOrg/summary/git/refs{/sha}","trees_url":"https://api.github.com/repos/StepicOrg/summary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StepicOrg/summary/statuses/{sha}","languages_url":"https://api.github.com/repos/StepicOrg/summary/languages","stargazers_url":"https://api.github.com/repos/StepicOrg/summary/stargazers","contributors_url":"https://api.github.com/repos/StepicOrg/summary/contributors","subscribers_url":"https://api.github.com/repos/StepicOrg/summary/subscribers","subscription_url":"https://api.github.com/repos/StepicOrg/summary/subscription","commits_url":"https://api.github.com/repos/StepicOrg/summary/commits{/sha}","git_commits_url":"https://api.github.com/repos/StepicOrg/summary/git/commits{/sha}","comments_url":"https://api.github.com/repos/StepicOrg/summary/comments{/number}","issue_comment_url":"https://api.github.com/repos/StepicOrg/summary/issues/comments{/number}","contents_url":"https://api.github.com/repos/StepicOrg/summary/contents/{+path}","compare_url":"https://api.github.com/repos/StepicOrg/summary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StepicOrg/summary/merges","archive_url":"https://api.github.com/repos/StepicOrg/summary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StepicOrg/summary/downloads","issues_url":"https://api.github.com/repos/StepicOrg/summary/issues{/number}","pulls_url":"https://api.github.com/repos/StepicOrg/summary/pulls{/number}","milestones_url":"https://api.github.com/repos/StepicOrg/summary/milestones{/number}","notifications_url":"https://api.github.com/repos/StepicOrg/summary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StepicOrg/summary/labels{/name}","releases_url":"https://api.github.com/repos/StepicOrg/summary/releases{/id}","deployments_url":"https://api.github.com/repos/StepicOrg/summary/deployments","created_at":"2016-07-14T10:43:08Z","updated_at":"2016-07-14T10:51:35Z","pushed_at":"2017-02-22T15:44:07Z","git_url":"git://github.com/StepicOrg/summary.git","ssh_url":"git@github.com:StepicOrg/summary.git","clone_url":"https://github.com/StepicOrg/summary.git","svn_url":"https://github.com/StepicOrg/summary","homepage":null,"size":1264,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"StepicOrg:master","ref":"master","sha":"ccc20c0f609adbe5cc248d320def2dedee7f50ec","user":{"login":"StepicOrg","id":6727350,"avatar_url":"https://avatars.githubusercontent.com/u/6727350?v=3","gravatar_id":"","url":"https://api.github.com/users/StepicOrg","html_url":"https://github.com/StepicOrg","followers_url":"https://api.github.com/users/StepicOrg/followers","following_url":"https://api.github.com/users/StepicOrg/following{/other_user}","gists_url":"https://api.github.com/users/StepicOrg/gists{/gist_id}","starred_url":"https://api.github.com/users/StepicOrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StepicOrg/subscriptions","organizations_url":"https://api.github.com/users/StepicOrg/orgs","repos_url":"https://api.github.com/users/StepicOrg/repos","events_url":"https://api.github.com/users/StepicOrg/events{/privacy}","received_events_url":"https://api.github.com/users/StepicOrg/received_events","type":"Organization","site_admin":false},"repo":{"id":63328104,"name":"summary","full_name":"StepicOrg/summary","owner":{"login":"StepicOrg","id":6727350,"avatar_url":"https://avatars.githubusercontent.com/u/6727350?v=3","gravatar_id":"","url":"https://api.github.com/users/StepicOrg","html_url":"https://github.com/StepicOrg","followers_url":"https://api.github.com/users/StepicOrg/followers","following_url":"https://api.github.com/users/StepicOrg/following{/other_user}","gists_url":"https://api.github.com/users/StepicOrg/gists{/gist_id}","starred_url":"https://api.github.com/users/StepicOrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StepicOrg/subscriptions","organizations_url":"https://api.github.com/users/StepicOrg/orgs","repos_url":"https://api.github.com/users/StepicOrg/repos","events_url":"https://api.github.com/users/StepicOrg/events{/privacy}","received_events_url":"https://api.github.com/users/StepicOrg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/StepicOrg/summary","description":"Autogenerating summary from video course","fork":false,"url":"https://api.github.com/repos/StepicOrg/summary","forks_url":"https://api.github.com/repos/StepicOrg/summary/forks","keys_url":"https://api.github.com/repos/StepicOrg/summary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StepicOrg/summary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StepicOrg/summary/teams","hooks_url":"https://api.github.com/repos/StepicOrg/summary/hooks","issue_events_url":"https://api.github.com/repos/StepicOrg/summary/issues/events{/number}","events_url":"https://api.github.com/repos/StepicOrg/summary/events","assignees_url":"https://api.github.com/repos/StepicOrg/summary/assignees{/user}","branches_url":"https://api.github.com/repos/StepicOrg/summary/branches{/branch}","tags_url":"https://api.github.com/repos/StepicOrg/summary/tags","blobs_url":"https://api.github.com/repos/StepicOrg/summary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StepicOrg/summary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StepicOrg/summary/git/refs{/sha}","trees_url":"https://api.github.com/repos/StepicOrg/summary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StepicOrg/summary/statuses/{sha}","languages_url":"https://api.github.com/repos/StepicOrg/summary/languages","stargazers_url":"https://api.github.com/repos/StepicOrg/summary/stargazers","contributors_url":"https://api.github.com/repos/StepicOrg/summary/contributors","subscribers_url":"https://api.github.com/repos/StepicOrg/summary/subscribers","subscription_url":"https://api.github.com/repos/StepicOrg/summary/subscription","commits_url":"https://api.github.com/repos/StepicOrg/summary/commits{/sha}","git_commits_url":"https://api.github.com/repos/StepicOrg/summary/git/commits{/sha}","comments_url":"https://api.github.com/repos/StepicOrg/summary/comments{/number}","issue_comment_url":"https://api.github.com/repos/StepicOrg/summary/issues/comments{/number}","contents_url":"https://api.github.com/repos/StepicOrg/summary/contents/{+path}","compare_url":"https://api.github.com/repos/StepicOrg/summary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StepicOrg/summary/merges","archive_url":"https://api.github.com/repos/StepicOrg/summary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StepicOrg/summary/downloads","issues_url":"https://api.github.com/repos/StepicOrg/summary/issues{/number}","pulls_url":"https://api.github.com/repos/StepicOrg/summary/pulls{/number}","milestones_url":"https://api.github.com/repos/StepicOrg/summary/milestones{/number}","notifications_url":"https://api.github.com/repos/StepicOrg/summary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StepicOrg/summary/labels{/name}","releases_url":"https://api.github.com/repos/StepicOrg/summary/releases{/id}","deployments_url":"https://api.github.com/repos/StepicOrg/summary/deployments","created_at":"2016-07-14T10:43:08Z","updated_at":"2016-07-14T10:51:35Z","pushed_at":"2017-02-22T15:44:07Z","git_url":"git://github.com/StepicOrg/summary.git","ssh_url":"git@github.com:StepicOrg/summary.git","clone_url":"https://github.com/StepicOrg/summary.git","svn_url":"https://github.com/StepicOrg/summary","homepage":null,"size":1264,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/StepicOrg/summary/pulls/10"},"html":{"href":"https://github.com/StepicOrg/summary/pull/10"},"issue":{"href":"https://api.github.com/repos/StepicOrg/summary/issues/10"},"comments":{"href":"https://api.github.com/repos/StepicOrg/summary/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/StepicOrg/summary/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/StepicOrg/summary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/StepicOrg/summary/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/StepicOrg/summary/statuses/bb6b1cf6becc689afeaa67a1a89abcaacc7a8993"}}}}
{"actor":{"display_login":"kostya93"}}