Skip to content

Commit

Permalink
fix: don't check permissions in v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Nov 9, 2024
1 parent 015e213 commit c351825
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
11 changes: 1 addition & 10 deletions insights/api/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

from insights.api.permissions import is_private
from insights.decorators import insights_whitelist, validate_type
from insights.insights.doctype.insights_team.insights_team import (
get_allowed_resources_for_user,
get_permission_filter,
)


@insights_whitelist()
def get_dashboard_list():
dashboards = frappe.get_list(
"Insights Dashboard",
filters={**get_permission_filter("Insights Dashboard")},
fields=["name", "title", "modified", "_liked_by"],
)
for dashboard in dashboards:
Expand Down Expand Up @@ -54,10 +49,6 @@ def create_dashboard(title):

@insights_whitelist()
def get_dashboard_options(chart):
allowed_dashboards = get_allowed_resources_for_user("Insights Dashboard")
if not allowed_dashboards:
return []

# find all dashboards that don't have the chart within the allowed dashboards
Dashboard = frappe.qb.DocType("Insights Dashboard")
DashboardItem = frappe.qb.DocType("Insights Dashboard Item")
Expand All @@ -67,7 +58,7 @@ def get_dashboard_options(chart):
.left_join(DashboardItem)
.on(Dashboard.name == DashboardItem.parent)
.select(Dashboard.name.as_("value"), Dashboard.title.as_("label"))
.where(Dashboard.name.isin(allowed_dashboards) & (DashboardItem.chart != chart))
.where(DashboardItem.chart != chart)
.groupby(Dashboard.name)
.run(as_dict=True)
)
Expand Down
8 changes: 0 additions & 8 deletions insights/api/queries.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import frappe

from insights.decorators import insights_whitelist
from insights.insights.doctype.insights_team.insights_team import (
get_allowed_resources_for_user,
)


@insights_whitelist()
def get_queries():
allowed_queries = get_allowed_resources_for_user("Insights Query")
if not allowed_queries:
return []

Query = frappe.qb.DocType("Insights Query")
QueryChart = frappe.qb.DocType("Insights Chart")
DataSource = frappe.qb.DocType("Insights Data Source")
Expand Down Expand Up @@ -39,7 +32,6 @@ def get_queries():
QueryChart.chart_type,
DataSource.title.as_("data_source_title"),
)
.where(Query.name.isin(allowed_queries))
.groupby(
Query.name,
User.full_name.as_("owner_name"),
Expand Down

0 comments on commit c351825

Please sign in to comment.