Using register_concept to connect new concept types

Aristotle-MDR concept register

This module allows developers to easily register new concept models with the core functionality of Aristotle-MDR. The register_concept is a wrapper around three methods that registers a new concept with the Django-Admin site, with the Django-Autocomplete and with a class for a Haystack search index. This is all done in a way that conforms to the permissions required for control item visibility.

Other methods in this module can be called, to highly customise how concepts are used within the admin site and search, but should be considered internal methods and future releases of Aristotle-MDR may break code that uses these methods.

aristotle_mdr.register.register_concept(concept_class, *args, **kwargs)[source]

A handler for third-party apps to make registering extension models based on aristotle_mdr.models.concept easier.

Sets up the version controls, search indexes, django administrator page and autocomplete handlers. All args and kwargs are passed to the called methods. For examples of what can be passed into this method review the other methods in aristotle_mdr.register.

Example usage (based on the models in the extensions test suite):

register_concept(Question, extra_fieldsets=[(‘Question’,’question_text’),]
aristotle_mdr.register.register_concept_admin(concept_class, *args, **kwargs)[source]

Registers the given concept with the Django admin backend based on the default aristotle_mdr.admin.ConceptAdmin.

Additional parameters are only required if a model has additional fields or references to other models.

Parameters:
  • auto_fieldsets (boolean) – If no extra_fieldsets, when set to true this generates a list of fields for the admin page as “Extra fields for [class]”
  • concept_class (concept) – The model that is to be registered
  • extra_fieldsets (list) – Model-specific fieldsets to be displayed. Fields in the tuples given should be those not defined by the base aristotle_mdr.models._concept class.
  • extra_inlines (list) – Model-specific inline admin forms to be displayed.
aristotle_mdr.register.register_concept_search_index(concept_class, *args, **kwargs)[source]

Registers the given concept with a Haystack search index that conforms to Aristotle permissions. If the concept to be registered does not have a template for serving a search document, a basic document with just the basic fields from aristotle_mdr.models._concept will be used when indexing items.

Parameters:concept_class (concept) – The model that is to be registered for searching.