You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/03/11 17:54:42 UTC

[GitHub] [incubator-superset] henry145145 commented on issue #9214: Allow admins to edit any chart

henry145145 commented on issue #9214: Allow admins to edit any chart
URL: https://github.com/apache/incubator-superset/issues/9214#issuecomment-597779461
 
 
   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
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org