superset icon indicating copy to clipboard operation
superset copied to clipboard

Allow admins to edit any chart

Open sb2nov opened this issue 6 years ago • 2 comments

We've someone in the organization that created a chart and added it to a dashboard. As an admin I don't have permissions by default to overwrite this chart.

Is there a way to give admins ability to edit any chart ?

sb2nov avatar Feb 26 '20 23:02 sb2nov

can try to look into "@expose("/explore/<datasource_type>/<datasource_id>/", methods=["GET", "POST"])" in views/core.py . You can customize your "can_overwrite" here

ref: https://github.com/apache/incubator-superset/blob/master/superset/views/core.py

comment out line 861 to 865

if action == "overwrite" and not slice_overwrite_perm:
            return json_error_response(
                _("You don't have the rights to ") + _("alter this ") + _("chart"),
                status=400,
            )

add something at line 888 and change the bootstrap little bit

user_role_s = [role.name.lower() for role in list(get_user_roles())]
can_ow = True if "admin" in user_role_s else slice_overwrite_perm
bootstrap_data = {
            "can_add": slice_add_perm,
            "can_download": slice_download_perm,
            "can_overwrite": can_ow,
            "datasource": datasource.data,
            "form_data": form_data,
            "datasource_id": datasource_id,
            "datasource_type": datasource_type,
            "slice": slc.data if slc else None,
            "standalone": standalone,
            "user_id": user_id,
            "forced_height": request.args.get("height"),
            "common": common_bootstrap_payload(),
        }

then, inside def save_or_overwrite_slice, right before the response (line 1030) can add something like

        user_role_s = [role.name.lower() for role in list(get_user_roles())]
        can_ow = True if "admin" in user_role_s else slice_overwrite_perm

        response = {
            "can_add": slice_add_perm,
            "can_download": slice_download_perm,
            "can_overwrite": can_ow,
            "form_data": slc.form_data,
            "slice": slc.data,
            "dashboard_id": dash.id if dash else None,
        }

Hope this help

henry145145 avatar Mar 11 '20 17:03 henry145145

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar May 10 '20 18:05 stale[bot]