Admin class specific for classes that are mapped by sqlalchemy. This allows for much more introspection than the standard camelot.admin.object_admin.ObjectAdmin.
It has additional class attributes that customise its behaviour.
Basic
The camelot.admin.action.base.Action that will be triggered when the user selects an item in a list of objects. This defaults to camelot.admin.action.list_action.OpenFormView, which opens a form for the current object.
Filtering
A list of fields that should be used to generate filters for in the table view. If the field named is a one2many, many2one or many2many field, the field name should be followed by a field name of the related entity
class Project( Entity ):
oranization = OneToMany( 'Organization' )
name = Column( Unicode(50) )
class Admin( EntityAdmin ):
list_display = ['organization']
list_filter = ['organization.name']
Copying
A dictionary of fields that will be deep copied when the user presses the copy button. This is useful for OneToMany fields. The key in the dictionary should be the name of the field, and the value is a new dictionary that can contain other fields that need to be copied:
copy_deep = {'addresses':{}}
A list of fields that should not be copied when the user presses the copy button:
copy_exclude = ['name']
The fields that form the primary key of the object will be excluded by default.
Searching
A list of fields that should be searched when the user enters something in the search box in the table view. By default all fields are searched for which Camelot can do a conversion of the entered string to the datatype of the underlying column.
For use with one2many, many2one or many2many fields, the same rules as for the list_filter attribute apply
Defaults to True, meaning that by default all searchable fields should be searched. If this is set to False, one should explicitely set the list_search attribute to enable search.
A list of fields that will be searchable through the expanded search. When set to None, all the fields in list_display will be searchable. Use this attribute to limit the number of search widgets. Defaults to None.
Adds the entity instance to the default session, if it is not yet attached to a session
Duplicate an object. If no new object is given to copy to, a new one will be created. This function will be called every time the user presses a copy button.
Parameters: |
|
---|---|
Returns: | the new object |
This function takes into account the deep_copy and the copy_exclude attributes. It tries to recreate relations with a minimum of side effects.
Returns a Qt widget that can be used to select an element from a query
Parameters: |
|
---|
returned widget has an entity_selected_signal signal that will be fired when a entity has been selected.
Returns a QtGui.QWidget containing a table view :param gui_context: a camelot.admin.action.base.GuiContext object.
In addition to all the fields that are defined in the views or through the field_attributes, this method returns all the fields that have been mapped.
Takes the dynamic field attributes from through the ObjectAdmin its get_dynamic_field_attributes and make relational fields not editable in case the object is not yet persisted.
Returns: | a list of tuples of type [(field_name, field_attributes)] |
---|
Get the attributes needed to visualize the field field_name :param field_name: the name of the field
Returns: | a dictionary of attributes needed to visualize the field, |
---|
Returns the filters applicable for these entities each filter is
Returns: | [(filter, filter_data)] |
---|
Get the modifications on an object since the last flush. :param obj: the object for which to get the modifications :return: a dictionary with the changed attributes and their old
value
Returns: | an sqlalchemy query for all the objects that should be |
---|
displayed in the table or the selection view. Overwrite this method to change the default query, which selects all rows in the database.
Returns a set of default field attributes based on introspection of the SQLAlchemy columns that form a field
Param : | columns a list of sqlalchemy.schema.Column objects. |
---|---|
Returns: | a dictionary with field attributes |
By default this method looks at the first column that defines the field and derives a delegate and other field attributes that make sense.
Returns: | True if the object has been deleted from the persistent |
---|
state, False otherwise
Returns: | True if the object has a persisted state, False otherwise |
---|
Get the primary key of an object :param obj: the object to get the primary key from :return: a tuple with with components of the primary key, or none
if the object has no primary key yet or any more.
Undo the pending changes to the backend and restore the original state
alias of EntityValidator