def render_buttons(self, r, buttons, record_id=None, **attr):
        """
            Render CRUD buttons

            @param r: the S3Request
            @param buttons: list of button names, any of:
                            "add", "edit", "delete", "list", "summary"
            @param record_id: the record ID
            @param attr: the controller attributes

            @return: a dict of buttons for the view
        """

        output = {}
        custom_crud_buttons = attr.get("custom_crud_buttons", {})

        tablename = self.tablename
        representation = r.representation

        url = r.url

        remove_filters = self._remove_filters
        crud_string = self.crud_string
        config = self._config
        crud_button = self.crud_button

        # Add button
        if "add" in buttons and config("insertable", True):
            ADD_BTN = "add_btn"
            authorised = self._permitted(method="create")
            if authorised:
                if ADD_BTN in custom_crud_buttons:
                    btn = crud_button(custom=custom_crud_buttons[ADD_BTN])
                else:
                    label = crud_string(tablename, "label_create")
                    _href = url(method="create",
                                representation=representation)
                    btn = crud_button(label=label,
                                      icon="add",
                                      _href=_href,
                                      _id="add-btn")
                output[ADD_BTN] = btn

        # List button
        if "list" in buttons:
            LIST_BTN = "list_btn"
            if not r.component or r.component.multiple:
                if LIST_BTN in custom_crud_buttons:
                    btn = crud_button(custom=custom_crud_buttons[LIST_BTN])
                else:
                    label = crud_string(tablename, "label_list_button")
                    _href = url(method="",
                                id=r.id if r.component else 0,
                                vars=remove_filters(r.get_vars),
                                representation=representation)
                    btn = crud_button(label=label,
                                      icon="list",
                                      _href=_href,
                                      _id="list-btn")
                output[LIST_BTN] = btn

        # Summary button
        if "summary" in buttons:
            SUMMARY_BTN = "summary_btn"
            if not r.component or r.component.multiple:
                if SUMMARY_BTN in custom_crud_buttons:
                    btn = crud_button(custom=custom_crud_buttons[SUMMARY_BTN])
                else:
                    label = crud_string(tablename, "label_list_button")
                    _href = url(method="summary",
                                id=0,
                                vars=remove_filters(r.get_vars),
                                representation=representation)
                    btn = crud_button(label=label,
                                      icon="list",
                                      _href=_href,
                                      _id="summary-btn")
                output[SUMMARY_BTN] = btn

        if not record_id:
            return output

        # Edit button
        if "edit" in buttons and config("editable", True):
            EDIT_BTN = "edit_btn"
            authorised = self._permitted(method="update")
            if authorised:
                if EDIT_BTN in custom_crud_buttons:
                    btn = crud_button(custom=custom_crud_buttons[EDIT_BTN])
                else:
                    label = current.messages.UPDATE
                    _href = url(method="update",
                                representation=representation)
                    btn = crud_button(label=label,
                                      icon="edit",
                                      _href=_href,
                                      _id="edit-btn")
                output[EDIT_BTN] = btn

        # Delete button
        if "delete" in buttons and config("deletable", True):
            DELETE_BTN = "delete_btn"
            authorised = self._permitted(method="delete")
            if authorised:
                if DELETE_BTN in custom_crud_buttons:
                    btn = crud_button(custom=custom_crud_buttons[DELETE_BTN])
                else:
                    label = crud_string(tablename, "label_delete_button")
                    _href = url(method="delete",
                                representation=representation)
                    btn = crud_button(label=label,
                                      icon="delete",
                                      _href=_href,
                                      _id="delete-btn",
                                      _class="delete-btn")
                output[DELETE_BTN] = btn

        return output

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3crud.py/S3CRUD.render_buttons/original