Skip to content

Commit

Permalink
Show report and alerts to all users based on config
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-dbx committed Feb 13, 2024
1 parent 9699676 commit 9ecf5dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,8 @@ def EMAIL_HEADER_MUTATOR( # pylint: disable=invalid-name,unused-argument
ALERT_REPORTS_MIN_CUSTOM_SCREENSHOT_WIDTH = 600
ALERT_REPORTS_MAX_CUSTOM_SCREENSHOT_WIDTH = 2400

ALERT_REPORTS_READ_ONLY_FULL_ACCESS = False

# A custom prefix to use on all Alerts & Reports emails
EMAIL_REPORTS_SUBJECT_PREFIX = "[Report] "

Expand Down
9 changes: 8 additions & 1 deletion superset/reports/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@
from sqlalchemy import or_
from sqlalchemy.orm.query import Query

from superset import db, security_manager
from superset import app, db, security_manager
from superset.reports.models import ReportSchedule
from superset.views.base import BaseFilter


config = app.config


class ReportScheduleFilter(BaseFilter): # pylint: disable=too-few-public-methods
def apply(self, query: Query, value: Any) -> Query:
if security_manager.can_access_all_datasources():
return query

# show reports and alerts to all users regardless ownership
if config["ALERT_REPORTS_READ_ONLY_FULL_ACCESS"]:
return query
owner_ids_query = (
db.session.query(ReportSchedule.id)
.join(ReportSchedule.owners)
Expand Down

0 comments on commit 9ecf5dc

Please sign in to comment.