apis_core.apis_relations package
Subpackages
- apis_core.apis_relations.migrations package
- Submodules
- apis_core.apis_relations.migrations.0001_initial module
- apis_core.apis_relations.migrations.0002_property_property_class_uri module
- apis_core.apis_relations.migrations.0003_auto_20230123_1715 module
- apis_core.apis_relations.migrations.0004_auto_20230124_1201 module
- apis_core.apis_relations.migrations.0005_alter_property_obj_class_alter_property_subj_class module
- apis_core.apis_relations.migrations.0006_versiontemptriple module
Submodules
apis_core.apis_relations.admin module
apis_core.apis_relations.apps module
apis_core.apis_relations.filtersets module
- class apis_core.apis_relations.filtersets.HistoricalTempTripleFilterSet(data=None, queryset=None, *, request=None, prefix=None)[source]
Bases:
TripleFilterSet
- base_filters = {'obj': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj': <django_filters.filters.CharFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
- declared_filters = {'obj': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj': <django_filters.filters.CharFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
- class apis_core.apis_relations.filtersets.HistoricalTripleFilterSet(data=None, queryset=None, *, request=None, prefix=None)[source]
Bases:
TripleFilterSet
- base_filters = {'obj': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj': <django_filters.filters.CharFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
- declared_filters = {'obj': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj': <django_filters.filters.CharFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
- class apis_core.apis_relations.filtersets.PropertyFilterSet(data=None, queryset=None, *, request=None, prefix=None)[source]
Bases:
GenericFilterSet
- class Meta[source]
Bases:
object
- exclude = ['self_contenttype', 'property_class_uri', 'rootobject_ptr']
- form
alias of
PropertyFilterSetForm
- base_filters = {'name_forward': <django_filters.filters.CharFilter object>, 'name_reverse': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
- declared_filters = {'name_forward': <django_filters.filters.CharFilter object>, 'name_reverse': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
- class apis_core.apis_relations.filtersets.PropertyFilterSetForm(*args, **kwargs)[source]
Bases:
GenericFilterSetForm
- base_fields = {}
- columns_exclude = ['self_contenttype', 'property_class_uri', 'rootobject_ptr']
- declared_fields = {}
- property media
Return all media required to render the widgets on this form.
- class apis_core.apis_relations.filtersets.PropertySubjObjFilter(*args, **kwargs)[source]
Bases:
ModelMultipleChoiceFilter
- class apis_core.apis_relations.filtersets.TripleFilterSet(data=None, queryset=None, *, request=None, prefix=None)[source]
Bases:
GenericFilterSet
- base_filters = {'obj': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj': <django_filters.filters.CharFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
- declared_filters = {'obj': <django_filters.filters.CharFilter object>, 'obj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>, 'subj': <django_filters.filters.CharFilter object>, 'subj_class': <apis_core.apis_relations.filtersets.PropertySubjObjFilter object>}
apis_core.apis_relations.forms module
- class apis_core.apis_relations.forms.GenericTripleForm(entity_type_self_str, entity_type_other_str)[source]
Bases:
ModelForm
- class Meta[source]
Bases:
object
- fields = ['subj', 'obj', 'prop', 'start_date_written', 'end_date_written', 'notes']
- model
alias of
TempTriple
- widgets = {'obj': <django.forms.widgets.HiddenInput object>, 'prop': <django.forms.widgets.HiddenInput object>, 'subj': <django.forms.widgets.HiddenInput object>}
- base_fields = {'end_date_written': <django.forms.fields.CharField object>, 'notes': <django.forms.fields.CharField object>, 'obj': <django.forms.models.ModelChoiceField object>, 'prop': <django.forms.models.ModelChoiceField object>, 'start_date_written': <django.forms.fields.CharField object>, 'subj': <django.forms.models.ModelChoiceField object>}
- declared_fields = {}
- get_text_id()[source]
Function to retrieve the highlighted text. :return: ID of text that was highlighted
- load_subj_obj_prop(entity_instance_self, entity_instance_other, property_instance, property_direction)[source]
- property media
Return all media required to render the widgets on this form.
apis_core.apis_relations.models module
- class apis_core.apis_relations.models.InheritanceForeignKey(to, on_delete, related_name=None, related_query_name=None, limit_choices_to=None, parent_link=False, to_field=None, db_constraint=True, **kwargs)[source]
Bases:
ForeignKey
- class apis_core.apis_relations.models.InheritanceForwardManyToOneDescriptor(field_with_rel)[source]
Bases:
ForwardManyToOneDescriptor
- class apis_core.apis_relations.models.Property(id, self_contenttype, rootobject_ptr, property_class_uri, name_forward, name_reverse)[source]
Bases:
RootObject
- exception DoesNotExist
Bases:
DoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- name_forward
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name_reverse
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- obj_class
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- objects = <apis_core.apis_relations.models.BaseRelationManager object>
- property_class_uri
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- rootobject_ptr
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.place
is aForwardOneToOneDescriptor
instance.
- rootobject_ptr_id
- save(*args, **kwargs)[source]
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.
- subj_class
Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
Pizza.toppings
andTopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- triple_set_from_prop
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- class apis_core.apis_relations.models.RelationPublishedQueryset(model=None, query=None, using=None, hints=None)[source]
Bases:
QuerySet
- class apis_core.apis_relations.models.TempTriple(id, subj, obj, prop, triple_ptr, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, references, notes)[source]
Bases:
Triple
,VersionMixin
- exception DoesNotExist
Bases:
DoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- end_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- end_date_written
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- end_end_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- end_start_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>
- notes
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- references
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- review
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- save(parse_dates=True, *args, **kwargs)[source]
Adaption of the save() method of the class to automatically parse string-dates into date objects
- start_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_date_written
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_end_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_start_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- triple_ptr
Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Restaurant.place
is aForwardOneToOneDescriptor
instance.
- triple_ptr_id
- class apis_core.apis_relations.models.Triple(id, subj, obj, prop)[source]
Bases:
Model
,GenericModel
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- obj
- obj_id
- objects = <apis_core.apis_relations.models.BaseRelationManager object>
- objects_inheritance = <model_utils.managers.InheritanceManager object>
- prop
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- prop_id
- save(*args, **kwargs)[source]
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.
- subj
- subj_id
- temptriple
Accessor to the related object on the reverse side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
Place.restaurant
is aReverseOneToOneDescriptor
instance.
- class apis_core.apis_relations.models.VersionTempTriple(triple_ptr, id, version_tag, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, references, notes, subj, obj, prop, history_id, history_date, history_change_reason, history_type, history_user)
Bases:
HistoricalChanges
,APISHistoryTableBase
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- end_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- end_date_written
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- end_end_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- end_start_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- static get_default_history_user(instance)
Returns the user specified by get_user method for manually creating historical objects
- get_history_type_display(*, field=<django.db.models.fields.CharField: history_type>)
- get_next_by_history_date(*, field=<django.db.models.fields.DateTimeField: history_date>, is_next=True, **kwargs)
- get_previous_by_history_date(*, field=<django.db.models.fields.DateTimeField: history_date>, is_next=False, **kwargs)
- history_change_reason
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- history_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- history_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- history_object
- history_type
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- history_user
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- history_user_id
- id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property instance
- instance_type
alias of
TempTriple
- property next_record
Get the next history record for the instance. None if last.
- notes
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- obj
- obj_id
- objects = <django.db.models.manager.Manager object>
- property prev_record
Get the previous history record for the instance. None if first.
- prop
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- prop_id
- references
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- revert_url()
URL for this change in the default admin site.
- review
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_date_written
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_end_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- start_start_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- subj
- subj_id
- tracked_fields = [<django.db.models.fields.AutoField: id>, <apis_core.apis_relations.models.InheritanceForeignKey: subj>, <apis_core.apis_relations.models.InheritanceForeignKey: obj>, <django.db.models.fields.related.ForeignKey: prop>, <django.db.models.fields.related.OneToOneField: triple_ptr>, <django.db.models.fields.BooleanField: review>, <django.db.models.fields.DateField: start_date>, <django.db.models.fields.DateField: start_start_date>, <django.db.models.fields.DateField: start_end_date>, <django.db.models.fields.DateField: end_date>, <django.db.models.fields.DateField: end_start_date>, <django.db.models.fields.DateField: end_end_date>, <django.db.models.fields.CharField: start_date_written>, <django.db.models.fields.CharField: end_date_written>, <django.db.models.fields.CharField: status>, <django.db.models.fields.TextField: references>, <django.db.models.fields.TextField: notes>]
- triple_ptr
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- triple_ptr_id
- version_tag
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
apis_core.apis_relations.signals module
apis_core.apis_relations.tables module
- class apis_core.apis_relations.tables.PropertyTable(data=None, order_by=None, orderable=None, empty_text=None, exclude=None, attrs=None, row_attrs=None, pinned_row_attrs=None, sequence=None, prefix=None, order_by_field=None, page_field=None, per_page_field=None, template_name=None, default=None, request=None, show_header=None, show_footer=True, extra_columns=None)[source]
Bases:
GenericTable
Construct table for properties.
The table shows how entities connect with one another via properties (relations). It uses the format of an RDF triple – Subject-Predicate-Object – plus “Reverse Predicate” for the inverse relationship and is displayed on the frontend on the Relations > Property page.
- class Meta[source]
Bases:
Meta
- exclude = ['desc']
- fields = ['subject', 'predicate', 'object', 'predicate_reverse']
- order_by = 'predicate'
- sequence = ('subject', 'predicate', 'object', 'predicate_reverse', '...', 'view', 'edit', 'delete')
- base_columns = {'delete': <apis_core.generic.tables.DeleteColumn object>, 'edit': <apis_core.generic.tables.EditColumn object>, 'object': <apis_core.apis_relations.tables.SubjObjColumn object>, 'predicate': <django_tables2.columns.base.Column object>, 'predicate_reverse': <django_tables2.columns.base.Column object>, 'subject': <apis_core.apis_relations.tables.SubjObjColumn object>, 'view': <apis_core.generic.tables.ViewColumn object>}
- class apis_core.apis_relations.tables.SubjObjColumn(*args, **kwargs)[source]
Bases:
ManyToManyColumn
- class apis_core.apis_relations.tables.TripleTable(data=None, order_by=None, orderable=None, empty_text=None, exclude=None, attrs=None, row_attrs=None, pinned_row_attrs=None, sequence=None, prefix=None, order_by_field=None, page_field=None, per_page_field=None, template_name=None, default=None, request=None, show_header=None, show_footer=True, extra_columns=None)[source]
Bases:
GenericTable
- class Meta[source]
Bases:
Meta
- exclude = ['desc']
- fields = ['id', 'subj', 'prop', 'obj']
- sequence = ('id', 'subj', 'prop', 'obj', '...', 'view', 'edit', 'delete')
- base_columns = {'delete': <apis_core.generic.tables.DeleteColumn object>, 'edit': <apis_core.generic.tables.EditColumn object>, 'obj': <django_tables2.columns.base.Column object>, 'subj': <django_tables2.columns.base.Column object>, 'view': <apis_core.generic.tables.ViewColumn object>}
- class apis_core.apis_relations.tables.TripleTableBase(data, *args, **kwargs)[source]
Bases:
GenericTable
The base table from which detail or edit tables will inherit from in order to avoid redundant definitions
- class Meta[source]
Bases:
object
- exclude = ('desc', 'view')
- fields = ['start_date_written', 'end_date_written', 'other_prop', 'other_entity', 'notes']
- model
alias of
TempTriple
- sequence = ('start_date_written', 'end_date_written', 'other_prop', 'other_entity', 'notes')
- base_columns = {'delete': <apis_core.generic.tables.DeleteColumn object>, 'edit': <apis_core.generic.tables.EditColumn object>, 'end_date_written': <django_tables2.columns.base.Column object>, 'notes': <django_tables2.columns.base.Column object>, 'other_entity': <django_tables2.columns.base.Column object>, 'other_prop': <django_tables2.columns.base.Column object>, 'start_date_written': <django_tables2.columns.base.Column object>}
- render_other_entity(record, value)[source]
Custom render_FOO method for related entity linking. Since the ‘other_related_entity’ is a generated annotation on the queryset, it does not return the related instance but only the foreign key as the integer it is. Thus fetching the related instance is necessary.
- Parameters:
record – The ‘row’ of a queryset, i.e. an entity instance
value – The current column of the row, i.e. the ‘other_related_entity’ annotation
- Returns:
related instance
- class apis_core.apis_relations.tables.TripleTableDetail(data, *args, **kwargs)[source]
Bases:
TripleTableBase
- base_columns = {'end_date_written': <django_tables2.columns.base.Column object>, 'notes': <django_tables2.columns.base.Column object>, 'other_entity': <django_tables2.columns.base.Column object>, 'other_prop': <django_tables2.columns.base.Column object>, 'start_date_written': <django_tables2.columns.base.Column object>}
- class apis_core.apis_relations.tables.TripleTableEdit(*args, **kwargs)[source]
Bases:
TripleTableBase
- class Meta[source]
Bases:
Meta
- fields = ['start_date_written', 'end_date_written', 'other_prop', 'other_entity', 'notes']
- sequence = ('start_date_written', 'end_date_written', 'other_prop', 'other_entity', 'notes')
- base_columns = {'delete': <apis_core.generic.tables.DeleteColumn object>, 'edit': <apis_core.generic.tables.EditColumn object>, 'end_date_written': <django_tables2.columns.base.Column object>, 'notes': <django_tables2.columns.base.Column object>, 'other_entity': <django_tables2.columns.base.Column object>, 'other_prop': <django_tables2.columns.base.Column object>, 'start_date_written': <django_tables2.columns.base.Column object>}