Package Camelot :: Package camelot :: Package admin :: Package form_action |
[frames] | no frames]

# Package form_action

source code

Form actions are objects that can be put in the form_actions list of the object admin interfaces. Those actions then appear on the form and can be executed by the end users. The most convenient method to create custom actions is to subclass FormAction and implement a custom run method

    class MyAction(FormAction):

      def run(self, entity_getter):
        print 'Hello World'

    class Movie(Entity):
      title = Field(Unicode(60), required=True)

      Admin(EntityAdmin):
        list_display = ['title']
        form_actions = [MyAction('Hello')]

Several subclasses of FormAction exist to provide common use cases such as executing a function in the model thread or printing a report.

To customize the look of the action button on the form, the render method should be overwritten.

Classes
| FormAction Abstract base class to implement form actions
| FormActionFromGuiFunction Convert a function that is supposed to run in the GUI thread to a FormAction, or
| FormActionProgressDialog
| FormActionFromModelFunction Convert a function that is supposed to run in the model thread to a FormAction.
| PrintHtmlFormAction Create an action for a form that pops up a print preview for generated html.
| DocxFormAction Action that generates a .docx file and opens it. It does so by generating an xml document with jinja templates that is a valid word document.

Functions
structure_to_form_actions(structure) Convert a list of python objects to a list of form actions. If the python object is a tuple, a FormActionFromGuiFunction is constructed with this tuple as arguments. If the python object is an instance of a FormAction, it is kept as is. | source code

Variables
| __package__ = ``'``Camelot.camelot.admin.form_action``'``