heliport.digital_objects package

Subpackages

Submodules

heliport.digital_objects.admin module

Registers Django admin pages.

See django.contrib.admin.ModelAdmin from Django documentation.

heliport.digital_objects.apps module

Django app configuration.

Some HELIPORT hooks can be registered in app config django.apps.AppConfig.ready().

See also Django documentation

class heliport.digital_objects.apps.DigitalObjectsConfig(app_name, app_module)

Bases: AppConfig

App configuration for digital objects app.

name = 'heliport.digital_objects'

heliport.digital_objects.interface module

Module with special name “interface” hooks into HELIPORT.

Some functions and heliport.core.app_interaction.Module subclasses are detected by HELIPORT and control how HELIPORT uses this app.

Note that this module must be imported in __init__.py of the django app.

class heliport.digital_objects.interface.DigitalObjectsModule

Bases: Module

get_url(project)
is_configured(project)
module_id = 'digital_objects'
name = 'Digital Objects'
class heliport.digital_objects.interface.ObjectGraphModule

Bases: Module

get_url(project)
icon = 'fa-solid fa-diagram-project'
is_configured(project)
module_id = 'object_graph'
name = 'Object Graph'
heliport.digital_objects.interface.get_search_url()
heliport.digital_objects.interface.serialize_project(project)

heliport.digital_objects.models module

Contains django.db.models.Model classes for Django ORM.

See Quick example from Django documentation. In HELIPORT the heliport.core.models.DigitalObject can be subclassed for models containing metadata in a project.

class heliport.digital_objects.models.ObjectGraph(digital_object_id, persistent_id, generated_persistent_id, category, label, label_is_public, description, description_is_public, created, last_modified, last_modified_is_public, deleted, permission, special_heliport_role, is_helper, projects_is_public, owner, members_is_public, digitalobject_ptr, object_graph_id)

Bases: DigitalObject

exception DoesNotExist

Bases: DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

delete_all_edges()
digitalobject_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.

digitalobject_ptr_id
object_graph_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

visualizationedge_set

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 heliport.digital_objects.models.PropertyPath(property_path_id, property, property_in_reverse, tail)

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

get_label()
objects = <django.db.models.manager.Manager object>
property

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.

property_id
property_in_reverse

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property_path_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

propertypath_set

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.

tail

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.

tail_id
visualizationedge_set

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 heliport.digital_objects.models.VisualizationEdge(edge_id, hex_color, dashed, path, visualization)

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

dashed

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

edge_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property edge_label
hex_color

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property html_color
objects = <django.db.models.manager.Manager object>
path

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.

path_id
property path_list
visualization

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.

visualization_id

heliport.digital_objects.serializers module

This module is for serialization into Datacite, RDF and JSON.

The JSON format is used for API endpoints via Django rest framework. Using this, it is typical to put the serializer classes into a “serializers.py” file.

For the serialization into RDF, attributes are described. See heliport.core.attribute_description.BaseAttribute for more detail.

class heliport.digital_objects.serializers.DigitalObjectRelationSerializer(*args, **kwargs)

Bases: ModelSerializer

class Meta

Bases: object

fields = ['digital_object_relation_id', 'subject', 'subject__label', 'subject__persistent_id', 'predicate', 'predicate__label', 'predicate__persistent_id', 'object', 'object__label', 'object__persistent_id']
model

alias of DigitalObjectRelation

class heliport.digital_objects.serializers.DigitalObjectSerializer(*args, **kwargs)

Bases: ModelSerializer

class Meta

Bases: object

fields = ['digital_object_id', 'projects', 'persistent_id', 'category', 'label', 'description', 'co_owners', 'owner']
model

alias of DigitalObject

heliport.digital_objects.tests module

Test the behaviour of this app.

This follows the Writing tests guide in Django.

class heliport.digital_objects.tests.DigitalObjectTests(methodName='runTest')

Bases: TestCase

Test digital objects app.

setUp()

Set up project, instances and logged-in heliport user.

test_list()

Test listing digital objects.

class heliport.digital_objects.tests.SearchAndAPITest(methodName='runTest')

Bases: TestCase

Test search including via API.

setUp()

Set up project and logged-in heliport user.

Test that search URL is accessible.

test_api()

Test api.

test_findable()

Test that digital object is findable.

heliport.digital_objects.urls module

Map django views to urls.

See this Example including explanation from the Django documentation.

heliport.digital_objects.views module

Contains Django View classes to handle HTTP requests.

See Using class-based views from Django documentation. In HELIPORT heliport.core.mixins are used to create uniform views. Also heliport.core.views.generic.HeliportObjectListView is used to quicly create a typical HELIPORT list view.

class heliport.digital_objects.views.DigitalObjectDeleteView(**kwargs)

Bases: HeliportLoginRequiredMixin, View

post(request, *args, **kwargs)
class heliport.digital_objects.views.DigitalObjectPropertiesView(**kwargs)

Bases: HeliportLoginRequiredMixin, View

class AttributeInfo(predicate, values, reverse)

Bases: tuple

predicate

Alias for field number 0

reverse

Alias for field number 2

values

Alias for field number 1

