EquationPlugin¶
-
class
EquationPlugin
(model=None, admin_site=None)[source]¶ Implementation of the actual plugin.
Attributes Summary
actions
actions_on_bottom
actions_on_top
actions_selection_counter
add_form_template
admin_preview
allow_children
autocomplete_fields
cache
cache_child_classes
cache_parent_classes
change_form_template
change_list_template
child_classes
date_hierarchy
delete_confirmation_template
delete_selected_confirmation_template
disable_child_plugins
exclude
fields
fieldsets
filter_horizontal
filter_vertical
formfield_overrides
inlines
list_display
list_display_links
list_editable
list_filter
list_max_show_all
list_per_page
list_select_related
media
module
name
object_history_template
opts
ordering
page_only
parent_classes
plugin_urls
popup_response_template
prepopulated_fields
preserve_filters
radio_fields
raw_id_fields
readonly_fields
render_plugin
render_template
require_parent
save_as
save_as_continue
save_on_top
search_fields
show_full_result_count
sortable_by
system
text_editor_preview
text_enabled
urls
value
view_on_site
Methods Summary
A list_display column containing a checkbox widget.
The ‘change list’ admin view for this model.
Construct a JSON structure describing changes from a changed object.
Given a model instance delete it from the database.
Given a queryset, delete it from the database.
Get a form Field for a database Field that has declared choices.
Hook for specifying the form Field instance for a given database Field instance.
Get a form Field for a ForeignKey.
Get a form Field for a ManyToManyField.
Return a given action from a parameter, which can either be a callable, or the name of a method on the ModelAdmin.
Return a list of choices for use in a form object.
Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action.
Return a list of ForeignKey and/or ManyToMany fields which should use an autocomplete widget.
Provides hints to the placeholder, and in turn to the page for determining the appropriate Cache-Control headers to add to the HTTPResponse object.
Get the initial form data from the request’s GET params.
Return the ChangeList class for use on the changelist page.
Return a Form class for use in the Formset on the changelist page.
Return a FormSet class for use on the changelist page if list_editable is used.
Return a ChangeList instance based on request.
Returns a list of plugin types that are allowed as children of this plugin.
Returns a list of plugin types that can be added as children to this plugin.
Returns a list of all plugin classes that will be considered when fetching all available child classes for this plugin.
Hook for customizing the delete process for the delete view and the “delete selected” action.
Returns the text displayed to the user when editing a plugin that requires no configuration.
Return the empty_value_display set on ModelAdmin or AdminSite.
Hook for specifying exclude.
If the ModelAdmin specifies ordering, the queryset should respect that ordering.
Hook for specifying fields.
Same as from base class except if there are no fields, show an info message.
Return a Form class for use in the admin add view.
Yield formsets and the corresponding inlines.
Return a sequence containing the fields to be displayed on the changelist.
Return a sequence containing the fields to be displayed as links on the changelist.
Return a sequence containing the fields to be displayed as filters in the right sidebar of the changelist page.
Return a list of fields to add to the select_related() part of the changelist items query.
Return a dict of all perms for this model.
Return an instance matching the field and value provided, the primary key is used if no field is provided.
Hook for specifying field ordering.
Return URL patterns for which the plugin wants to register views for.
Hook for specifying custom prepopulated fields.
Return the preserved filters querystring.
Return a QuerySet of all model instances that can be edited by the admin site.
Hook for specifying custom readonly fields.
Return a sequence containing the fields to be searched whenever somebody submits a search query.
Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
Hook for specifying which fields can be sorted in the changelist.
Provides hints to the placeholder, and in turn to the page for determining VARY headers for the response.
Return True if the given request has permission to add an object.
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Return True if the given request has any permission in the given app label.
Return True if the given request has permission to view the given Django model instance.
The ‘history’ admin view for this model.
Return the alt text for the shown icon.
Return the path to an icon which is shown in the text editor.
Check if the plugin was added to a text plugin.
Log that an object has been successfully added.
Log that an object has been successfully changed.
Log that an object will be deleted.
Send a message to the user.
Render the Plugin with self.render_template and the data in instance.
We just need the popup interface here
Handle an admin action.
Determine the HttpResponse for the add_view stage.
Determine the HttpResponse for the change_view stage.
Determine the HttpResponse for the delete_view stage.
Figure out where to redirect after the ‘Save’ button has been pressed when adding a new object.
Figure out where to redirect after the ‘Save’ button has been pressed when editing an existing object.
Given a ModelForm return an unsaved instance.
Given an inline formset save it to the database.
Override original method, and add some attributes to obj This have to be made, because if object is newly created, he must know where he lives.
Given the
HttpRequest
, the parentModelForm
instance, the list of inline formsets and a boolean value based on whether the parent is being added or changed, save the related objects to the database.Return True if the model associated with this admin should be allowed to be referenced by the specified field.
Methods Documentation
-
action_checkbox
(obj)¶ A list_display column containing a checkbox widget.
-
add_view
(request, form_url='', extra_context=None)¶
-
autocomplete_view
(request)¶
-
change_view
(request, object_id, form_url='', extra_context=None)¶
-
changeform_view
(request, object_id=None, form_url='', extra_context=None)¶
-
changelist_view
(request, extra_context=None)¶ The ‘change list’ admin view for this model.
-
check
(**kwargs)¶
-
construct_change_message
(request, form, formsets, add=False)¶ Construct a JSON structure describing changes from a changed object.
-
delete_model
(request, obj)¶ Given a model instance delete it from the database.
-
delete_queryset
(request, queryset)¶ Given a queryset, delete it from the database.
-
delete_view
(request, object_id, extra_context=None)¶
-
formfield_for_choice_field
(db_field, request, **kwargs)¶ Get a form Field for a database Field that has declared choices.
-
formfield_for_dbfield
(db_field, request, **kwargs)¶ Hook for specifying the form Field instance for a given database Field instance.
If kwargs are given, they’re passed to the form Field’s constructor.
-
formfield_for_foreignkey
(db_field, request, **kwargs)¶ Get a form Field for a ForeignKey.
-
formfield_for_manytomany
(db_field, request, **kwargs)¶ Get a form Field for a ManyToManyField.
-
get_action
(action)¶ Return a given action from a parameter, which can either be a callable, or the name of a method on the ModelAdmin. Return is a tuple of (callable, name, description).
-
get_action_choices
(request, default_choices=[('', '---------')])¶ Return a list of choices for use in a form object. Each choice is a tuple (name, description).
-
get_actions
(request)¶ Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action.
-
get_autocomplete_fields
(request)¶ Return a list of ForeignKey and/or ManyToMany fields which should use an autocomplete widget.
-
get_cache_expiration
(request, instance, placeholder)¶ Provides hints to the placeholder, and in turn to the page for determining the appropriate Cache-Control headers to add to the HTTPResponse object.
- Must return one of:
None: This means the placeholder and the page will not even consider this plugin when calculating the page expiration;
A TZ-aware datetime of a specific date and time in the future when this plugin’s content expires;
A datetime.timedelta instance indicating how long, relative to the response timestamp that the content can be cached;
An integer number of seconds that this plugin’s content can be cached.
- There are constants are defined in cms.constants that may be helpful:
EXPIRE_NOW
MAX_EXPIRATION_TTL
An integer value of 0 (zero) or EXPIRE_NOW effectively means “do not cache”. Negative values will be treated as EXPIRE_NOW. Values exceeding the value MAX_EXPIRATION_TTL will be set to that value.
Negative timedelta values or those greater than MAX_EXPIRATION_TTL will also be ranged in the same manner.
Similarly, datetime values earlier than now will be treated as EXPIRE_NOW. Values greater than MAX_EXPIRATION_TTL seconds in the future will be treated as MAX_EXPIRATION_TTL seconds in the future.
-
get_changeform_initial_data
(request)¶ Get the initial form data from the request’s GET params.
-
get_changelist
(request, **kwargs)¶ Return the ChangeList class for use on the changelist page.
-
get_changelist_form
(request, **kwargs)¶ Return a Form class for use in the Formset on the changelist page.
-
get_changelist_formset
(request, **kwargs)¶ Return a FormSet class for use on the changelist page if list_editable is used.
-
get_changelist_instance
(request)¶ Return a ChangeList instance based on request. May raise IncorrectLookupParameters.
-
classmethod
get_child_class_overrides
(slot, page)¶ Returns a list of plugin types that are allowed as children of this plugin.
-
classmethod
get_child_classes
(slot, page, instance=None)¶ Returns a list of plugin types that can be added as children to this plugin.
-
classmethod
get_child_plugin_candidates
(slot, page)¶ Returns a list of all plugin classes that will be considered when fetching all available child classes for this plugin.
-
get_deleted_objects
(objs, request)¶ Hook for customizing the delete process for the delete view and the “delete selected” action.
-
classmethod
get_empty_change_form_text
(obj=None)¶ Returns the text displayed to the user when editing a plugin that requires no configuration.
-
get_empty_value_display
()¶ Return the empty_value_display set on ModelAdmin or AdminSite.
-
get_exclude
(request, obj=None)¶ Hook for specifying exclude.
-
get_field_queryset
(db, db_field, request)¶ If the ModelAdmin specifies ordering, the queryset should respect that ordering. Otherwise don’t specify the queryset, let the field decide (return None in that case).
-
get_fields
(request, obj=None)¶ Hook for specifying fields.
-
get_fieldsets
(request, obj=None)¶ Same as from base class except if there are no fields, show an info message.
-
get_form
(request, obj=None, change=False, **kwargs)¶ Return a Form class for use in the admin add view. This is used by add_view and change_view.
-
get_formsets_with_inlines
(request, obj=None)¶ Yield formsets and the corresponding inlines.
-
get_inline_formsets
(request, formsets, inline_instances, obj=None)¶
-
get_inline_instances
(request, obj=None)¶
-
get_list_display
(request)¶ Return a sequence containing the fields to be displayed on the changelist.
-
get_list_display_links
(request, list_display)¶ Return a sequence containing the fields to be displayed as links on the changelist. The list_display parameter is the list of fields returned by get_list_display().
-
get_list_filter
(request)¶ Return a sequence containing the fields to be displayed as filters in the right sidebar of the changelist page.
Return a list of fields to add to the select_related() part of the changelist items query.
-
get_model_perms
(request)¶ Return a dict of all perms for this model. This dict has the keys
add
,change
,delete
, andview
mapping to the True/False for each of those actions.
-
get_object
(request, object_id, from_field=None)¶ Return an instance matching the field and value provided, the primary key is used if no field is provided. Return
None
if no match is found or the object_id fails validation.
-
get_ordering
(request)¶ Hook for specifying field ordering.
-
get_paginator
(request, queryset, per_page, orphans=0, allow_empty_first_page=True)¶
-
classmethod
get_parent_classes
(slot, page, instance=None)¶
-
get_plugin_urls
()¶ Return URL patterns for which the plugin wants to register views for.
-
get_prepopulated_fields
(request, obj=None)¶ Hook for specifying custom prepopulated fields.
-
get_preserved_filters
(request)¶ Return the preserved filters querystring.
-
get_queryset
(request)¶ Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
-
get_readonly_fields
(request, obj=None)¶ Hook for specifying custom readonly fields.
-
classmethod
get_render_queryset
()¶
-
classmethod
get_require_parent
(slot, page)¶
-
get_search_fields
(request)¶ Return a sequence containing the fields to be searched whenever somebody submits a search query.
-
get_search_results
(request, queryset, search_term)¶ Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
-
get_sortable_by
(request)¶ Hook for specifying which fields can be sorted in the changelist.
-
get_urls
()¶
-
get_vary_cache_on
(request, instance, placeholder)¶ Provides hints to the placeholder, and in turn to the page for determining VARY headers for the response.
- Must return one of:
None (default),
String of a case-sensitive header name, or
iterable of case-sensitive header names.
NOTE: This only makes sense to use with caching. If this plugin has
cache = False
or plugin.get_cache_expiration(…) returns 0, get_vary_cache_on() will have no effect.
-
get_view_on_site_url
(obj=None)¶
-
has_add_permission
(request)¶ Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
-
has_change_permission
(request, obj=None)¶ Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to change the obj model instance. If obj is None, this should return True if the given request has permission to change any object of the given type.
-
has_delete_permission
(request, obj=None)¶ Return True if the given request has permission to change the given Django model instance, the default implementation doesn’t examine the obj parameter.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to delete the obj model instance. If obj is None, this should return True if the given request has permission to delete any object of the given type.
-
has_module_permission
(request)¶ Return True if the given request has any permission in the given app label.
Can be overridden by the user in subclasses. In such case it should return True if the given request has permission to view the module on the admin index page and access the module’s index page. Overriding it does not restrict access to the add, change or delete views. Use ModelAdmin.has_(add|change|delete)_permission for that.
-
has_view_or_change_permission
(request, obj=None)¶
-
has_view_permission
(request, obj=None)¶ Return True if the given request has permission to view the given Django model instance. The default implementation doesn’t examine the obj parameter.
If overridden by the user in subclasses, it should return True if the given request has permission to view the obj model instance. If obj is None, it should return True if the request has permission to view any object of the given type.
-
history_view
(request, object_id, extra_context=None)¶ The ‘history’ admin view for this model.
-
icon_alt
(instance)[source]¶ Return the alt text for the shown icon.
This is used in django-cms==3.4 only.
- Parameters
instance (EquationPluginModel) – Instance of the plugins Model
- Returns
Path to the icon.
- Return type
str
See also
-
icon_src
(instance)[source]¶ Return the path to an icon which is shown in the text editor.
This is used in django-cms==3.4 only.
- Parameters
instance (EquationPluginModel) – Instance of the plugins Model
- Returns
Path to the icon.
- Return type
str
-
is_in_text_editor
(instance)[source]¶ Check if the plugin was added to a text plugin.
- Parameters
instance (EquationPluginModel) – Instance of the plugins Model
- Returns
True if the plugin was added to a text plugin (‘djangocms-text-ckeditor’) or False if it was added to page as stand alone element.
- Return type
bool
-
log_addition
(request, obj, bypass=None)¶ Log that an object has been successfully added.
The default implementation creates an admin LogEntry object.
-
log_change
(request, obj, message, bypass=None)¶ Log that an object has been successfully changed.
The default implementation creates an admin LogEntry object.
-
log_deletion
(request, obj, object_repr, bypass=None)¶ Log that an object will be deleted. Note that this method must be called before the deletion.
The default implementation creates an admin LogEntry object.
-
lookup_allowed
(lookup, value)¶
-
message_user
(request, message, level=20, extra_tags='', fail_silently=False)¶ Send a message to the user. The default implementation posts a message using the django.contrib.messages backend.
Exposes almost the same API as messages.add_message(), but accepts the positional arguments in a different order to maintain backwards compatibility. For convenience, it accepts the level argument as a string rather than the usual level number.
-
render
(context, instance, placeholder)[source]¶ Render the Plugin with self.render_template and the data in instance.
- Parameters
context (dict) – [description]
instance (EquationPluginModel) – Instance of the plugins Model
placeholder (str) – [description]
- Returns
[description]
- Return type
dict
-
render_change_form
(request, context, add=False, change=False, form_url='', obj=None)¶ We just need the popup interface here
-
render_close_frame
(request, obj, extra_context=None)¶
-
render_delete_form
(request, context)¶
-
classmethod
requires_parent_plugin
(slot, page)¶
-
response_action
(request, queryset)¶ Handle an admin action. This is called if a request is POSTed to the changelist; it returns an HttpResponse if the action was handled, and None otherwise.
-
response_add
(request, obj, **kwargs)¶ Determine the HttpResponse for the add_view stage.
-
response_change
(request, obj)¶ Determine the HttpResponse for the change_view stage.
-
response_delete
(request, obj_display, obj_id)¶ Determine the HttpResponse for the delete_view stage.
-
response_post_save_add
(request, obj)¶ Figure out where to redirect after the ‘Save’ button has been pressed when adding a new object.
-
response_post_save_change
(request, obj)¶ Figure out where to redirect after the ‘Save’ button has been pressed when editing an existing object.
-
save_form
(request, form, change)¶ Given a ModelForm return an unsaved instance.
change
is True if the object is being changed, and False if it’s being added.
-
save_formset
(request, form, formset, change)¶ Given an inline formset save it to the database.
-
save_model
(request, obj, form, change)¶ Override original method, and add some attributes to obj This have to be made, because if object is newly created, he must know where he lives.
Given the
HttpRequest
, the parentModelForm
instance, the list of inline formsets and a boolean value based on whether the parent is being added or changed, save the related objects to the database. Note that at this point save_form() and save_model() have already been called.
-
to_field_allowed
(request, to_field)¶ Return True if the model associated with this admin should be allowed to be referenced by the specified field.
-