def email_inbox():

    if not auth.s3_logged_in():
        session.error = T("Requires Login!")
        redirect(URL(c="default", f="user", args="login"))

    s3.filter = (FS("inbound") == True)

    from s3 import S3SQLCustomForm, S3SQLInlineComponent
    crud_form = S3SQLCustomForm("date",
                                "subject",
                                "from_address",
                                "body",
                                S3SQLInlineComponent(
                                    "attachment",
                                    name = "document_id",
                                    label = T("Attachments"),
                                    fields = ["document_id",
                                              ],
                                    ),
                                )

    tablename = "msg_email"

    # CRUD Strings
    s3.crud_strings[tablename] = Storage(
        title_display = T("Email Details"),
        title_list = T("Email InBox"),
        label_list_button = T("View Email InBox"),
        label_delete_button = T("Delete Email"),
        msg_record_deleted = T("Email deleted"),
        msg_list_empty = T("No Emails currently in InBox")
    )

    s3db.configure(tablename,
                   crud_form = crud_form,
                   # Permissions-based
                   #deletable = False,
                   editable = False,
                   insertable = False,
                   list_fields = ["id",
                                  "date",
                                  "from_address",
                                  "subject",
                                  "body",
                                  (T("Attachments"), "attachment.document_id"),
                                  ],
                   )

    def prep(r):
        s3db.msg_email.inbound.readable = False
        if r.id:
            s3db.msg_attachment.document_id.label = ""
        return True
    s3.prep = prep

    return s3_rest_controller(module, "email")

# =============================================================================
RESTful CRUD controller for the Email Inbox
dataset/ETHPy150Open sahana/eden/controllers/msg.py/email_inbox