Home | Trees | Indices | Help |
|
---|
|
The ObjectAdmin class describes the interface that will be used to interact with objects of a certain class. The behaviour of this class and the resulting interface can be tuned by specifying specific class attributes: .. attribute:: verbose_name A human-readable name for the object, singular :: verbose_name = 'movie' If this isn't given, the class name will be used .. attribute:: verbose_name_plural A human-readable name for the object, plural :: verbose_name_plural = 'movies' If this isn't given, Camelot will use verbose_name + "s" .. attribute:: list_display a list with the fields that should be displayed in a table view .. attribute:: form_display a list with the fields that should be displayed in a form view, defaults to the same fields as those specified in list_display :: class Admin(EntityAdmin): form_display = ['title', 'rating', 'cover'] instead of telling which forms to display. It is also possible to define the form itself :: from camelot.view.forms import Form, TabForm, WidgetOnlyForm, HBoxForm class Admin(EntityAdmin): form_display = TabForm([ ('Movie', Form([ HBoxForm([['title', 'rating'], WidgetOnlyForm('cover')]), 'short_description', 'releasedate', 'director', 'script', 'genre', 'description', 'tags'], scrollbars=True)), ('Cast', WidgetOnlyForm('cast')) ]) .. attribute:: list_filter 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 = Field(Unicode(50)) class Admin(EntityAdmin): list_display = ['organization'] list_filter = ['organization.name'] .. image:: ../_static/filter/group_box_filter.png .. attribute:: list_search A list of fields that should be searched when the user enters something in the search box in the table view. By default only character fields are searched. For use with one2many, many2one or many2many fields, the same rules as for the list_filter attribute apply .. attribute:: confirm_delete Indicates if the deletion of an object should be confirmed by the user, defaults to False. Can be set to either True, False, or the message to display when asking confirmation of the deletion. .. attribute:: form_size a tuple indicating the size of a form view, defaults to (700,500) .. attribute:: form_actions Actions to be accessible by pushbuttons on the side of a form, a list of tuples (button_label, action_function) where action_function takes as its single argument, a method that returns the the object that was displayed by the form when the button was pressed:: class Admin(EntityAdmin): form_actions = [('Foo', lamda o_getter:print 'foo')] .. attribute:: field_attributes A dictionary specifying for each field of the model some additional attributes on how they should be displayed. All of these attributes are propagated to the constructor of the delegate of this field:: class Movie(Entity): title = Field(Unicode(50)) class Admin(EntityAdmin): list_display = ['title'] field_attributes = dict(title=dict(editable=False)) Other field attributes process by the admin interface are: .. attribute:: name The name of the field used, this defaults to the name of the attribute .. attribute:: target In case of relation fields, specifies the class that is at the other end of the relation. Defaults to the one found by introspection. .. attribute:: admin In case of relation fields, specifies the admin class that is to be used to visualize the other end of the relation. Defaults to the default admin class of the target class. .. attribute:: model The QAbstractItemModel class to be used to display collections of this object, defaults to a CollectionProxy .. attribute:: confirm_delete set to True if the user should get a confirmation dialog before deleting data, defaults to False .. attribute:: TableView The QWidget class to be used when a table view is needed
Nested Classes | |
validator A validator class for normal python objects. By default this validator declares all objects valid. Subclass this class and overwrite it's objectValidity method to change it's behaviour. |
|
model The CollectionProxy contains a limited copy of the data in the actual collection, usable for fast visualisation in a QTableView |
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Properties | |
Inherited from |
Method Details |
|
|
|
|
|
|
|
|
Get the attributes needed to visualize the field field_name :param field_name : the name of the field
|
The columns to be displayed in the list view, returns a list of pairs of the name of the field and its attributes needed to display it properly
|
|
|
|
|
|
Create a Qt widget containing a form to create a new instance of the entity related to this admin class The returned class has an 'entity_created_signal' that will be fired when a valid new entity was created by the form
|
|
|
|
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sat Jun 12 15:41:32 2010 | http://epydoc.sourceforge.net |