{"action":"created","comment":{"url":"https://api.github.com/repos/liqd/adhocracy3/pulls/comments/61034240","id":61034240,"diff_hunk":"@@ -0,0 +1,109 @@\n+\"\"\"Automatically transition workflow states.\n+\n+This is registered as console script.\n+\"\"\"\n+import transaction\n+import argparse\n+import inspect\n+import logging\n+\n+from pyramid.paster import bootstrap\n+from pyramid.registry import Registry\n+from substanced.util import find_service\n+\n+from adhocracy_core.authorization import create_fake_god_request\n+from adhocracy_core.interfaces import IResource\n+from adhocracy_core.interfaces import search_query\n+from adhocracy_core.resources.process import IProcess\n+from adhocracy_core.sheets.workflow import IWorkflowAssignment\n+from adhocracy_core.workflows import transition_to_states\n+from adhocracy_core.utils import now\n+\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+def auto_transition_process_workflow():  # pragma: no cover\n+    \"\"\"Automatically transition workflow states.\n+\n+    usage::\n+\n+        bin/auto_auto_transition_process_workflow etc/development.ini\n+    \"\"\"\n+    docstring = inspect.getdoc(auto_transition_process_workflow)\n+    parser = argparse.ArgumentParser(description=docstring)\n+    parser.add_argument('ini_file',\n+                        help='path to the adhocracy backend ini file')\n+    args = parser.parse_args()\n+    env = bootstrap(args.ini_file)\n+    _auto_transition_process_workflow(env['root'], env['registry'])\n+    transaction.commit()\n+    env['closer']()\n+\n+\n+def _auto_transition_process_workflow(context: IResource, registry: Registry):\n+    catalogs = find_service(context, 'catalogs')\n+    query = search_query._replace(interfaces=IProcess,\n+                                  resolve=True\n+                                  )\n+    processes = catalogs.search(query).elements\n+    for process in processes:\n+        workflow_assignment = registry.content.get_sheet(process,\n+                                                         IWorkflowAssignment)\n+        if _workflow_auto_transition_enabled(registry, workflow_assignment) \\\n+            and _workflow_auto_transition_needed(process, registry,\n+                                                 workflow_assignment):\n+            _do_workflow_auto_transition(process, registry)\n+","path":"src/adhocracy_core/adhocracy_core/scripts/auto_transition_process_workflow.py","position":57,"original_position":57,"commit_id":"f876794aae6ec1671149b039da907080b1460026","original_commit_id":"f876794aae6ec1671149b039da907080b1460026","user":{"login":"joka","id":353982,"avatar_url":"https://avatars.githubusercontent.com/u/353982?v=3","gravatar_id":"","url":"https://api.github.com/users/joka","html_url":"https://github.com/joka","followers_url":"https://api.github.com/users/joka/followers","following_url":"https://api.github.com/users/joka/following{/other_user}","gists_url":"https://api.github.com/users/joka/gists{/gist_id}","starred_url":"https://api.github.com/users/joka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joka/subscriptions","organizations_url":"https://api.github.com/users/joka/orgs","repos_url":"https://api.github.com/users/joka/repos","events_url":"https://api.github.com/users/joka/events{/privacy}","received_events_url":"https://api.github.com/users/joka/received_events","type":"User","site_admin":false},"body":"sorry for being picky, I just want to emphasise the sections about readability, variables and function in the refactoring guideline: http://adhocracy3.readthedocs.org/en/latest/coding_guides/refactor_guidelines.html#clean-code-short-summary","created_at":"2016-04-26T06:33:47Z","updated_at":"2016-04-26T06:33:47Z","html_url":"https://github.com/liqd/adhocracy3/pull/2247#discussion_r61034240","pull_request_url":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247","_links":{"self":{"href":"https://api.github.com/repos/liqd/adhocracy3/pulls/comments/61034240"},"html":{"href":"https://github.com/liqd/adhocracy3/pull/2247#discussion_r61034240"},"pull_request":{"href":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247"}}},"pull_request":{"url":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247","id":67197468,"html_url":"https://github.com/liqd/adhocracy3/pull/2247","diff_url":"https://github.com/liqd/adhocracy3/pull/2247.diff","patch_url":"https://github.com/liqd/adhocracy3/pull/2247.patch","issue_url":"https://api.github.com/repos/liqd/adhocracy3/issues/2247","number":2247,"state":"open","locked":false,"title":"2016 04 as add automatic workflow transition script","user":{"login":"2e2a","id":16001917,"avatar_url":"https://avatars.githubusercontent.com/u/16001917?v=3","gravatar_id":"","url":"https://api.github.com/users/2e2a","html_url":"https://github.com/2e2a","followers_url":"https://api.github.com/users/2e2a/followers","following_url":"https://api.github.com/users/2e2a/following{/other_user}","gists_url":"https://api.github.com/users/2e2a/gists{/gist_id}","starred_url":"https://api.github.com/users/2e2a/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2e2a/subscriptions","organizations_url":"https://api.github.com/users/2e2a/orgs","repos_url":"https://api.github.com/users/2e2a/repos","events_url":"https://api.github.com/users/2e2a/events{/privacy}","received_events_url":"https://api.github.com/users/2e2a/received_events","type":"User","site_admin":false},"body":"@joka please review","created_at":"2016-04-20T14:32:51Z","updated_at":"2016-04-26T06:33:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57141b03620bca1e0fe2e26df9e7ae2a04b6530e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247/commits","review_comments_url":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247/comments","review_comment_url":"https://api.github.com/repos/liqd/adhocracy3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/liqd/adhocracy3/issues/2247/comments","statuses_url":"https://api.github.com/repos/liqd/adhocracy3/statuses/f876794aae6ec1671149b039da907080b1460026","head":{"label":"liqd:2016-04-as-add-automatic-workflow-transition-script","ref":"2016-04-as-add-automatic-workflow-transition-script","sha":"f876794aae6ec1671149b039da907080b1460026","user":{"login":"liqd","id":2312088,"avatar_url":"https://avatars.githubusercontent.com/u/2312088?v=3","gravatar_id":"","url":"https://api.github.com/users/liqd","html_url":"https://github.com/liqd","followers_url":"https://api.github.com/users/liqd/followers","following_url":"https://api.github.com/users/liqd/following{/other_user}","gists_url":"https://api.github.com/users/liqd/gists{/gist_id}","starred_url":"https://api.github.com/users/liqd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liqd/subscriptions","organizations_url":"https://api.github.com/users/liqd/orgs","repos_url":"https://api.github.com/users/liqd/repos","events_url":"https://api.github.com/users/liqd/events{/privacy}","received_events_url":"https://api.github.com/users/liqd/received_events","type":"Organization","site_admin":false},"repo":{"id":22982974,"name":"adhocracy3","full_name":"liqd/adhocracy3","owner":{"login":"liqd","id":2312088,"avatar_url":"https://avatars.githubusercontent.com/u/2312088?v=3","gravatar_id":"","url":"https://api.github.com/users/liqd","html_url":"https://github.com/liqd","followers_url":"https://api.github.com/users/liqd/followers","following_url":"https://api.github.com/users/liqd/following{/other_user}","gists_url":"https://api.github.com/users/liqd/gists{/gist_id}","starred_url":"https://api.github.com/users/liqd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liqd/subscriptions","organizations_url":"https://api.github.com/users/liqd/orgs","repos_url":"https://api.github.com/users/liqd/repos","events_url":"https://api.github.com/users/liqd/events{/privacy}","received_events_url":"https://api.github.com/users/liqd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/liqd/adhocracy3","description":"Adhocracy 3 with customizations for various projects","fork":false,"url":"https://api.github.com/repos/liqd/adhocracy3","forks_url":"https://api.github.com/repos/liqd/adhocracy3/forks","keys_url":"https://api.github.com/repos/liqd/adhocracy3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liqd/adhocracy3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liqd/adhocracy3/teams","hooks_url":"https://api.github.com/repos/liqd/adhocracy3/hooks","issue_events_url":"https://api.github.com/repos/liqd/adhocracy3/issues/events{/number}","events_url":"https://api.github.com/repos/liqd/adhocracy3/events","assignees_url":"https://api.github.com/repos/liqd/adhocracy3/assignees{/user}","branches_url":"https://api.github.com/repos/liqd/adhocracy3/branches{/branch}","tags_url":"https://api.github.com/repos/liqd/adhocracy3/tags","blobs_url":"https://api.github.com/repos/liqd/adhocracy3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liqd/adhocracy3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liqd/adhocracy3/git/refs{/sha}","trees_url":"https://api.github.com/repos/liqd/adhocracy3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liqd/adhocracy3/statuses/{sha}","languages_url":"https://api.github.com/repos/liqd/adhocracy3/languages","stargazers_url":"https://api.github.com/repos/liqd/adhocracy3/stargazers","contributors_url":"https://api.github.com/repos/liqd/adhocracy3/contributors","subscribers_url":"https://api.github.com/repos/liqd/adhocracy3/subscribers","subscription_url":"https://api.github.com/repos/liqd/adhocracy3/subscription","commits_url":"https://api.github.com/repos/liqd/adhocracy3/commits{/sha}","git_commits_url":"https://api.github.com/repos/liqd/adhocracy3/git/commits{/sha}","comments_url":"https://api.github.com/repos/liqd/adhocracy3/comments{/number}","issue_comment_url":"https://api.github.com/repos/liqd/adhocracy3/issues/comments{/number}","contents_url":"https://api.github.com/repos/liqd/adhocracy3/contents/{+path}","compare_url":"https://api.github.com/repos/liqd/adhocracy3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liqd/adhocracy3/merges","archive_url":"https://api.github.com/repos/liqd/adhocracy3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liqd/adhocracy3/downloads","issues_url":"https://api.github.com/repos/liqd/adhocracy3/issues{/number}","pulls_url":"https://api.github.com/repos/liqd/adhocracy3/pulls{/number}","milestones_url":"https://api.github.com/repos/liqd/adhocracy3/milestones{/number}","notifications_url":"https://api.github.com/repos/liqd/adhocracy3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liqd/adhocracy3/labels{/name}","releases_url":"https://api.github.com/repos/liqd/adhocracy3/releases{/id}","deployments_url":"https://api.github.com/repos/liqd/adhocracy3/deployments","created_at":"2014-08-15T08:07:57Z","updated_at":"2016-04-16T09:36:11Z","pushed_at":"2016-04-25T17:53:16Z","git_url":"git://github.com/liqd/adhocracy3.git","ssh_url":"git@github.com:liqd/adhocracy3.git","clone_url":"https://github.com/liqd/adhocracy3.git","svn_url":"https://github.com/liqd/adhocracy3","homepage":"","size":23503,"stargazers_count":40,"watchers_count":40,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":94,"forks":13,"open_issues":94,"watchers":40,"default_branch":"master"}},"base":{"label":"liqd:master","ref":"master","sha":"2be50b0a7d38c57e9b6a1ab046deac4b4cacf6dc","user":{"login":"liqd","id":2312088,"avatar_url":"https://avatars.githubusercontent.com/u/2312088?v=3","gravatar_id":"","url":"https://api.github.com/users/liqd","html_url":"https://github.com/liqd","followers_url":"https://api.github.com/users/liqd/followers","following_url":"https://api.github.com/users/liqd/following{/other_user}","gists_url":"https://api.github.com/users/liqd/gists{/gist_id}","starred_url":"https://api.github.com/users/liqd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liqd/subscriptions","organizations_url":"https://api.github.com/users/liqd/orgs","repos_url":"https://api.github.com/users/liqd/repos","events_url":"https://api.github.com/users/liqd/events{/privacy}","received_events_url":"https://api.github.com/users/liqd/received_events","type":"Organization","site_admin":false},"repo":{"id":22982974,"name":"adhocracy3","full_name":"liqd/adhocracy3","owner":{"login":"liqd","id":2312088,"avatar_url":"https://avatars.githubusercontent.com/u/2312088?v=3","gravatar_id":"","url":"https://api.github.com/users/liqd","html_url":"https://github.com/liqd","followers_url":"https://api.github.com/users/liqd/followers","following_url":"https://api.github.com/users/liqd/following{/other_user}","gists_url":"https://api.github.com/users/liqd/gists{/gist_id}","starred_url":"https://api.github.com/users/liqd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liqd/subscriptions","organizations_url":"https://api.github.com/users/liqd/orgs","repos_url":"https://api.github.com/users/liqd/repos","events_url":"https://api.github.com/users/liqd/events{/privacy}","received_events_url":"https://api.github.com/users/liqd/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/liqd/adhocracy3","description":"Adhocracy 3 with customizations for various projects","fork":false,"url":"https://api.github.com/repos/liqd/adhocracy3","forks_url":"https://api.github.com/repos/liqd/adhocracy3/forks","keys_url":"https://api.github.com/repos/liqd/adhocracy3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liqd/adhocracy3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liqd/adhocracy3/teams","hooks_url":"https://api.github.com/repos/liqd/adhocracy3/hooks","issue_events_url":"https://api.github.com/repos/liqd/adhocracy3/issues/events{/number}","events_url":"https://api.github.com/repos/liqd/adhocracy3/events","assignees_url":"https://api.github.com/repos/liqd/adhocracy3/assignees{/user}","branches_url":"https://api.github.com/repos/liqd/adhocracy3/branches{/branch}","tags_url":"https://api.github.com/repos/liqd/adhocracy3/tags","blobs_url":"https://api.github.com/repos/liqd/adhocracy3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liqd/adhocracy3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liqd/adhocracy3/git/refs{/sha}","trees_url":"https://api.github.com/repos/liqd/adhocracy3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liqd/adhocracy3/statuses/{sha}","languages_url":"https://api.github.com/repos/liqd/adhocracy3/languages","stargazers_url":"https://api.github.com/repos/liqd/adhocracy3/stargazers","contributors_url":"https://api.github.com/repos/liqd/adhocracy3/contributors","subscribers_url":"https://api.github.com/repos/liqd/adhocracy3/subscribers","subscription_url":"https://api.github.com/repos/liqd/adhocracy3/subscription","commits_url":"https://api.github.com/repos/liqd/adhocracy3/commits{/sha}","git_commits_url":"https://api.github.com/repos/liqd/adhocracy3/git/commits{/sha}","comments_url":"https://api.github.com/repos/liqd/adhocracy3/comments{/number}","issue_comment_url":"https://api.github.com/repos/liqd/adhocracy3/issues/comments{/number}","contents_url":"https://api.github.com/repos/liqd/adhocracy3/contents/{+path}","compare_url":"https://api.github.com/repos/liqd/adhocracy3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liqd/adhocracy3/merges","archive_url":"https://api.github.com/repos/liqd/adhocracy3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liqd/adhocracy3/downloads","issues_url":"https://api.github.com/repos/liqd/adhocracy3/issues{/number}","pulls_url":"https://api.github.com/repos/liqd/adhocracy3/pulls{/number}","milestones_url":"https://api.github.com/repos/liqd/adhocracy3/milestones{/number}","notifications_url":"https://api.github.com/repos/liqd/adhocracy3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liqd/adhocracy3/labels{/name}","releases_url":"https://api.github.com/repos/liqd/adhocracy3/releases{/id}","deployments_url":"https://api.github.com/repos/liqd/adhocracy3/deployments","created_at":"2014-08-15T08:07:57Z","updated_at":"2016-04-16T09:36:11Z","pushed_at":"2016-04-25T17:53:16Z","git_url":"git://github.com/liqd/adhocracy3.git","ssh_url":"git@github.com:liqd/adhocracy3.git","clone_url":"https://github.com/liqd/adhocracy3.git","svn_url":"https://github.com/liqd/adhocracy3","homepage":"","size":23503,"stargazers_count":40,"watchers_count":40,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":94,"forks":13,"open_issues":94,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247"},"html":{"href":"https://github.com/liqd/adhocracy3/pull/2247"},"issue":{"href":"https://api.github.com/repos/liqd/adhocracy3/issues/2247"},"comments":{"href":"https://api.github.com/repos/liqd/adhocracy3/issues/2247/comments"},"review_comments":{"href":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247/comments"},"review_comment":{"href":"https://api.github.com/repos/liqd/adhocracy3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/liqd/adhocracy3/pulls/2247/commits"},"statuses":{"href":"https://api.github.com/repos/liqd/adhocracy3/statuses/f876794aae6ec1671149b039da907080b1460026"}}}}