'Update the approved_on field when alert gets approved'

@staticmethod
def cap_alert_approve(record=None):

    if (not record):
        return
    alert_id = record['id']
    if alert_id:
        db = current.db
        approved_on = record['approved_on']
        table = db.cap_alert
        query = (table.id == alert_id)
        utcnow = current.request.utcnow
        db(query).update(approved_on=utcnow, sent=utcnow)
        row = db(query).select(table.owned_by_user, limitby=(0, 1)).first()
        if row.owned_by_user:
            settings = current.deployment_settings
            pe_id = current.auth.s3_user_pe_id(int(row.owned_by_user))
            subject = ('%s:    Alert    Approved' % settings.get_system_name_short())
            url = ('%s%s' % (settings.get_base_public_url(), URL(c='cap', f='alert', args=[alert_id])))
            message = (current.T('This    alert    that    you    requested    to    review    has    been    approved:\n\n%s') % url)
            current.msg.send_by_pe_id(pe_id, subject, message)
        clone(current.request, record)
