def cap_alert_list_layout(list_id, item_id, resource, rfields, record):

    record_id = record["cap_alert.id"]
    item_class = "thumbnail"

    T = current.T
    #raw = record._row
    # @ToDo: handle the case where we have multiple info segments &/or areas
    headline = record["cap_info.headline"]
    location = s3_str(record["cap_area.name"])
    priority = record["cap_info.priority"]
    status = record["cap_alert.status"]
    scope = record["cap_alert.scope"]
    event = record["cap_info.event_type_id"]

    if current.auth.s3_logged_in():
        _href = URL(c="cap", f="alert", args=[record_id, "profile"])
    else:
        _href = URL(c="cap", f="public", args=[record_id, "profile"])

    priority_row = None
    if priority and priority != "-":
        # Give the priority color to headline
        db = current.db
        wptable = db.cap_warning_priority
        priority_row = db(wptable.name == priority).select(wptable.color_code,
                                                           limitby=(0, 1)).first()

    more = A(T("Full Alert"),
             _href = _href,
             _target = "_blank",
             )

    if list_id == "map_popup":
        itable = current.s3db.cap_info
        # Map popup
        event = itable.event_type_id.represent(event)
        if priority is None:
            priority = T("Unknown")
        else:
            priority = itable.priority.represent(priority)
        description = record["cap_info.description"]
        response_type = record["cap_info.response_type"]
        sender = record["cap_info.sender_name"]
        last = TAG[""](BR(),
                       description,
                       BR(),
                       ", ".join(response_type),
                       BR(),
                       sender,
                       BR(),
                       )

        details = "%s %s %s" % (priority, status, scope)

        headline_ = A(headline,
                      _href = _href,
                      _target = "_blank",
                      )

        if priority_row:
            headline_["_style"] = "color: #%s" % (priority_row.color_code)

        item = DIV(headline_,
                   BR(),
                   location,
                   BR(),
                   details,
                   BR(),
                   event,
                   last,
                   more,
                   _class=item_class,
                   _id=item_id,
                   )
    else:
        if priority == current.messages["NONE"]:
            priority = T("Unknown")
        sender_name = record["cap_info.sender_name"]
        sent = record["cap_alert.sent"]

        headline = "%s" % (headline)

        sub_heading = "%s %s" % (priority, event)

        sub_headline = A(sub_heading,
                         _href = _href,
                         _target = "_blank",
                         )

        if priority_row:
            sub_headline["_style"] = "color: #%s" % (priority_row.color_code)

        para = T("%(status)s alert for %(area_description)s.") \
                % dict(status=status, area_description=location)

        issuer = "%s: %s" % (T("Issued by"), sender_name)
        issue_date = "%s: %s" % (T("Issued on"), sent)

        item = DIV(headline,
                   BR(),
                   para,
                   BR(),
                   sub_headline,
                   BR(),
                   issuer,
                   BR(),
                   issue_date,
                   BR(),
                   more,
                   _class=item_class,
                   _id=item_id,
                   )

    return item

# =============================================================================
Default dataList item renderer for CAP Alerts on the Home page.
dataset/ETHPy150Open sahana/eden/modules/s3db/cap.py/cap_alert_list_layout