'On-accept routine for dashboard configurations
- make sure there is at most one active config for the same
controller/function'

@staticmethod
def dashboard_onaccept(form):

    db = current.db
    try:
        record_id = form.vars.id
    except AttributeError:
        return
    table = current.s3db.s3_dashboard
    query = (table.id == record_id)
    row = db(query).select(table.id, table.controller, table.function, table.active, limitby=(0, 1)).first()
    if (not row):
        return
    if row.active:
        query = (((((table.controller == row.controller) & (table.function == row.function)) & (table.id != row.id)) & (table.active == True)) & (table.deleted != True))
        db(query).update(active=False)
