{"action":"created","comment":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/127021669","pull_request_review_id":49564544,"id":127021669,"diff_hunk":"@@ -2,13 +2,32 @@\n import json\n import logging\n \n+from contextlib import contextmanager\n+\n from website import settings\n from osf.models import NodeLicense, MetaSchema\n from website.project.metadata.schemas import OSF_META_SCHEMAS\n \n logger = logging.getLogger(__file__)\n \n \n+@contextmanager\n+def disable_auto_now_fields(model):\n+    \"\"\"\n+    Context manager to disable updates of all auto_now fields for a given model.\n+\n+    \"\"\"\n+    for field in model._meta.get_fields():\n+        if hasattr(field, 'auto_now') and field.auto_now:","path":"osf/utils/migrations.py","position":20,"original_position":20,"commit_id":"8604010b94bdcd882c39fcde3e047a24e6ffc80b","original_commit_id":"8604010b94bdcd882c39fcde3e047a24e6ffc80b","user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars1.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"body":"No, let's only disable `auto_now` fields for now.","created_at":"2017-07-12T17:38:48Z","updated_at":"2017-07-12T17:38:48Z","html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7454#discussion_r127021669","pull_request_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454","_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments/127021669"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7454#discussion_r127021669"},"pull_request":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454"}}},"pull_request":{"url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454","id":130163417,"html_url":"https://github.com/CenterForOpenScience/osf.io/pull/7454","diff_url":"https://github.com/CenterForOpenScience/osf.io/pull/7454.diff","patch_url":"https://github.com/CenterForOpenScience/osf.io/pull/7454.patch","issue_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7454","number":7454,"state":"open","locked":false,"title":"Add context manager for disabling auto_now updates.","user":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars3.githubusercontent.com/u/7913604?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"body":"#### Purpose\r\n- Adds a context manager to prevent `auto_now` fields from being updated during migrations and scripts.\r\n\r\n#### Changes\r\n- Adds `disable_auto_now_fields` context manager and test in `test_utils.py`. \r\n\r\n#### Side Effects\r\n- None expected.\r\n\r\n#### Ticket\r\n- [OSF-8222](https://openscience.atlassian.net/browse/OSF-8222)\r\n","created_at":"2017-07-12T15:08:24Z","updated_at":"2017-07-12T17:38:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59bb175fe8dd0360a4e98b6b9262c9569c32876b","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454/commits","review_comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454/comments","review_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7454/comments","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/8604010b94bdcd882c39fcde3e047a24e6ffc80b","head":{"label":"caseyrollins:feature/disable-auto-now","ref":"feature/disable-auto-now","sha":"8604010b94bdcd882c39fcde3e047a24e6ffc80b","user":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars3.githubusercontent.com/u/7913604?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"repo":{"id":26963858,"name":"osf.io","full_name":"caseyrollins/osf.io","owner":{"login":"caseyrollins","id":7913604,"avatar_url":"https://avatars3.githubusercontent.com/u/7913604?v=3","gravatar_id":"","url":"https://api.github.com/users/caseyrollins","html_url":"https://github.com/caseyrollins","followers_url":"https://api.github.com/users/caseyrollins/followers","following_url":"https://api.github.com/users/caseyrollins/following{/other_user}","gists_url":"https://api.github.com/users/caseyrollins/gists{/gist_id}","starred_url":"https://api.github.com/users/caseyrollins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caseyrollins/subscriptions","organizations_url":"https://api.github.com/users/caseyrollins/orgs","repos_url":"https://api.github.com/users/caseyrollins/repos","events_url":"https://api.github.com/users/caseyrollins/events{/privacy}","received_events_url":"https://api.github.com/users/caseyrollins/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/caseyrollins/osf.io","description":"Facilitating Open Science","fork":true,"url":"https://api.github.com/repos/caseyrollins/osf.io","forks_url":"https://api.github.com/repos/caseyrollins/osf.io/forks","keys_url":"https://api.github.com/repos/caseyrollins/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caseyrollins/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caseyrollins/osf.io/teams","hooks_url":"https://api.github.com/repos/caseyrollins/osf.io/hooks","issue_events_url":"https://api.github.com/repos/caseyrollins/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/caseyrollins/osf.io/events","assignees_url":"https://api.github.com/repos/caseyrollins/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/caseyrollins/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/caseyrollins/osf.io/tags","blobs_url":"https://api.github.com/repos/caseyrollins/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caseyrollins/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caseyrollins/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/caseyrollins/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caseyrollins/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/caseyrollins/osf.io/languages","stargazers_url":"https://api.github.com/repos/caseyrollins/osf.io/stargazers","contributors_url":"https://api.github.com/repos/caseyrollins/osf.io/contributors","subscribers_url":"https://api.github.com/repos/caseyrollins/osf.io/subscribers","subscription_url":"https://api.github.com/repos/caseyrollins/osf.io/subscription","commits_url":"https://api.github.com/repos/caseyrollins/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/caseyrollins/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/caseyrollins/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/caseyrollins/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/caseyrollins/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/caseyrollins/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caseyrollins/osf.io/merges","archive_url":"https://api.github.com/repos/caseyrollins/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caseyrollins/osf.io/downloads","issues_url":"https://api.github.com/repos/caseyrollins/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/caseyrollins/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/caseyrollins/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/caseyrollins/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caseyrollins/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/caseyrollins/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/caseyrollins/osf.io/deployments","created_at":"2014-11-21T14:49:09Z","updated_at":"2016-01-20T14:34:47Z","pushed_at":"2017-07-12T16:20:35Z","git_url":"git://github.com/caseyrollins/osf.io.git","ssh_url":"git@github.com:caseyrollins/osf.io.git","clone_url":"https://github.com/caseyrollins/osf.io.git","svn_url":"https://github.com/caseyrollins/osf.io","homepage":"http://osf.io","size":154360,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"CenterForOpenScience:develop","ref":"develop","sha":"056d7d0e007ca9fc2928bc346480c2faf6d9551a","user":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars2.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"repo":{"id":10199599,"name":"osf.io","full_name":"CenterForOpenScience/osf.io","owner":{"login":"CenterForOpenScience","id":3344584,"avatar_url":"https://avatars2.githubusercontent.com/u/3344584?v=3","gravatar_id":"","url":"https://api.github.com/users/CenterForOpenScience","html_url":"https://github.com/CenterForOpenScience","followers_url":"https://api.github.com/users/CenterForOpenScience/followers","following_url":"https://api.github.com/users/CenterForOpenScience/following{/other_user}","gists_url":"https://api.github.com/users/CenterForOpenScience/gists{/gist_id}","starred_url":"https://api.github.com/users/CenterForOpenScience/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CenterForOpenScience/subscriptions","organizations_url":"https://api.github.com/users/CenterForOpenScience/orgs","repos_url":"https://api.github.com/users/CenterForOpenScience/repos","events_url":"https://api.github.com/users/CenterForOpenScience/events{/privacy}","received_events_url":"https://api.github.com/users/CenterForOpenScience/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CenterForOpenScience/osf.io","description":"Facilitating Open Science","fork":false,"url":"https://api.github.com/repos/CenterForOpenScience/osf.io","forks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/forks","keys_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/teams","hooks_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/hooks","issue_events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/events{/number}","events_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/events","assignees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/assignees{/user}","branches_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/branches{/branch}","tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/tags","blobs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/{sha}","languages_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/languages","stargazers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/stargazers","contributors_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contributors","subscribers_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscribers","subscription_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/subscription","commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/contents/{+path}","compare_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/merges","archive_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/downloads","issues_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues{/number}","pulls_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls{/number}","milestones_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/milestones{/number}","notifications_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/labels{/name}","releases_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/releases{/id}","deployments_url":"https://api.github.com/repos/CenterForOpenScience/osf.io/deployments","created_at":"2013-05-21T15:53:37Z","updated_at":"2017-07-11T00:41:03Z","pushed_at":"2017-07-12T17:24:12Z","git_url":"git://github.com/CenterForOpenScience/osf.io.git","ssh_url":"git@github.com:CenterForOpenScience/osf.io.git","clone_url":"https://github.com/CenterForOpenScience/osf.io.git","svn_url":"https://github.com/CenterForOpenScience/osf.io","homepage":"https://osf.io","size":156157,"stargazers_count":348,"watchers_count":348,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":228,"mirror_url":null,"open_issues_count":232,"forks":228,"open_issues":232,"watchers":348,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454"},"html":{"href":"https://github.com/CenterForOpenScience/osf.io/pull/7454"},"issue":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7454"},"comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/issues/7454/comments"},"review_comments":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454/comments"},"review_comment":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/pulls/7454/commits"},"statuses":{"href":"https://api.github.com/repos/CenterForOpenScience/osf.io/statuses/8604010b94bdcd882c39fcde3e047a24e6ffc80b"}}}}
{"actor":{"display_login":"sloria"}}