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

add_child

Adds a child to the node.

add_root

Adds a root node to the tree.

add_sibling

Adds a new node as a sibling to the current node object.

check

clean

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields.

clean_fields

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

copy_plugin

Copy this plugin and return the new plugin.

copy_relations

Handle copying of any relations attached to this plugin.

date_error_message

delete

Removes a node and all it’s descendants.

dump_bulk

Dumps a tree branch to a python data structure.

find_problems

Checks for problems in the tree structure, problems can occur when:

fix_tree

Fixes the plugin tree by first calling treebeard fix_tree and the recalculating the correct position property for each plugin.

from_db

full_clean

Call clean_fields(), clean(), and validate_unique() on the model.

get_action_urls

get_add_url

get_ancestors

returns

A queryset containing the current node object’s ancestors,

get_annotated_list

Gets an annotated list from a tree branch.

get_annotated_list_qs

Gets an annotated list from a queryset.

get_bound_plugin

Returns an instance of the plugin model configured for this plugin type.

get_breadcrumb

get_breadcrumb_json

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

get_copy_url

get_database_vendor

returns the supported database vendor used by a treebeard model when performing read (select) or write (update, insert, delete) operations.

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

get_descendants_group_count

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

get_first_root_node

returns

get_first_sibling

returns

get_font_size_unit_display

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

get_last_root_node

returns

get_last_sibling

returns

get_media_path

get_move_url

get_next_by_changed_date

get_next_by_creation_date

get_next_sibling

returns

The next node’s sibling, or None if it was the rightmost

get_parent

returns

the parent node of the current node object.

get_plugin_class

get_plugin_class_instance

get_plugin_info

get_plugin_instance

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

get_previous_by_changed_date

get_previous_by_creation_date

get_root

returns

the root node for the current node object.

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

get_sorted_pos_queryset

returns

A queryset of the nodes that must be moved

get_tree

returns

is_child_of

returns

True is the node if a child of another node given as an

is_descendant_of

returns

True if the node is a descendant of another node given

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

returns

True if the node is a sibling of another node given as an

load_bulk

Loads a list/dictionary structure to the tree.

move

Moves the current node and all it’s descendants to a new position relative to another node.

notify_on_autoadd

Method called when we auto add this plugin via default_plugins in CMS_PLACEHOLDER_CONF.

notify_on_autoadd_children

Method called when we auto add children to this plugin via default_plugins/<plugin>/children in CMS_PLACEHOLDER_CONF.

num_children

numconv_obj

post_copy

Handle more advanced cases (eg Text Plugins) after the original is copied

prepare_database_save

refresh_from_db

Reload field values from the database.

reload

save

Save the current instance.

save_base

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too.

serializable_value

Return the value of the field name for this instance.

set_base_attr

unique_error_message

update

validate_unique

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:

  1. your code breaks and you get incomplete transactions (always use transactions!)

  2. changing the steplen value in a model (you must dump_bulk() first, change steplen and then load_bulk()

Returns

A tuple of five lists:

  1. a list of ids of nodes with characters not found in the alphabet

  2. a list of ids of nodes when a wrong path length according to steplen

  3. a list of ids of orphaned nodes

  4. a list of ids of nodes with the wrong depth value for their path

  5. 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_breadcrumb()
get_breadcrumb_json()
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

actionread 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, returns False

is_descendant_of(node)
Returns

True if the node is a descendant of another node given as an argument, else, returns False

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, returns False

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, and

    • children: a list of dictionaries, each one has it’s own data and children 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 id that are given in the structure. Will error if there are nodes without id info or if the ids 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.