{"action":"created","comment":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/103435793","pull_request_review_id":24219838,"id":103435793,"diff_hunk":"@@ -505,8 +530,96 @@ def can_be_private?\n     derived? ? user.try(:private_maps_enabled) : user.try(:private_tables_enabled)\n   end\n \n+  def store_using_table(table_privacy_changed = false)\n+    do_store(false, table_privacy_changed)\n+  end\n+\n+  # Backward compatibility with Sequel\n+  def store\n+    do_store\n+    self\n+  end\n+\n+  def is_owner?(user)\n+    user.id == user_id\n+  end\n+\n   private\n \n+  def do_store(_propagate_changes = true, _table_privacy_changed = false)\n+    save!\n+  end\n+\n+  def remove_password\n+    @password_salt = nil\n+    @encrypted_password = nil\n+  end\n+\n+  def perform_invalidations\n+    # previously we used 'invalidate_cache' but due to public_map displaying all the user public visualizations,\n+    # now we need to purgue everything to avoid cached stale data or public->priv still showing scenarios\n+    if privacy_changed? || name_changed? || dirty?\n+      invalidate_cache\n+    end\n+\n+    # When a table's relevant data is changed, propagate to all who use it or relate to it\n+    if dirty? && table\n+      user_table.dependent_visualizations.each(&:invalidate_cache)\n+    end\n+  end\n+\n+  def dirty?\n+    description_changed? || attributions_changed? || version_changed? || encrypted_password_changed?\n+  end\n+\n+  def propagate_privacy_and_name_to\n+    raise \"Empty table sent to Visualization::Member propagate_privacy_and_name_to()\" unless table\n+    propagate_privacy if privacy_changed? && canonical?\n+    propagate_name if name_changed?\n+  end\n+\n+  def propagate_privacy\n+    table.reload\n+    if table.privacy_text.casecmp(privacy) != 0 # privacy is different, case insensitive\n+      CartoDB::TablePrivacyManager.new(table).set_from_visualization(self).update_cdb_tablemetadata\n+    end\n+  end\n+\n+  # @param table Table\n+  def propagate_name\n+    table.reload # Needed to avoid double renames\n+    table.register_table_only = register_table_only\n+    table.name = name\n+    table.update(name: name)\n+    if name_changed?\n+      support_tables.rename(name_was, name, true, name_was)\n+    end\n+    self\n+  rescue => exception\n+    if name_changed? && !(exception.to_s =~ /relation.*does not exist/)\n+      revert_name_change(name_was)\n+    end\n+    raise CartoDB::InvalidMember.new(exception.to_s)\n+  end\n+\n+  def revert_name_change(previous_name)\n+    self.name = previous_name\n+    # store","path":"app/models/carto/visualization.rb","position":167,"original_position":167,"commit_id":"0217b80986c72307d9df50368acfa0da8b25793c","original_commit_id":"0217b80986c72307d9df50368acfa0da8b25793c","user":{"login":"juanignaciosl","id":932968,"avatar_url":"https://avatars.githubusercontent.com/u/932968?v=3","gravatar_id":"","url":"https://api.github.com/users/juanignaciosl","html_url":"https://github.com/juanignaciosl","followers_url":"https://api.github.com/users/juanignaciosl/followers","following_url":"https://api.github.com/users/juanignaciosl/following{/other_user}","gists_url":"https://api.github.com/users/juanignaciosl/gists{/gist_id}","starred_url":"https://api.github.com/users/juanignaciosl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juanignaciosl/subscriptions","organizations_url":"https://api.github.com/users/juanignaciosl/orgs","repos_url":"https://api.github.com/users/juanignaciosl/repos","events_url":"https://api.github.com/users/juanignaciosl/events{/privacy}","received_events_url":"https://api.github.com/users/juanignaciosl/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2017-02-28T11:44:28Z","updated_at":"2017-02-28T11:44:28Z","html_url":"https://github.com/CartoDB/cartodb/pull/11600#discussion_r103435793","pull_request_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600","_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments/103435793"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/11600#discussion_r103435793"},"pull_request":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600"}}},"pull_request":{"url":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600","id":107219083,"html_url":"https://github.com/CartoDB/cartodb/pull/11600","diff_url":"https://github.com/CartoDB/cartodb/pull/11600.diff","patch_url":"https://github.com/CartoDB/cartodb/pull/11600.patch","issue_url":"https://api.github.com/repos/CartoDB/cartodb/issues/11600","number":11600,"state":"open","locked":false,"title":"First steps for UserTable initialization after save [WIP]","user":{"login":"juanignaciosl","id":932968,"avatar_url":"https://avatars.githubusercontent.com/u/932968?v=3","gravatar_id":"","url":"https://api.github.com/users/juanignaciosl","html_url":"https://github.com/juanignaciosl","followers_url":"https://api.github.com/users/juanignaciosl/followers","following_url":"https://api.github.com/users/juanignaciosl/following{/other_user}","gists_url":"https://api.github.com/users/juanignaciosl/gists{/gist_id}","starred_url":"https://api.github.com/users/juanignaciosl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juanignaciosl/subscriptions","organizations_url":"https://api.github.com/users/juanignaciosl/orgs","repos_url":"https://api.github.com/users/juanignaciosl/repos","events_url":"https://api.github.com/users/juanignaciosl/events{/privacy}","received_events_url":"https://api.github.com/users/juanignaciosl/received_events","type":"User","site_admin":false},"body":" #11589","created_at":"2017-02-21T15:59:49Z","updated_at":"2017-02-28T11:44:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5fb87db15ed92b9b666b380f61a95cbfe8d834af","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600/commits","review_comments_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600/comments","review_comment_url":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/issues/11600/comments","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/0217b80986c72307d9df50368acfa0da8b25793c","head":{"label":"CartoDB:11589-UserTable_hooks_refactor","ref":"11589-UserTable_hooks_refactor","sha":"0217b80986c72307d9df50368acfa0da8b25793c","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Location Intelligence & Data Visualization tool","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/cartodb/deployments","created_at":"2012-07-05T15:23:45Z","updated_at":"2017-02-28T10:01:42Z","pushed_at":"2017-02-28T11:25:53Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"http://carto.com","size":347167,"stargazers_count":1402,"watchers_count":1402,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":387,"mirror_url":null,"open_issues_count":663,"forks":387,"open_issues":663,"watchers":1402,"default_branch":"master"}},"base":{"label":"CartoDB:master","ref":"master","sha":"56e8d055d721c286ed4d6f7eef14eb2c99c77bd2","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":4909355,"name":"cartodb","full_name":"CartoDB/cartodb","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb","description":"Location Intelligence & Data Visualization tool","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb","forks_url":"https://api.github.com/repos/CartoDB/cartodb/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb/releases{/id}","deployments_url":"https://api.github.com/repos/CartoDB/cartodb/deployments","created_at":"2012-07-05T15:23:45Z","updated_at":"2017-02-28T10:01:42Z","pushed_at":"2017-02-28T11:25:53Z","git_url":"git://github.com/CartoDB/cartodb.git","ssh_url":"git@github.com:CartoDB/cartodb.git","clone_url":"https://github.com/CartoDB/cartodb.git","svn_url":"https://github.com/CartoDB/cartodb","homepage":"http://carto.com","size":347167,"stargazers_count":1402,"watchers_count":1402,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":387,"mirror_url":null,"open_issues_count":663,"forks":387,"open_issues":663,"watchers":1402,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600"},"html":{"href":"https://github.com/CartoDB/cartodb/pull/11600"},"issue":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/11600"},"comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/issues/11600/comments"},"review_comments":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600/comments"},"review_comment":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CartoDB/cartodb/pulls/11600/commits"},"statuses":{"href":"https://api.github.com/repos/CartoDB/cartodb/statuses/0217b80986c72307d9df50368acfa0da8b25793c"}}}}
{"actor":{"display_login":"juanignaciosl"}}