{"action":"created","comment":{"url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/comments/34842585","id":34842585,"diff_hunk":"@@ -35,8 +36,71 @@ def popup_usage_restrictions():\n     return \"Enter instructions for what users can and cannot do with the data.\"\n \n class ExampleIDatasetFormPlugin(p.SingletonPlugin, tk.DefaultDatasetForm):\n-    p.implements(p.IDatasetForm)\n-    p.implements(p.IConfigurer)\n+\n+    p.implements(p.IResourceController)\n+    def before_create(self, context, resource):\n+        return\n+    def after_create(self, context, resource):\n+        # must have changed['format'] when you created the resource\n+        tk.redirect_to(controller='package',action='resource_edit',\n+                       resource_id=resource['id'],id=resource['package_id'])\n+\n+    def _control_datadict(self, resource):\n+        ''' delete and rebuild datadict'''\n+        record = resource.get('datadict','')\n+        if record:\n+            resource.pop('datadict', None)\n+            record = eval(record) \n+            ds.delete_datastore_json(resource['id'], 'name', 'datadict')\n+            ds.create_datastore_json(resource['id'], record, 'name', 'datadict') \n+            # print 'check datadict? ',  ds.print_datastore_json(resource['id'],'','') \n+        return\n+    def before_update(self, context, current, resource):\n+        # note keys that have changed (resource is new current is old)\n+        self.changed_keys = ['format', 'privacy_contains_pii']\n+        self.changed = {}\n+        for i in self.changed_keys:\n+            self.changed[i] = False\n+            if resource.get(i,'0') != current.get(i,'1'):\n+                print 'trigger a redirect in after_update: ', self.changed.get(i,'')\n+                self.changed[i] = True\n+        # mimic a new controller for data dictionary field\n+        if current.get('format','0') == 'Data Dictionary' and resource.get('format','1') == 'Data Dictionary':\n+            self._control_datadict(resource)\n+","path":"ckanext/cfpb_extrafields/plugin.py","position":null,"original_position":45,"commit_id":"381383330faf61e236bdf9872598729a0c6f0d02","original_commit_id":"a1c1562daba22bdfb260bd86147b49844d2851ee","user":{"login":"sleitner","id":2593347,"avatar_url":"https://avatars.githubusercontent.com/u/2593347?v=3","gravatar_id":"","url":"https://api.github.com/users/sleitner","html_url":"https://github.com/sleitner","followers_url":"https://api.github.com/users/sleitner/followers","following_url":"https://api.github.com/users/sleitner/following{/other_user}","gists_url":"https://api.github.com/users/sleitner/gists{/gist_id}","starred_url":"https://api.github.com/users/sleitner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleitner/subscriptions","organizations_url":"https://api.github.com/users/sleitner/orgs","repos_url":"https://api.github.com/users/sleitner/repos","events_url":"https://api.github.com/users/sleitner/events{/privacy}","received_events_url":"https://api.github.com/users/sleitner/received_events","type":"User","site_admin":false},"body":"awesome! just tweaked it to dictionary comprehension because I want to know whether each element changed:\r\nself.changed = {key: resource.get(key, '0') != current.get(key, '1') for key in ['format', 'privacy_contains_pii']}","created_at":"2015-07-16T21:57:07Z","updated_at":"2015-07-16T21:57:07Z","html_url":"https://github.com/cfpb/ckanext-cfpb-extrafields/pull/12#discussion_r34842585","pull_request_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/comments/34842585"},"html":{"href":"https://github.com/cfpb/ckanext-cfpb-extrafields/pull/12#discussion_r34842585"},"pull_request":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12","id":39692551,"html_url":"https://github.com/cfpb/ckanext-cfpb-extrafields/pull/12","diff_url":"https://github.com/cfpb/ckanext-cfpb-extrafields/pull/12.diff","patch_url":"https://github.com/cfpb/ckanext-cfpb-extrafields/pull/12.patch","issue_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/issues/12","number":12,"state":"open","locked":false,"title":"DSNs","user":{"login":"sleitner","id":2593347,"avatar_url":"https://avatars.githubusercontent.com/u/2593347?v=3","gravatar_id":"","url":"https://api.github.com/users/sleitner","html_url":"https://github.com/sleitner","followers_url":"https://api.github.com/users/sleitner/followers","following_url":"https://api.github.com/users/sleitner/following{/other_user}","gists_url":"https://api.github.com/users/sleitner/gists{/gist_id}","starred_url":"https://api.github.com/users/sleitner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleitner/subscriptions","organizations_url":"https://api.github.com/users/sleitner/orgs","repos_url":"https://api.github.com/users/sleitner/repos","events_url":"https://api.github.com/users/sleitner/events{/privacy}","received_events_url":"https://api.github.com/users/sleitner/received_events","type":"User","site_admin":false},"body":"Adding first-pass at downloadable files used by applications to open specific locations (a table in a database for example). This should be merged after the resource rewrite PR.","created_at":"2015-07-10T15:02:20Z","updated_at":"2015-07-16T21:57:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d2e7919c2ebfbf955ea6c1e6a3df93c37491844","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12/commits","review_comments_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12/comments","review_comment_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/issues/12/comments","statuses_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/statuses/381383330faf61e236bdf9872598729a0c6f0d02","head":{"label":"sleitner:dsn","ref":"dsn","sha":"381383330faf61e236bdf9872598729a0c6f0d02","user":{"login":"sleitner","id":2593347,"avatar_url":"https://avatars.githubusercontent.com/u/2593347?v=3","gravatar_id":"","url":"https://api.github.com/users/sleitner","html_url":"https://github.com/sleitner","followers_url":"https://api.github.com/users/sleitner/followers","following_url":"https://api.github.com/users/sleitner/following{/other_user}","gists_url":"https://api.github.com/users/sleitner/gists{/gist_id}","starred_url":"https://api.github.com/users/sleitner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleitner/subscriptions","organizations_url":"https://api.github.com/users/sleitner/orgs","repos_url":"https://api.github.com/users/sleitner/repos","events_url":"https://api.github.com/users/sleitner/events{/privacy}","received_events_url":"https://api.github.com/users/sleitner/received_events","type":"User","site_admin":false},"repo":{"id":34133130,"name":"ckanext-cfpb-extrafields","full_name":"sleitner/ckanext-cfpb-extrafields","owner":{"login":"sleitner","id":2593347,"avatar_url":"https://avatars.githubusercontent.com/u/2593347?v=3","gravatar_id":"","url":"https://api.github.com/users/sleitner","html_url":"https://github.com/sleitner","followers_url":"https://api.github.com/users/sleitner/followers","following_url":"https://api.github.com/users/sleitner/following{/other_user}","gists_url":"https://api.github.com/users/sleitner/gists{/gist_id}","starred_url":"https://api.github.com/users/sleitner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sleitner/subscriptions","organizations_url":"https://api.github.com/users/sleitner/orgs","repos_url":"https://api.github.com/users/sleitner/repos","events_url":"https://api.github.com/users/sleitner/events{/privacy}","received_events_url":"https://api.github.com/users/sleitner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sleitner/ckanext-cfpb-extrafields","description":"","fork":true,"url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields","forks_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/forks","keys_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/teams","hooks_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/hooks","issue_events_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/issues/events{/number}","events_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/events","assignees_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/assignees{/user}","branches_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/branches{/branch}","tags_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/tags","blobs_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/git/refs{/sha}","trees_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/statuses/{sha}","languages_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/languages","stargazers_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/stargazers","contributors_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/contributors","subscribers_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/subscribers","subscription_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/subscription","commits_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/commits{/sha}","git_commits_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/git/commits{/sha}","comments_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/comments{/number}","issue_comment_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/issues/comments{/number}","contents_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/contents/{+path}","compare_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/merges","archive_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/downloads","issues_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/issues{/number}","pulls_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/pulls{/number}","milestones_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/milestones{/number}","notifications_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/labels{/name}","releases_url":"https://api.github.com/repos/sleitner/ckanext-cfpb-extrafields/releases{/id}","created_at":"2015-04-17T18:27:39Z","updated_at":"2015-07-16T15:13:00Z","pushed_at":"2015-07-16T21:17:06Z","git_url":"git://github.com/sleitner/ckanext-cfpb-extrafields.git","ssh_url":"git@github.com:sleitner/ckanext-cfpb-extrafields.git","clone_url":"https://github.com/sleitner/ckanext-cfpb-extrafields.git","svn_url":"https://github.com/sleitner/ckanext-cfpb-extrafields","homepage":"https://github.com","size":507,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"base":{"label":"cfpb:master","ref":"master","sha":"9f14fafcbde79341cd24d7aa4427ccd4d1be257a","user":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"repo":{"id":32742657,"name":"ckanext-cfpb-extrafields","full_name":"cfpb/ckanext-cfpb-extrafields","owner":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cfpb/ckanext-cfpb-extrafields","description":"","fork":false,"url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields","forks_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/forks","keys_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/teams","hooks_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/hooks","issue_events_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/issues/events{/number}","events_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/events","assignees_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/assignees{/user}","branches_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/branches{/branch}","tags_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/tags","blobs_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/statuses/{sha}","languages_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/languages","stargazers_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/stargazers","contributors_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/contributors","subscribers_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/subscribers","subscription_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/subscription","commits_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/contents/{+path}","compare_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/merges","archive_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/downloads","issues_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/issues{/number}","pulls_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls{/number}","milestones_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/milestones{/number}","notifications_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/labels{/name}","releases_url":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/releases{/id}","created_at":"2015-03-23T15:58:47Z","updated_at":"2015-07-11T17:52:31Z","pushed_at":"2015-07-16T21:17:06Z","git_url":"git://github.com/cfpb/ckanext-cfpb-extrafields.git","ssh_url":"git@github.com:cfpb/ckanext-cfpb-extrafields.git","clone_url":"https://github.com/cfpb/ckanext-cfpb-extrafields.git","svn_url":"https://github.com/cfpb/ckanext-cfpb-extrafields","homepage":"https://github.com","size":868,"stargazers_count":2,"watchers_count":2,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":3,"forks":3,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12"},"html":{"href":"https://github.com/cfpb/ckanext-cfpb-extrafields/pull/12"},"issue":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/issues/12"},"comments":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/cfpb/ckanext-cfpb-extrafields/statuses/381383330faf61e236bdf9872598729a0c6f0d02"}}}}