geonature.core.gn_commons.admin¶
Attributes¶
Classes¶
Declarative Form base class. Extends BaseForm's core behaviour allowing |
|
SQLAlchemy model view |
|
SQLAlchemy model view |
|
SQLAlchemy model view |
Module Contents¶
- class geonature.core.gn_commons.admin.TAdditionalFieldsForm(formdata=None, obj=None, prefix='', **kwargs)[source]¶
Bases:
flask_admin.form.BaseFormDeclarative Form base class. Extends BaseForm’s core behaviour allowing fields to be defined on Form subclasses as class attributes.
In addition, form and instance input data are taken at construction time and passed to process().
- validate(extra_validators=None)[source]¶
Validate the form by calling
validateon each field. ReturnsTrueif validation passes.If the form defines a
validate_<fieldname>method, it is appended as an extra validator for the field’svalidate.- Paramètres:
extra_validators – A dict mapping field names to lists of extra validator methods to run. Extra validators run after validators passed when creating the field. If the form has
validate_<fieldname>, it is the last extra validator.
- class geonature.core.gn_commons.admin.BibFieldAdmin(model, session, name=None, category=None, endpoint=None, url=None, static_folder=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]¶
Bases:
geonature.core.admin.utils.CruvedProtectedMixin,flask_admin.contrib.sqla.ModelViewSQLAlchemy model view
Usage sample:
admin = Admin() admin.add_view(ModelView(User, db.session))
- form_base_class[source]¶
Base form class. Will be used by form scaffolding function when creating model form.
Useful if you want to have custom constructor or override some fields.
Example:
class MyBaseForm(Form): def do_something(self): pass class MyModelView(BaseModelView): form_base_class = MyBaseForm
- form_columns = ('field_name', 'field_label', 'type_widget', 'modules', 'objects', 'datasets', 'required',...[source]¶
Collection of the model field names for the form. If set to None will get them from the model.
Example:
class MyModelView(BaseModelView): form_columns = ('name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): form_columns = ('name', User.last_name)
SQLA Note: Model attributes must be on the same model as your ModelView or you will need to use inline_models.
- column_exclude_list = ('field_values', 'additional_attributes', 'key_label', 'key_value', 'multiselect', 'api',...[source]¶
Collection of excluded list column names.
For example:
class MyModelView(BaseModelView): column_exclude_list = ('last_name', 'email')
- column_display_all_relations = True[source]¶
Controls if list view should display all relations, not only many-to-one.
- class geonature.core.gn_commons.admin.TMobileAppsAdmin(model, session, name=None, category=None, endpoint=None, url=None, static_folder=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]¶
Bases:
geonature.core.admin.utils.CruvedProtectedMixin,flask_admin.contrib.sqla.ModelViewSQLAlchemy model view
Usage sample:
admin = Admin() admin.add_view(ModelView(User, db.session))
- column_list = ('app_code', 'relative_path_apk', 'url_apk', 'package', 'version_code')[source]¶
Collection of the model field names for the list view. If set to None, will get them from the model.
For example:
class MyModelView(BaseModelView): column_list = ('name', 'last_name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): column_list = ('name', User.last_name)
- When using SQLAlchemy models, you can reference related columns like this::
- class MyModelView(BaseModelView):
column_list = (“<relationship>.<related column name>”,)
- column_labels[source]¶
Dictionary where key is column name and value is string to display.
For example:
class MyModelView(BaseModelView): column_labels = dict(name='Name', last_name='Last Name')
- form_columns = ('app_code', 'relative_path_apk', 'url_apk', 'package', 'version_code')[source]¶
Collection of the model field names for the form. If set to None will get them from the model.
Example:
class MyModelView(BaseModelView): form_columns = ('name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): form_columns = ('name', User.last_name)
SQLA Note: Model attributes must be on the same model as your ModelView or you will need to use inline_models.
- class geonature.core.gn_commons.admin.TModulesAdmin(model, session, name=None, category=None, endpoint=None, url=None, static_folder=None, menu_class_name=None, menu_icon_type=None, menu_icon_value=None)[source]¶
Bases:
geonature.core.admin.utils.CruvedProtectedMixin,flask_admin.contrib.sqla.ModelViewSQLAlchemy model view
Usage sample:
admin = Admin() admin.add_view(ModelView(User, db.session))
- can_view_details = True[source]¶
Setting this to true will enable the details view. This is recommended when there are too many columns to display in the list_view.
- action_disallowed_list = ['delete'][source]¶
Set of disallowed action names. For example, if you want to disable mass model deletion, do something like this:
- class MyModelView(BaseModelView):
action_disallowed_list = [“delete”]
- column_searchable_list = ('module_code', 'module_label')[source]¶
Collection of the searchable columns.
Example:
class MyModelView(ModelView): column_searchable_list = ('name', 'email')
You can also pass columns:
class MyModelView(ModelView): column_searchable_list = (User.name, User.email)
The following search rules apply:
If you enter
ZZZin the UI search field, it will generateILIKE '%ZZZ%'statement against searchable columns.If you enter multiple words, each word will be searched separately, but only rows that contain all words will be displayed. For example, searching for
abc defwill find all rows that containabcanddefin one or more columns.If you prefix your search term with
^, it will find all rows that start with^. So, if you entered^ZZZthenILIKE 'ZZZ%'will be used.If you prefix your search term with
=, it will perform an exact match. For example, if you entered=ZZZ, the statementILIKE 'ZZZ'will be used.
- column_default_sort = [('module_order', False), ('id_module', False)][source]¶
Default sort column if no sorting is applied.
Example:
class MyModelView(BaseModelView): column_default_sort = 'user'
You can use tuple to control ascending descending order. In following example, items will be sorted in descending order:
class MyModelView(BaseModelView): column_default_sort = ('user', True)
If you want to sort by more than one column, you can pass a list of tuples:
class MyModelView(BaseModelView): column_default_sort = [('name', True), ('last_name', True)]
- column_sortable_list = ('module_order', 'module_code', 'module_label')[source]¶
Collection of the sortable columns for the list view. If set to None, will get them from the model.
For example:
class MyModelView(BaseModelView): column_sortable_list = ('name', 'last_name')
If you want to explicitly specify field/column to be used while sorting, you can use a tuple:
class MyModelView(BaseModelView): column_sortable_list = ('name', ('user', 'user.username'))
You can also specify multiple fields to be used while sorting:
class MyModelView(BaseModelView): column_sortable_list = ( 'name', ('user', ('user.first_name', 'user.last_name')))
When using SQLAlchemy models, model attributes can be used instead of strings:
class MyModelView(BaseModelView): column_sortable_list = ('name', ('user', User.username))
- column_list = ('module_code', 'module_label', 'module_picto', 'module_order')[source]¶
Collection of the model field names for the list view. If set to None, will get them from the model.
For example:
class MyModelView(BaseModelView): column_list = ('name', 'last_name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): column_list = ('name', User.last_name)
- When using SQLAlchemy models, you can reference related columns like this::
- class MyModelView(BaseModelView):
column_list = (“<relationship>.<related column name>”,)
- column_details_list = ('module_code', 'module_label', 'module_desc', 'module_comment', 'module_picto',...[source]¶
Collection of the field names included in the details view. If set to None, will get them from the model.
- form_columns = ('module_label', 'module_desc', 'module_comment', 'module_picto', 'module_doc_url', 'module_order')[source]¶
Collection of the model field names for the form. If set to None will get them from the model.
Example:
class MyModelView(BaseModelView): form_columns = ('name', 'email')
(Added in 1.4.0) SQLAlchemy model attributes can be used instead of strings:
class MyModelView(BaseModelView): form_columns = ('name', User.last_name)
SQLA Note: Model attributes must be on the same model as your ModelView or you will need to use inline_models.