{"action":"created","comment":{"url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments/74600557","id":74600557,"diff_hunk":"@@ -0,0 +1,139 @@\n+import datetime\n+import logging\n+\n+from django.core.management.base import BaseCommand\n+from django.core.exceptions import ObjectDoesNotExist\n+\n+from student.models import CourseAccessRole\n+from django.contrib.auth.models import Group\n+from edx_solutions_api_integration.models import CourseGroupRelationship\n+from edx_solutions_api_integration.courseware_access import get_course_key\n+from courseware import courses\n+\n+log = logging.getLogger(__name__)\n+\n+\n+class Command(BaseCommand):\n+    help = '''Remove instructor role of internal admins on courses in their organization and add it on internal tagged courses\n+example:\n+    ./manage.py lms repair_internal_admin_instructor_role dryrun --settings={aws, devstack}\n+\n+Options:\n+    createlog\n+                don't print all the effects but create log file\n+    dryrun\n+                do the dry run for the fixes\n+    repair\n+                repair all roles\n+'''\n+\n+    def handle(self, *args, **options):\n+        if len(args) < 1 or len(args) > 2:\n+            print Command.help\n+            return\n+\n+        dry_run = True\n+        create_log = False\n+\n+        msg_string = 'Script started on {}'.format(datetime.datetime.now().ctime())\n+\n+        if 'repair' in args:\n+            dry_run = False\n+        if 'dryrun' in args:\n+            dry_run = True\n+        if 'createlog' in args:\n+            create_log = True\n+            file_handler = logging.FileHandler('repair_internal_admin_instructor_role.log')","path":"common/djangoapps/student/management/commands/repair_internal_admin_instructor_role.py","position":46,"original_position":46,"commit_id":"c0002d7afbde6f8d70874a5de5607eb79842dee5","original_commit_id":"c0002d7afbde6f8d70874a5de5607eb79842dee5","user":{"login":"ziafazal","id":434995,"avatar_url":"https://avatars.githubusercontent.com/u/434995?v=3","gravatar_id":"","url":"https://api.github.com/users/ziafazal","html_url":"https://github.com/ziafazal","followers_url":"https://api.github.com/users/ziafazal/followers","following_url":"https://api.github.com/users/ziafazal/following{/other_user}","gists_url":"https://api.github.com/users/ziafazal/gists{/gist_id}","starred_url":"https://api.github.com/users/ziafazal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ziafazal/subscriptions","organizations_url":"https://api.github.com/users/ziafazal/orgs","repos_url":"https://api.github.com/users/ziafazal/repos","events_url":"https://api.github.com/users/ziafazal/events{/privacy}","received_events_url":"https://api.github.com/users/ziafazal/received_events","type":"User","site_admin":false},"body":"@franosincic why we are creating a separate log file? `log.info` should put loggin in `/edx/var/log/lms/edx.log`","created_at":"2016-08-12T14:32:04Z","updated_at":"2016-08-12T14:32:04Z","html_url":"https://github.com/edx-solutions/edx-platform/pull/740#discussion_r74600557","pull_request_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740","_links":{"self":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments/74600557"},"html":{"href":"https://github.com/edx-solutions/edx-platform/pull/740#discussion_r74600557"},"pull_request":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740"}}},"pull_request":{"url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740","id":81107615,"html_url":"https://github.com/edx-solutions/edx-platform/pull/740","diff_url":"https://github.com/edx-solutions/edx-platform/pull/740.diff","patch_url":"https://github.com/edx-solutions/edx-platform/pull/740.patch","issue_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/740","number":740,"state":"open","locked":false,"title":"repair_internal_admin_instructor_role script","user":{"login":"franosincic","id":10136836,"avatar_url":"https://avatars.githubusercontent.com/u/10136836?v=3","gravatar_id":"","url":"https://api.github.com/users/franosincic","html_url":"https://github.com/franosincic","followers_url":"https://api.github.com/users/franosincic/followers","following_url":"https://api.github.com/users/franosincic/following{/other_user}","gists_url":"https://api.github.com/users/franosincic/gists{/gist_id}","starred_url":"https://api.github.com/users/franosincic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/franosincic/subscriptions","organizations_url":"https://api.github.com/users/franosincic/orgs","repos_url":"https://api.github.com/users/franosincic/repos","events_url":"https://api.github.com/users/franosincic/events{/privacy}","received_events_url":"https://api.github.com/users/franosincic/received_events","type":"User","site_admin":false},"body":"Script for fixing internal admin instructor role. ","created_at":"2016-08-12T11:55:18Z","updated_at":"2016-08-12T14:32:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4b92d1bd5a627fe8ae8adb1a73ebe80bec8f077f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740/commits","review_comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740/comments","review_comment_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/740/comments","statuses_url":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/c0002d7afbde6f8d70874a5de5607eb79842dee5","head":{"label":"edx-solutions:fsincic/repair_internal_admin_instructor_role","ref":"fsincic/repair_internal_admin_instructor_role","sha":"c0002d7afbde6f8d70874a5de5607eb79842dee5","user":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"repo":{"id":16513414,"name":"edx-platform","full_name":"edx-solutions/edx-platform","owner":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx-solutions/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/edx-solutions/edx-platform","forks_url":"https://api.github.com/repos/edx-solutions/edx-platform/forks","keys_url":"https://api.github.com/repos/edx-solutions/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx-solutions/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx-solutions/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx-solutions/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx-solutions/edx-platform/events","assignees_url":"https://api.github.com/repos/edx-solutions/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx-solutions/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx-solutions/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx-solutions/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx-solutions/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx-solutions/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx-solutions/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx-solutions/edx-platform/merges","archive_url":"https://api.github.com/repos/edx-solutions/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx-solutions/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx-solutions/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx-solutions/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx-solutions/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx-solutions/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx-solutions/edx-platform/deployments","created_at":"2014-02-04T14:02:57Z","updated_at":"2016-04-28T20:50:22Z","pushed_at":"2016-08-12T13:25:41Z","git_url":"git://github.com/edx-solutions/edx-platform.git","ssh_url":"git@github.com:edx-solutions/edx-platform.git","clone_url":"https://github.com/edx-solutions/edx-platform.git","svn_url":"https://github.com/edx-solutions/edx-platform","homepage":"http://code.edx.org/","size":685672,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":7,"default_branch":"master"}},"base":{"label":"edx-solutions:master","ref":"master","sha":"35c47a2bd8a1668a8b351c3cad1b83daf8e0e9eb","user":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"repo":{"id":16513414,"name":"edx-platform","full_name":"edx-solutions/edx-platform","owner":{"login":"edx-solutions","id":6585054,"avatar_url":"https://avatars.githubusercontent.com/u/6585054?v=3","gravatar_id":"","url":"https://api.github.com/users/edx-solutions","html_url":"https://github.com/edx-solutions","followers_url":"https://api.github.com/users/edx-solutions/followers","following_url":"https://api.github.com/users/edx-solutions/following{/other_user}","gists_url":"https://api.github.com/users/edx-solutions/gists{/gist_id}","starred_url":"https://api.github.com/users/edx-solutions/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx-solutions/subscriptions","organizations_url":"https://api.github.com/users/edx-solutions/orgs","repos_url":"https://api.github.com/users/edx-solutions/repos","events_url":"https://api.github.com/users/edx-solutions/events{/privacy}","received_events_url":"https://api.github.com/users/edx-solutions/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx-solutions/edx-platform","description":"the edX learning management system (LMS) and course authoring tool, Studio","fork":true,"url":"https://api.github.com/repos/edx-solutions/edx-platform","forks_url":"https://api.github.com/repos/edx-solutions/edx-platform/forks","keys_url":"https://api.github.com/repos/edx-solutions/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx-solutions/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx-solutions/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx-solutions/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx-solutions/edx-platform/events","assignees_url":"https://api.github.com/repos/edx-solutions/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx-solutions/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx-solutions/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx-solutions/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx-solutions/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx-solutions/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx-solutions/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx-solutions/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx-solutions/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx-solutions/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx-solutions/edx-platform/merges","archive_url":"https://api.github.com/repos/edx-solutions/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx-solutions/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx-solutions/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx-solutions/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx-solutions/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx-solutions/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx-solutions/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx-solutions/edx-platform/releases{/id}","deployments_url":"https://api.github.com/repos/edx-solutions/edx-platform/deployments","created_at":"2014-02-04T14:02:57Z","updated_at":"2016-04-28T20:50:22Z","pushed_at":"2016-08-12T13:25:41Z","git_url":"git://github.com/edx-solutions/edx-platform.git","ssh_url":"git@github.com:edx-solutions/edx-platform.git","clone_url":"https://github.com/edx-solutions/edx-platform.git","svn_url":"https://github.com/edx-solutions/edx-platform","homepage":"http://code.edx.org/","size":685672,"stargazers_count":7,"watchers_count":7,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740"},"html":{"href":"https://github.com/edx-solutions/edx-platform/pull/740"},"issue":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/issues/740"},"comments":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/issues/740/comments"},"review_comments":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740/comments"},"review_comment":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/pulls/740/commits"},"statuses":{"href":"https://api.github.com/repos/edx-solutions/edx-platform/statuses/c0002d7afbde6f8d70874a5de5607eb79842dee5"}}}}
{"actor":{"display_login":"ziafazal"}}