Dialog API
DontManage provides a group of standard, interactive and flexible dialogs that are easy to configure and use. There's also a more extensive API for Javascript.
dontmanage.msgprint
dontmanage.msgprint(msg, title, raise_exception, as_table, as_list, indicator, primary_action)
This method works only within a request / response cycle. It shows a message to the user logged in to Desk who initiated the request.
The argument list includes:
msg: The message to be displayedtitle: Title of the modalas_table: Ifmsgis a list of lists, render as HTML tableas_list: Ifmsgis a list, render as HTML unordered listprimary_action: Bind a primary server/client side action.raise_exception: Exception
dontmanage.msgprint(
msg='This file does not exist',
title='Error',
raise_exception=FileNotFoundError
)
dontmanage.msgprint
primary_action can contain a server_action or client_side action which must contain dotted paths to the respective methods. The JavaScript function must be a globally available function. You can also pass hide_on_success to close the message after the action is successfully completed.
# msgprint with server and client side action
dontmanage.msgprint(msg='This file does not exist',
title='Error',
raise_exception=FileNotFoundError
primary_action={
'label': _('Perform Action'),
'server_action': 'dotted.path.to.server.method',
'client_action': 'dotted.path.to.client.method',
'hide_on_success': True,
'args': args
}
)
dontmanage.msgprint with primary action
dontmanage.throw
dontmanage.throw(msg, exc, title)
This method will raise an exception as well as show a message in Desk. It is essentially a wrapper around dontmanage.msgprint.
exc can be passed an optional exception. By default it will raise a ValidationError exception.
dontmanage.throw(
title='Error',
msg='This file does not exist',
exc=FileNotFoundError
)
dontmanage.throw