EquationPluginModel¶
-
class
EquationPluginModel
(*args, **kwargs)[source]¶ Database model of saved Equations.
Attributes Summary
alias_reference
Accessor to the related objects manager on the reverse side of a many-to-one relation.
alphabet
changed_date
A wrapper for a deferred-loading field.
child_plugin_instances
cms_aliasplugin
Accessor to the related object on the reverse side of a one-to-one relation.
cms_placeholderreference
Accessor to the related object on the reverse side of a one-to-one relation.
cmsplugin_ptr
Accessor to the related object on the forward side of a one-to-one relation.
cmsplugin_ptr_id
A wrapper for a deferred-loading field.
cmsplugin_set
Accessor to the related objects manager on the reverse side of a many-to-one relation.
creation_date
A wrapper for a deferred-loading field.
depth
A wrapper for a deferred-loading field.
djangocms_equation_equationpluginmodel
Accessor to the related object on the reverse side of a one-to-one relation.
djangocms_text_ckeditor_text
Accessor to the related object on the reverse side of a one-to-one relation.
font_size_unit
Value of the font-size with size value font_size_value.
font_size_value
Value of the font-size with unit font_size_unit.
gap
id
A wrapper for a deferred-loading field.
is_inline
If it should be displayed inline or be stand alone.
language
A wrapper for a deferred-loading field.
node_order_by
numchild
A wrapper for a deferred-loading field.
numconv_obj_
objects
page
parent
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
parent_id
A wrapper for a deferred-loading field.
path
A wrapper for a deferred-loading field.
pk
placeholder
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
placeholder_id
A wrapper for a deferred-loading field.
plugin_type
A wrapper for a deferred-loading field.
position
A wrapper for a deferred-loading field.
steplen
tex_code
Latex code of the equation.
Methods Summary
Adds a child to the node.
Adds a root node to the tree.
Adds a new node as a sibling to the current node object.
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields.
Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
Copy this plugin and return the new plugin.
Handle copying of any relations attached to this plugin.
Removes a node and all it’s descendants.
Dumps a tree branch to a python data structure.
Checks for problems in the tree structure, problems can occur when:
Fixes the plugin tree by first calling treebeard fix_tree and the recalculating the correct position property for each plugin.
Call clean_fields(), clean(), and validate_unique() on the model.
- returns
A queryset containing the current node object’s ancestors,
Gets an annotated list from a tree branch.
Gets an annotated list from a queryset.
Returns an instance of the plugin model configured for this plugin type.
- returns
A queryset of all the node’s children
- returns
The number the node’s children, calculated in the most
returns the supported database vendor used by a treebeard model when performing read (select) or write (update, insert, delete) operations.
Return a set containing names of deferred fields for this instance.
- returns
the depth (level) of the node
- returns
the number of descendants of a node.
- returns
A queryset of all the node’s descendants as DFS, doesn’t
Helper for a very common case: get a group of siblings and the number of descendants in every sibling.
- returns
- returns
- returns
Get foreign keys and models they refer to, so we can pre-process the data for load_bulk
Get alt text for instance’s icon
Get src URL for instance’s icon
- returns
- returns
- returns
- returns
The next node’s sibling, or None if it was the rightmost
- returns
the parent node of the current node object.
Given a plugin instance (usually as a CMSPluginBase), this method returns a tuple containing: instance - The instance AS THE APPROPRIATE SUBCLASS OF CMSPluginBase and not necessarily just ‘self’, which is often just a CMSPluginBase, plugin - the associated plugin class instance (subclass of CMSPlugin)
1 based position!
- returns
The previous node’s sibling, or None if it was the leftmost
- returns
the root node for the current node object.
- returns
A queryset containing the root nodes in the tree.
- returns
A queryset of all the node’s siblings, including the node
- returns
A queryset of the nodes that must be moved
- returns
- returns
True
is the node if a child of another node given as an
- returns
True
if the node is a descendant of another node given
- returns
True if the node is a leaf node (else, returns False)
- returns
True if the node is a root node (else, returns False)
- returns
True
if the node is a sibling of another node given as an
Loads a list/dictionary structure to the tree.
Moves the current node and all it’s descendants to a new position relative to another node.
Method called when we auto add this plugin via default_plugins in CMS_PLACEHOLDER_CONF.
Method called when we auto add children to this plugin via default_plugins/<plugin>/children in CMS_PLACEHOLDER_CONF.
Handle more advanced cases (eg Text Plugins) after the original is copied
Reload field values from the database.
Save the current instance.
Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too.
Return the value of the field name for this instance.
Check unique constraints on the model and raise ValidationError if any failed.
Methods Documentation
-
add_child
(**kwargs)¶ Adds a child to the node.
This method saves the node in database. The object is populated as if via:
` obj = self.__class__(**kwargs) `
- Raises
PathOverflow – when no more child nodes can be added
-
classmethod
add_root
(**kwargs)¶ Adds a root node to the tree.
This method saves the node in database. The object is populated as if via:
` obj = cls(**kwargs) `
- Raises
PathOverflow – when no more root objects can be added
-
add_sibling
(pos=None, **kwargs)¶ Adds a new node as a sibling to the current node object.
This method saves the node in database. The object is populated as if via:
` obj = self.__class__(**kwargs) `
- Raises
PathOverflow – when the library can’t make room for the node’s new position
-
classmethod
check
(**kwargs)¶
-
clean
()¶ Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
-
clean_fields
(exclude=None)¶ Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
-
copy_plugin
(target_placeholder, target_language, parent_cache, no_signals=False)¶ Copy this plugin and return the new plugin.
The logic of this method is the following:
# get a new generic plugin instance # assign the position in the plugin tree # save it to let mptt/treebeard calculate the tree attributes # then get a copy of the current plugin instance # assign to it the id of the generic plugin instance above;
this will effectively change the generic plugin created above into a concrete one
- # copy the tree related attributes from the generic plugin to
the concrete one
# save the concrete plugin # trigger the copy relations # return the generic plugin instance
This copy logic is required because we don’t know what the fields of the real plugin are. By getting another instance of it at step 4 and then overwriting its ID at step 5, the ORM will copy the custom fields for us.
-
copy_relations
(old_instance)¶ Handle copying of any relations attached to this plugin. Custom plugins have to do this themselves!
-
date_error_message
(lookup_type, field_name, unique_for)¶
-
delete
(no_mp=False, *args, **kwargs)¶ Removes a node and all it’s descendants.
-
classmethod
dump_bulk
(parent=None, keep_ids=True)¶ Dumps a tree branch to a python data structure.
-
classmethod
find_problems
()¶ Checks for problems in the tree structure, problems can occur when:
your code breaks and you get incomplete transactions (always use transactions!)
changing the
steplen
value in a model (you mustdump_bulk()
first, changesteplen
and thenload_bulk()
- Returns
A tuple of five lists:
a list of ids of nodes with characters not found in the
alphabet
a list of ids of nodes when a wrong
path
length according tosteplen
a list of ids of orphaned nodes
a list of ids of nodes with the wrong depth value for their path
a list of ids nodes that report a wrong number of children
-
classmethod
fix_tree
(destructive=False)¶ Fixes the plugin tree by first calling treebeard fix_tree and the recalculating the correct position property for each plugin.
-
classmethod
from_db
(db, field_names, values)¶
-
full_clean
(exclude=None, validate_unique=True)¶ Call clean_fields(), clean(), and validate_unique() on the model. Raise a ValidationError for any errors that occur.
-
get_action_urls
(js_compat=True)¶
-
get_add_url
()¶
-
get_ancestors
()¶ - Returns
A queryset containing the current node object’s ancestors, starting by the root node and descending to the parent.
-
classmethod
get_annotated_list
(parent=None, max_depth=None)¶ Gets an annotated list from a tree branch.
- Parameters
parent – The node whose descendants will be annotated. The node itself will be included in the list. If not given, the entire tree will be annotated.
max_depth – Optionally limit to specified depth
-
classmethod
get_annotated_list_qs
(qs)¶ Gets an annotated list from a queryset.
-
get_bound_plugin
()¶ Returns an instance of the plugin model configured for this plugin type.
-
get_children
()¶ - Returns
A queryset of all the node’s children
-
get_children_count
()¶ - Returns
The number the node’s children, calculated in the most
efficient possible way.
-
get_copy_url
()¶
-
classmethod
get_database_vendor
(action)¶ returns the supported database vendor used by a treebeard model when performing read (select) or write (update, insert, delete) operations.
- Parameters
action – read or write
- Returns
postgresql, mysql or sqlite
-
get_deferred_fields
()¶ Return a set containing names of deferred fields for this instance.
-
get_delete_url
()¶
-
get_depth
()¶ - Returns
the depth (level) of the node
-
get_descendant_count
()¶ - Returns
the number of descendants of a node.
-
get_descendants
()¶ - Returns
A queryset of all the node’s descendants as DFS, doesn’t include the node itself
-
classmethod
get_descendants_group_count
(parent=None)¶ Helper for a very common case: get a group of siblings and the number of descendants in every sibling.
-
get_edit_url
()¶
-
get_first_child
()¶ - Returns
The leftmost node’s child, or None if it has no children.
-
classmethod
get_first_root_node
()¶ - Returns
The first root node in the tree or
None
if it is empty.
-
get_first_sibling
()¶ - Returns
The leftmost node’s sibling, can return the node itself if it was the leftmost sibling.
-
get_font_size_unit_display
(*, field=<django.db.models.fields.CharField: font_size_unit>)¶
-
classmethod
get_foreign_keys
()¶ Get foreign keys and models they refer to, so we can pre-process the data for load_bulk
-
get_instance_icon_alt
()¶ Get alt text for instance’s icon
-
get_instance_icon_src
()¶ Get src URL for instance’s icon
-
get_last_child
()¶ - Returns
The rightmost node’s child, or None if it has no children.
-
classmethod
get_last_root_node
()¶ - Returns
The last root node in the tree or
None
if it is empty.
-
get_last_sibling
()¶ - Returns
The rightmost node’s sibling, can return the node itself if it was the rightmost sibling.
-
get_media_path
(filename)¶
-
get_move_url
()¶
-
get_next_by_changed_date
(*, field=<django.db.models.fields.DateTimeField: changed_date>, is_next=True, **kwargs)¶
-
get_next_by_creation_date
(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=True, **kwargs)¶
-
get_next_sibling
()¶ - Returns
The next node’s sibling, or None if it was the rightmost sibling.
-
get_parent
(update=False)¶ - Returns
the parent node of the current node object. Caches the result in the object itself to help in loops.
-
get_plugin_class
()¶
-
get_plugin_class_instance
(admin=None)¶
-
get_plugin_info
(children=None, parents=None)¶
-
get_plugin_instance
(admin=None)¶ Given a plugin instance (usually as a CMSPluginBase), this method returns a tuple containing:
- instance - The instance AS THE APPROPRIATE SUBCLASS OF
CMSPluginBase and not necessarily just ‘self’, which is often just a CMSPluginBase,
- plugin - the associated plugin class instance (subclass
of CMSPlugin)
-
get_plugin_name
()¶
-
get_position_in_placeholder
()¶ 1 based position!
-
get_prev_sibling
()¶ - Returns
The previous node’s sibling, or None if it was the leftmost sibling.
-
get_previous_by_changed_date
(*, field=<django.db.models.fields.DateTimeField: changed_date>, is_next=False, **kwargs)¶
-
get_previous_by_creation_date
(*, field=<django.db.models.fields.DateTimeField: creation_date>, is_next=False, **kwargs)¶
-
get_root
()¶ - Returns
the root node for the current node object.
-
classmethod
get_root_nodes
()¶ - Returns
A queryset containing the root nodes in the tree.
-
get_short_description
()¶
-
get_siblings
()¶ - Returns
A queryset of all the node’s siblings, including the node itself.
-
get_sorted_pos_queryset
(siblings, newobj)¶ - Returns
A queryset of the nodes that must be moved
to the right. Called only for Node models with
node_order_by
This function is based on _insertion_target_filters from django-mptt (BSD licensed) by Jonathan Buchanan: https://github.com/django-mptt/django-mptt/blob/0.3.0/mptt/signals.py
-
classmethod
get_tree
(parent=None)¶ - Returns
A queryset of nodes ordered as DFS, including the parent. If no parent is given, the entire tree is returned.
-
is_child_of
(node)¶ - Returns
True
is the node if a child of another node given as an argument, else, returnsFalse
-
is_descendant_of
(node)¶ - Returns
True
if the node is a descendant of another node given as an argument, else, returnsFalse
-
is_leaf
()¶ - Returns
True if the node is a leaf node (else, returns False)
-
is_root
()¶ - Returns
True if the node is a root node (else, returns False)
-
is_sibling_of
(node)¶ - Returns
True
if the node is a sibling of another node given as an argument, else, returnsFalse
-
classmethod
load_bulk
(bulk_data, parent=None, keep_ids=False)¶ Loads a list/dictionary structure to the tree.
- Parameters
bulk_data –
The data that will be loaded, the structure is a list of dictionaries with 2 keys:
data
: will store arguments that will be passed for object creation, andchildren
: a list of dictionaries, each one has it’s owndata
andchildren
keys (a recursive structure)
parent – The node that will receive the structure as children, if not specified the first level of the structure will be loaded as root nodes
keep_ids – If enabled, loads the nodes with the same primary keys that are given in the structure. Will error if there are nodes without primary key info or if the primary keys are already used.
- Returns
A list of the added node ids.
-
move
(target, pos=None)¶ Moves the current node and all it’s descendants to a new position relative to another node.
- Raises
PathOverflow – when the library can’t make room for the node’s new position
-
notify_on_autoadd
(request, conf)¶ Method called when we auto add this plugin via default_plugins in CMS_PLACEHOLDER_CONF. Some specific plugins may have some special stuff to do when they are auto added.
-
notify_on_autoadd_children
(request, conf, children)¶ Method called when we auto add children to this plugin via default_plugins/<plugin>/children in CMS_PLACEHOLDER_CONF. Some specific plugins may have some special stuff to do when we add children to them. ie : TextPlugin must update its content to add HTML tags to be able to see his children in WYSIWYG.
-
num_children
()¶
-
classmethod
numconv_obj
()¶
-
post_copy
(old_instance, new_old_ziplist)¶ Handle more advanced cases (eg Text Plugins) after the original is copied
-
prepare_database_save
(field)¶
-
refresh_from_db
(*args, **kwargs)¶ Reload field values from the database.
By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.
Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.
When accessing deferred fields of an instance, the deferred loading of the field will call this method.
-
reload
()¶
-
save
(no_signals=False, *args, **kwargs)¶ Save the current instance. Override this in a subclass if you want to control the saving process.
The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
-
save_base
(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)¶ Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.
The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.
-
serializable_value
(field_name)¶ Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.
Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.
-
set_base_attr
(plugin)¶
-
unique_error_message
(model_class, unique_check)¶
-
update
(refresh=False, **fields)¶
-
validate_unique
(exclude=None)¶ Check unique constraints on the model and raise ValidationError if any failed.