def email_channel():
    """
        RESTful CRUD controller for Inbound Email channels

        @ToDo: Allow selection of a specific Channel for Alerts
    """

    def prep(r):
        table = r.table
        tablename = "msg_email_channel"
        s3db.configure(tablename,
                       deletable = False,
                       )

        if not r.id:
            # Have we got a channel defined?
            query = (table.deleted == False) & \
                    (table.enabled == True)
            organisation_id = auth.user.organisation_id
            if organisation_id:
                query &= ((table.organisation_id == organisation_id) | \
                          (table.organisation_id == None))
            channels = db(query).select(table.id,
                                        table.organisation_id,
                                        )
            if organisation_id and 1 > len(channels):
                _channels = channels.find(lambda row: row.organisation_id == organisation_id)
                if not _channels:
                    _channels = channels.find(lambda row: row.organisation_id == None)
                record = _channels.first()
            else:
                record = channels.first()

            if record:
                r.id = record.id
                r.method = "update"
            else:
                r.method = "create"

        if r.interactive:
            table.server.label = T("Server")
            table.protocol.label = T("Protocol")
            table.use_ssl.label = "SSL"
            table.port.label = T("Port")
            table.username.label = T("Username")
            table.password.label = T("Password")
            table.delete_from_server.label = T("Delete from Server?")
            table.port.comment = DIV(_class="tooltip",
                                     _title="%s|%s" % (T("Port"),
                                                       T("For POP-3 this is usually 110 (995 for SSL), for IMAP this is usually 143 (993 for IMAP).")))
            table.delete_from_server.comment = DIV(_class="tooltip",
                                                   _title="%s|%s" % (T("Delete"),
                                                                     T("If this is set to True then mails will be deleted from the server after downloading.")))

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

        return True
    s3.prep = prep

    def postp(r, output):
        if r.interactive and isinstance(output, dict) and \
           not s3task._is_alive():
            poll_btn = A(T("Poll"),
                         _class="action-btn",
                         _href=URL(args=[r.id, "poll"])
                         )
            output["rheader"] = poll_btn
        return output
    s3.postp = postp

    return s3_rest_controller("msg")

# -----------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/controllers/deploy.py/email_channel/swapped operands of `>`