Entities¶
In the entities app all 5 core entites - Person, Place, Institution, Event and Work are saved.
Models¶
- class apis_core.apis_entities.models.AbstractEntity(*args, **kwargs)[source]¶
Abstract super class which encapsulates common logic between the different entity kinds and provides various methods relating to either all or a specific entity kind.
Most of the class methods are designed to be used in the sublcass as they are considering contexts which depend on the subclass entity type. So they are to be understood in that dynamic context.
- Parameters:
entity_field_name – the name of one of several ManyToMany fields created automatically
- Returns:
None
Note: this method depends on the ‘generate_all_fields’ function of the EntityRelationFieldGenerator class which wires the ManyToMany Fields into the entities and respective relationtypes. This method is nevertheless defined here within AbstractEntity for documentational purpose.
- Parameters:
entity_field_name – the name of one of several ManyToMany fields created automatically
- Returns:
None
Note: this method depends on the ‘generate_all_fields’ function of the EntityRelationFieldGenerator class which wires the ManyToMany Fields into the entities and respective relationtypes. This method is nevertheless defined here within AbstractEntity for documentational purpose.
- classmethod create_relation_methods_from_manytomany_fields()[source]¶
Creates methods on an entity class with which other related entities can be called without the need to consider potential self-references (the A and B sides therein).
The resulting methods follow the syntax: <entity>.get_related_<entity>_instances()
e.g. for Person: person.get_related_work_instances() or person.get_related_person_instances()
Note that with these methods it is not necessary to differentiate between A and B entities when self-relations exist.
The result of any such method call is the queryset of the related entities. (And not a ManyToManyManager as is the case when calling <entity>.<entity>_set where in the case of self-relation it must be differentiated between A and B entities, e.g. person.personA_set )
It was not possible to my understanding to change managers in such a way that two (the A and the B) could be combined into one manager. Hence these additional shortcut methods.
- Returns:
None
- classmethod get_all_entity_classes()[source]¶
- Returns:
list of all python classes of the entities defined within this models’ module
- classmethod get_all_entity_names()[source]¶
- Returns:
list of all class names in lower case of the entities defined within this models’ module
- classmethod get_entity_class_of_name(entity_name)[source]¶
- Parameters:
entity_name – str : The name of an entity
- Returns:
The model class of the entity respective to the given name
- Returns:
a list of names of all ManyToMany field names relating to entities from the respective entity class
E.g. for Person.get_related_entity_field_names() or person_instance.get_related_entity_field_names() -> [‘event_set’, ‘institution_set’, ‘personB_set’, ‘personA_set’, ‘place_set’, ‘work_set’]
Note: this method depends on the ‘generate_all_fields’ function of the EntityRelationFieldGenerator class which wires the ManyToMany Fields into the entities and respective relationtypes. This method is nevertheless defined here within AbstractEntity for documentational purpose.
- Returns:
list of queryset of all entity instances which are somehow related to the calling entity instance
- Returns:
list of python classes of the relations which are related to the respective entity class
E.g. for Place.get_related_relation_classes() or place_instance.get_related_relation_classes() -> [ InstitutionPlace, PersonPlace, PlaceEvent, PlacePlace, PlaceWork ]
- Returns:
list of class names in lower case of the relations which are related to the respective entity class
E.g. for Place.get_related_relation_names() or place_instance.get_related_relation_names() -> [‘institutionplace_set’, ‘personplace_set’, ‘placeevent_set’, ‘placeplace_set’, ‘placework_set’]
- Returns:
list of queryset of all relation instances which are somehow related to the calling entity instance
- Returns:
list of python classes of the relation types which are related to the respective entity class
E.g. for Place.get_related_relation_classes() or place_instance.get_related_relation_classes() -> [ InstitutionPlaceRelation, PersonPlaceRelation, PlaceEventRelation, PlacePlaceRelation, PlaceWorkRelation ]
- Returns:
a list of names of all ManyToMany field names relating to relationtypes from the respective entity class
E.g. for PersonPerson.get_related_relationtype_field_names() or person_instance.get_related_relationtype_field_names() -> [‘event_relationtype_set’, ‘institution_relationtype_set’, ‘personB_relationtype_set’, ‘personA_relationtype_set’, ‘place_relationtype_set’, ‘work_relationtype_set’]
Note: this method depends on the ‘generate_all_fields’ function of the EntityRelationFieldGenerator class which wires the ManyToMany Fields into the entities and respective relationtypes. This method is nevertheless defined here within AbstractEntity for documentational purpose.
- Returns:
list of queryset of all relationtype instances which are somehow related to the calling entity instance
- Returns:
list of class names in lower case of the relation types which are related to the respective entity class
E.g. for Place.get_related_relation_classes() or place_instance.get_related_relation_classes() -> [ ‘institutionplacerelation’, ‘personplacerelation’, ‘placeeventrelation’, ‘placeplacerelation’, ‘placeworkrelation’ ]
- class apis_core.apis_entities.models.Event(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr, kind)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class apis_core.apis_entities.models.Institution(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr, kind)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class apis_core.apis_entities.models.Person(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr, first_name, gender)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class apis_core.apis_entities.models.Place(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr, kind, lat, lng)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- class apis_core.apis_entities.models.Work(id, name, review, start_date, start_start_date, start_end_date, end_date, end_start_date, end_end_date, start_date_written, end_date_written, status, source, references, notes, published, tempentityclass_ptr, kind)[source]¶
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
Views¶
- class apis_core.apis_entities.views.GenericListViewNew(**kwargs)[source]¶
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- formhelper_class¶
alias of
apis_core.apis_entities.forms.GenericFilterFormHelper
- get_context_data(**kwargs)[source]¶
Overridden version of .TemplateResponseMixin to inject the table into the template’s context.
- get_queryset(**kwargs)[source]¶
Return the list of items for this view.
The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.
- apis_core.apis_entities.views.getGeoJson(request)[source]¶
Used to retrieve GeoJsons for single objects
- apis_core.apis_entities.views.getGeoJsonList(request)[source]¶
Used to retrieve a list of GeoJsons. To generate the list the kind of connection and the connected entity is needed
- apis_core.apis_entities.views.getNetJsonList(request)[source]¶
Used to retrieve a Json to draw a network