static check_access_allowed(digital_object, request)
static extract_boolean_param(request, param_name)
static extract_digital_object(request, param_name)
static extract_properties(request, param_name, reverse_relation_prefix)
static filter_object_has_not_properties(query, properties, reverse_properties)
static filter_subject_has_not_properties(query, properties, reverse_properties)
get(request, *args, **kwargs)
static get_all_forward_relations(digital_object)
static get_all_reverse_relations(digital_object)
static get_relations(digital_object, properties, reverse_properties)
classmethod group_by_property(digital_object_relations, is_reverse_relation)
static serialize_digital_object(obj)
classmethod serialize_results(all_results)
class heliport.digital_objects.views.DigitalObjectRelationViewSet(**kwargs)

Bases: ModelViewSet

Digital Object Relations.

filter_backends = [<class 'rest_framework.filters.SearchFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]
filterset_fields = ['subject', 'predicate', 'object', 'subject__persistent_id', 'predicate__persistent_id', 'object__persistent_id']
get_queryset()
permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]
search_fields = ['subject__label', 'predicate__label', 'object__label', 'subject__description', 'predicate__description', 'object__description']
serializer_class

alias of DigitalObjectRelationSerializer

class heliport.digital_objects.views.DigitalObjectViewSet(**kwargs)

Bases: HeliportModelViewSet

Digital Objects To Register a handle append /register_handle/ to the url e.g. …/123/register_handle/ where 123 is the pk of the digital object To Query landing page URL append /landing_page_url/ to the url.

filterset_fields = ['digital_object_id', 'persistent_id', 'category', 'owner']
get_queryset()
landing_page_url(request, pk=None)
register_handle(request, pk=None)
serializer_class

alias of DigitalObjectSerializer

class heliport.digital_objects.views.ObjectGraphListView

Bases: HeliportObjectListView

action_open(obj)
actions = [('Open', 'action_open', 'link'), ('Edit', 'action_edit', 'link_secondary'), ('Delete', 'action_delete', 'danger')]

Actions that are available for each column. Triples of action name, method name called on the HeliportObjectListView # noqa: E501 and style information. For more control over action overwrite register_actions(). # noqa: E501 See implementation of register_actions() for definitions of style information. # noqa: E501

category = 'HELIPORT/graph_visualization'

Namespace used for handle generation

columns = [('ID', 'object_graph_id', 'small'), ('Name', 'label', 'normal'), ('Description', 'description', 'large')]

Columns shown in the table. Triples of column name, attribute shown in column, column size. # noqa: E501 For more control over columns overwrite register_columns(). See implementation of register_columns() for definition of column sizes

create_heading = 'Add an Object Graph'

Text displayed as heading over form when creating obj. See also get_create_heading(). # noqa: E501

edit_fields = [('Name', 'label', 'normal'), ('Description', 'description', 'large')]

Fields editable in this view. Triple of key name, attribute name ware value is stored and field style For more control over form fields overwrite register_form_columns(). See implementation of register_form_columns() for definitions of field styles. # noqa: E501

list_heading = 'Object Graphs'

Text displayed as heading

list_url = 'digital_objects:object_graph_list'

Url that leads to this view for listing objects. The “update_url” string is passed to django.urls.reverse(). # noqa: E501 with “project” url argument to get the actual url. list_url is required by the default action_edit() implementation to link back to original page after edditing. # noqa: E501

model

alias of ObjectGraph

update_url = 'digital_objects:object_graph_update'

Url that leads to this view for updating. The “update_url” string is passed to django.urls.reverse(). # noqa: E501 with “project” and “pk” url arguments to get the actual url. update_url is required by the default action_edit() implementation.

class heliport.digital_objects.views.ObjectGraphView(**kwargs)

Bases: HeliportObjectMixin, DetailView

class Edge(start, end, viz)

Bases: tuple

end

Alias for field number 1

start

Alias for field number 0

viz

Alias for field number 2

class EdgeType(obj, path)

Bases: tuple

obj

Alias for field number 0

path

Alias for field number 1

build_index(path_step)
extend_index(index_by_end, path_step)
generate_edges(vis_edge)
generate_graph()
get_context_data(**kwargs)

Add extra context for rendering template (Called by django base view).

The extra context includes the generated graph.

index_to_edge_list(index_by_end, vis_edge)
model

alias of ObjectGraph

post(request, *args, **kwargs)
query_relations(path_step)
template_name = 'digital_objects/object_graph.html'
class heliport.digital_objects.views.ObjectsView(**kwargs)

Bases: HeliportProjectMixin, TemplateView

static fetch_digital_objects_relations(relation_pk_list)
get_context_data(**kwargs)

Add extra context for rendering template (Called by django base view).

The extra context includes the digital objects to show including e.g. categories to filter by.

post(request, *args, **kwargs)
template_name = 'digital_objects/digital_objects.html'
class heliport.digital_objects.views.SaveCategoryView(**kwargs)

Bases: HeliportLoginRequiredMixin, View

post(request, *args, **kwargs)
class heliport.digital_objects.views.SearchView(**kwargs)

Bases: HeliportLoginRequiredMixin, TemplateView

get_context_data(**kwargs)

Add extra context for rendering template (Called by django base view).

The extra context includes the search results.

template_name = 'digital_objects/search.html'
heliport.digital_objects.views.get_digital_object_save(pk, create=False)
heliport.digital_objects.views.save_get(collection, key, the_type, default=None)

Module contents

App to store arbitrary metadata using heliport.core.models.DigitalObject s.

The interface module is imported to the top level of the package for HELIPORT app interface discovery (see heliport.core.app_interaction.get_heliport_apps()).