apis_core.apis_relations package

Subpackages

Submodules

apis_core.apis_relations.admin module

apis_core.apis_relations.apps module

class apis_core.apis_relations.apps.RelationsConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.AutoField'
name = 'apis_core.apis_relations'
ready()[source]

Override this method in subclasses to run code when Django starts.

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

get_queryset(request)[source]
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>}
class_in(queryset, name, value)[source]
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>}
obj_icontains(queryset, name, value)[source]
subj_icontains(queryset, name, value)[source]

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_html_table(entity_instance_self, entity_instance_other, request)[source]
get_text_id()[source]

Function to retrieve the highlighted text. :return: ID of text that was highlighted

load_remaining_data_from_input(start_date_written, end_date_written)[source]
load_remaining_data_from_triple(triple)[source]
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.

save()[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

apis_core.apis_relations.models module

class apis_core.apis_relations.models.BaseRelationManager(*args, **kwargs)[source]

Bases: Manager

filter_ann_proj(request=None, ann_proj=1, include_all=True)[source]
filter_for_user()[source]
get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.

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

alias of InheritanceForwardManyToOneDescriptor

class apis_core.apis_relations.models.InheritanceForwardManyToOneDescriptor(field_with_rel)[source]

Bases: ForwardManyToOneDescriptor

get_queryset(**hints)[source]
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 and Topping.pizzas are ManyToManyDescriptor 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 a ForwardOneToOneDescriptor 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 and Topping.pizzas are ManyToManyDescriptor 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 a ReverseManyToOneDescriptor 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

filter_ann_proj(request=None, ann_proj=1, include_all=True)[source]

The filter function provided by the manager class.

Parameters:

requestdjango.request object

Returns:

queryset that contains only objects that are shown in the highlighted text or those not connected to an annotation at all.

filter_for_user(*args, **kwargs)[source]
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 a ForwardOneToOneDescriptor 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

duplicate()[source]
get_web_object()[source]
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 a ForwardManyToOneDescriptor 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 a ReverseOneToOneDescriptor 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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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 a ForwardManyToOneDescriptor 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.models.find_if_user_accepted()[source]
apis_core.apis_relations.models.obj_class_changed(sender, **kwargs)[source]
apis_core.apis_relations.models.subj_class_changed(sender, **kwargs)[source]
apis_core.apis_relations.models.subj_or_obj_class_changed(sender, is_subj, **kwargs)[source]

apis_core.apis_relations.signals module

apis_core.apis_relations.signals.copy_relations(sender, instance, duplicate, **kwargs)[source]

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>}
order_object(queryset, is_descending)[source]
order_subject(queryset, is_descending)[source]
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>}
order_end_date_written(queryset, is_descending)[source]
order_start_date_written(queryset, is_descending)[source]
render_end_date_written(record, value)[source]
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

render_start_date_written(record, value)[source]
class apis_core.apis_relations.tables.TripleTableDetail(data, *args, **kwargs)[source]

Bases: TripleTableBase

class Meta[source]

Bases: Meta

exclude = ('desc', 'view', 'delete', 'edit')
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>}
apis_core.apis_relations.tables.get_generic_triple_table(other_entity_class_name, entity_pk_self, detail)[source]

apis_core.apis_relations.urls module

apis_core.apis_relations.views module

class apis_core.apis_relations.views.GenericRelationView(**kwargs)[source]

Bases: List

Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.

setup(*args, **kwargs)[source]

Initialize attributes shared by all view methods.

apis_core.apis_relations.views.get_form_ajax(request)[source]

Returns forms rendered in html

apis_core.apis_relations.views.save_ajax_form(request, entity_type, kind_form, SiteID, ObjectID=False)[source]

Tests validity and saves AjaxForms, returns them when validity test fails