Commit ba84a1af authored by Christopher Toth's avatar Christopher Toth

Minor English cleanups for flask_admin.contrib.sqlamodel.view

parent 208adeab
...@@ -18,7 +18,7 @@ from .typefmt import DEFAULT_FORMATTERS ...@@ -18,7 +18,7 @@ from .typefmt import DEFAULT_FORMATTERS
class ModelView(BaseModelView): class ModelView(BaseModelView):
""" """
SQLALchemy model view SQLAlchemy model view
Usage sample:: Usage sample::
...@@ -90,7 +90,7 @@ class ModelView(BaseModelView): ...@@ -90,7 +90,7 @@ class ModelView(BaseModelView):
class MyModelView(ModelView): class MyModelView(ModelView):
column_searchable_list = (User.name, User.email) column_searchable_list = (User.name, User.email)
Following search rules apply: The following search rules apply:
- If you enter *ZZZ* in the UI search field, it will generate *ILIKE '%ZZZ%'* - If you enter *ZZZ* in the UI search field, it will generate *ILIKE '%ZZZ%'*
statement against searchable columns. statement against searchable columns.
...@@ -103,8 +103,8 @@ class ModelView(BaseModelView): ...@@ -103,8 +103,8 @@ class ModelView(BaseModelView):
- If you prefix your search term with ^, it will find all rows - If you prefix your search term with ^, it will find all rows
that start with ^. So, if you entered *^ZZZ*, *ILIKE 'ZZZ%'* will be used. that start with ^. So, if you entered *^ZZZ*, *ILIKE 'ZZZ%'* will be used.
- If you prefix your search term with =, it will do exact match. - If you prefix your search term with =, it will perform an exact match.
For example, if you entered *=ZZZ*, *ILIKE 'ZZZ'* statement will be used. For example, if you entered *=ZZZ*, the statement *ILIKE 'ZZZ'* will be used.
""" """
column_filters = None column_filters = None
...@@ -163,11 +163,11 @@ class ModelView(BaseModelView): ...@@ -163,11 +163,11 @@ class ModelView(BaseModelView):
""" """
If set to `False` and user deletes more than one model using built in action, If set to `False` and user deletes more than one model using built in action,
all models will be read from the database and then deleted one by one all models will be read from the database and then deleted one by one
giving SQLAlchemy chance to manually cleanup any dependencies (many-to-many giving SQLAlchemy a chance to manually cleanup any dependencies (many-to-many
relationships, etc). relationships, etc).
If set to `True`, will run `DELETE` statement which is somewhat faster, If set to `True`, will run a `DELETE` statement which is somewhat faster,
but might leave corrupted data if you forget to configure `DELETE but may leave corrupted data if you forget to configure `DELETE
CASCADE` for your model. CASCADE` for your model.
""" """
...@@ -195,9 +195,9 @@ class ModelView(BaseModelView): ...@@ -195,9 +195,9 @@ class ModelView(BaseModelView):
class MyModelView(ModelView): class MyModelView(ModelView):
inline_models = (MyInlineModelForm(MyInlineModel),) inline_models = (MyInlineModelForm(MyInlineModel),)
You can customize generated field name by: You can customize the generated field name by:
1. Using `form_name` property as option: 1. Using the `form_name` property as a key to the options dictionary:
class MyModelView(ModelView): class MyModelView(ModelView):
inline_models = ((Post, dict(form_label='Hello'))) inline_models = ((Post, dict(form_label='Hello')))
...@@ -226,15 +226,15 @@ class ModelView(BaseModelView): ...@@ -226,15 +226,15 @@ class ModelView(BaseModelView):
:param model: :param model:
Model class Model class
:param session: :param session:
SQLALchemy session SQLAlchemy session
:param name: :param name:
View name. If not set, will default to model name View name. If not set, defaults to the model name
:param category: :param category:
Category name Category name
:param endpoint: :param endpoint:
Endpoint name. If not set, will default to model name Endpoint name. If not set, defaults to the model name
:param url: :param url:
Base URL. If not set, will default to '/admin/' + endpoint Base URL. If not set, defaults to '/admin/' + endpoint
""" """
self.session = session self.session = session
...@@ -270,19 +270,19 @@ class ModelView(BaseModelView): ...@@ -270,19 +270,19 @@ class ModelView(BaseModelView):
# Scaffolding # Scaffolding
def scaffold_pk(self): def scaffold_pk(self):
""" """
Return primary key name from a model Return the primary key name from a model
""" """
return tools.get_primary_key(self.model) return tools.get_primary_key(self.model)
def get_pk_value(self, model): def get_pk_value(self, model):
""" """
Return PK value from a model object. Return the PK value from a model object.
""" """
return getattr(model, self._primary_key) return getattr(model, self._primary_key)
def scaffold_list_columns(self): def scaffold_list_columns(self):
""" """
Return list of columns from the model. Return a list of columns from the model.
""" """
columns = [] columns = []
...@@ -307,7 +307,7 @@ class ModelView(BaseModelView): ...@@ -307,7 +307,7 @@ class ModelView(BaseModelView):
def scaffold_sortable_columns(self): def scaffold_sortable_columns(self):
""" """
Return dictionary of sortable columns. Return a dictionary of sortable columns.
Key is column name, value is sort column/field. Key is column name, value is sort column/field.
""" """
columns = dict() columns = dict()
...@@ -322,7 +322,7 @@ class ModelView(BaseModelView): ...@@ -322,7 +322,7 @@ class ModelView(BaseModelView):
column = p.columns[0] column = p.columns[0]
# Can't sort by on primary and foreign keys by default # Can't sort on primary or foreign keys by default
if column.foreign_keys: if column.foreign_keys:
continue continue
...@@ -383,7 +383,7 @@ class ModelView(BaseModelView): ...@@ -383,7 +383,7 @@ class ModelView(BaseModelView):
def is_text_column_type(self, name): def is_text_column_type(self, name):
""" """
Verify if column type is text-based. Verify if the provided column type is text-based.
:returns: :returns:
``True`` for ``String``, ``Unicode``, ``Text``, ``UnicodeText`` ``True`` for ``String``, ``Unicode``, ``Text``, ``UnicodeText``
...@@ -479,7 +479,7 @@ class ModelView(BaseModelView): ...@@ -479,7 +479,7 @@ class ModelView(BaseModelView):
def is_valid_filter(self, filter): def is_valid_filter(self, filter):
""" """
Verify that provided filter object is derived from the Verify that the provided filter object is derived from the
SQLAlchemy-compatible filter class. SQLAlchemy-compatible filter class.
:param filter: :param filter:
...@@ -522,7 +522,7 @@ class ModelView(BaseModelView): ...@@ -522,7 +522,7 @@ class ModelView(BaseModelView):
def scaffold_auto_joins(self): def scaffold_auto_joins(self):
""" """
Return list of joined tables by going through the Return a list of joined tables by going through the
displayed columns. displayed columns.
""" """
if not self.column_auto_select_related: if not self.column_auto_select_related:
...@@ -669,7 +669,7 @@ class ModelView(BaseModelView): ...@@ -669,7 +669,7 @@ class ModelView(BaseModelView):
def get_one(self, id): def get_one(self, id):
""" """
Return one model by its id. Return a single model by its id.
:param id: :param id:
Model id Model id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment