NativeQuerySnippets have different permissions implementations. In Metabase CE, anyone can read/edit/create all NativeQuerySnippets if they have native query perms for at least one database. EE has a more advanced implementation. | (ns metabase.models.native-query-snippet.permissions (:require [metabase.api.common :as api] [metabase.models.data-permissions :as data-perms] [metabase.public-settings.premium-features :refer [defenterprise]])) |
Checks whether the current user has native query permissions for any database. | (defn has-any-native-permissions? [] (data-perms/user-has-any-perms-of-type? api/*current-user-id* :perms/create-queries)) |
Can the current User read this | (defenterprise can-read? metabase-enterprise.snippet-collections.models.native-query-snippet.permissions ([_] (has-any-native-permissions?)) ([_ _] (has-any-native-permissions?))) |
Can the current User edit this | (defenterprise can-write? metabase-enterprise.snippet-collections.models.native-query-snippet.permissions ([_] (has-any-native-permissions?)) ([_ _] (has-any-native-permissions?))) |
Can the current User save a new Snippet with the values in | (defenterprise can-create? metabase-enterprise.snippet-collections.models.native-query-snippet.permissions [_ _] (has-any-native-permissions?)) |
Can the current User apply a map of | (defenterprise can-update? metabase-enterprise.snippet-collections.models.native-query-snippet.permissions [_ _] (has-any-native-permissions?)) |