def facebook_channel():

    if not auth.s3_has_role(ADMIN):
        session.error = ERROR.UNAUTHORISED
        redirect(URL(f="index"))

    tablename = "msg_facebook_channel"
    table = s3db[tablename]

    # CRUD Strings
    s3.crud_strings[tablename] = Storage(
        title_display = T("Facebook Settings"),
        title_list = T("Facebook Accounts"),
        label_create = T("Add Facebook Account"),
        title_update = T("Edit Facebook Settings"),
        label_list_button = T("View Facebook Accounts"),
        msg_record_created = T("Account added"),
        msg_record_deleted = T("Facebook Account deleted"),
        msg_list_empty = T("No Accounts currently defined"),
        msg_record_modified = T("Facebook Settings updated")
        )

    def postp(r, output):
        if r.interactive:
            # Normal Action Buttons
            s3_action_buttons(r)
            # Custom Action Buttons for Enable/Disable
            table = r.table
            query = (table.deleted == False)
            rows = db(query).select(table.id,
                                    table.enabled,
                                    )
            restrict_e = [str(row.id) for row in rows if not row.enabled]
            restrict_d = [str(row.id) for row in rows if row.enabled]

            from s3 import s3_str
            s3.actions += [dict(label=s3_str(T("Enable")),
                                _class="action-btn",
                                url=URL(args=["[id]", "enable"]),
                                restrict = restrict_e),
                           dict(label=s3_str(T("Disable")),
                                _class="action-btn",
                                url = URL(args = ["[id]", "disable"]),
                                restrict = restrict_d),
                           ]
            #if not s3task._is_alive():
            #    # No Scheduler Running
            #    s3.actions += [dict(label=s3_str(T("Poll")),
            #                        _class="action-btn",
            #                        url = URL(args = ["[id]", "poll"]),
            #                        restrict = restrict_d)
            #                   ]
        return output
    s3.postp = postp

    return s3_rest_controller()

# -----------------------------------------------------------------------------
RESTful CRUD controller for Facebook channels
dataset/ETHPy150Open sahana/eden/controllers/msg.py/facebook_channel