heliport.core package
Subpackages
- heliport.core.migrations package
- Submodules
- heliport.core.migrations.0001_initial module
- heliport.core.migrations.0002_auto_20220224_1552 module
- heliport.core.migrations.0003_image module
- heliport.core.migrations.0004_auto_20220314_1014 module
- heliport.core.migrations.0005_logininfo_encrypted_password module
- heliport.core.migrations.0006_auto_20220322_1052 module
- heliport.core.migrations.0007_remove_logininfo_password module
- heliport.core.migrations.0008_rebuild_group_model module
- heliport.core.migrations.0009_heliportuser_affiliation_contribution module
- heliport.core.migrations.0010_contribution_type module
- heliport.core.migrations.0011_set_digitalobject_role module
- heliport.core.migrations.0012_auto_20220401_1204 module
- heliport.core.migrations.0013_timelineconfiguration module
- heliport.core.migrations.0014_tag module
- heliport.core.migrations.0015_digitalobject_last_modified module
- heliport.core.migrations.0016_insert_core_vocabulary module
- heliport.core.migrations.0017_digitalobjectrelation_is_public_and_more module
- heliport.core.migrations.0018_digitalobject_description_is_public_and_more module
- heliport.core.migrations.0019_digitalobject_last_modified_is_public module
- heliport.core.migrations.0020_namedtoken module
- heliport.core.migrations.0021_digitalobject_is_helper module
- heliport.core.migrations.0022_delete_timelineconfiguration module
- heliport.core.migrations.0023_alter_digitalobject_projects module
- heliport.core.migrations.0024_remove_digitalobject_heliport_groups_and_more module
- heliport.core.migrations.0025_rename_group_heliportgroup module
- heliport.core.migrations.0026_heliportgroup_auth_group module
- heliport.core.migrations.0027_heliportuser_stored_email module
- heliport.core.migrations.0028_alter_heliportuser_email_sha1_is_public_and_more module
- heliport.core.migrations.0029_alter_heliportuser_orcid module
- heliport.core.migrations.0030_digitalobjectidentifier module
- heliport.core.migrations.0031_remove_project_hzdr_id module
- heliport.core.migrations.0032_digitalobjectidentifier_url module
- heliport.core.migrations.0033_rename_type_digitalobjectidentifier_scheme module
- heliport.core.migrations.0034_remove_project_uuid module
- Module contents
- heliport.core.templatetags package
- heliport.core.user_logic package
- heliport.core.utils package
- Submodules
- heliport.core.utils.IDs module
- heliport.core.utils.collections module
- heliport.core.utils.colors module
- heliport.core.utils.command_line_execution module
- heliport.core.utils.context module
- heliport.core.utils.encryption module
- heliport.core.utils.exceptions module
- heliport.core.utils.form_description module
- heliport.core.utils.http module
- heliport.core.utils.json_ld module
- heliport.core.utils.normalization module
- heliport.core.utils.queries module
- heliport.core.utils.serialization module
- heliport.core.utils.string_tools module
- heliport.core.utils.table_description module
- heliport.core.utils.url module
- heliport.core.utils.version module
- Module contents
- heliport.core.views package
- Submodules
- heliport.core.views.api module
- heliport.core.views.digital_objects module
- heliport.core.views.generic module
HeliportCreateAndUpdateViewHeliportCreateAndUpdateView.assert_permission()HeliportCreateAndUpdateView.contextHeliportCreateAndUpdateView.dispatch()HeliportCreateAndUpdateView.get_context_data()HeliportCreateAndUpdateView.get_object()HeliportCreateAndUpdateView.get_project()HeliportCreateAndUpdateView.get_response()HeliportCreateAndUpdateView.is_createHeliportCreateAndUpdateView.is_updateHeliportCreateAndUpdateView.list_urlHeliportCreateAndUpdateView.modelHeliportCreateAndUpdateView.objectHeliportCreateAndUpdateView.objectsHeliportCreateAndUpdateView.pk_url_kwargHeliportCreateAndUpdateView.projectHeliportCreateAndUpdateView.project_url_kwargHeliportCreateAndUpdateView.update_urlHeliportCreateAndUpdateView.user
HeliportFormViewHeliportObjectListViewHeliportObjectListView.action_delete()HeliportObjectListView.action_edit()HeliportObjectListView.actionsHeliportObjectListView.add_textHeliportObjectListView.after_save_attributesHeliportObjectListView.categoryHeliportObjectListView.columnsHeliportObjectListView.create_headingHeliportObjectListView.dynamic_actions()HeliportObjectListView.edit_fieldsHeliportObjectListView.edit_tagsHeliportObjectListView.extract_action()HeliportObjectListView.extract_form_fields()HeliportObjectListView.get()HeliportObjectListView.get_context_data()HeliportObjectListView.get_create_heading()HeliportObjectListView.get_create_instance()HeliportObjectListView.get_form()HeliportObjectListView.get_object()HeliportObjectListView.get_table()HeliportObjectListView.get_update_heading()HeliportObjectListView.get_update_instance()HeliportObjectListView.handle_action()HeliportObjectListView.handle_create()HeliportObjectListView.handle_error()HeliportObjectListView.handle_update()HeliportObjectListView.info_snippet_addHeliportObjectListView.list_headingHeliportObjectListView.list_urlHeliportObjectListView.modelHeliportObjectListView.post()HeliportObjectListView.register_actions()HeliportObjectListView.register_columns()HeliportObjectListView.register_form_columns()HeliportObjectListView.set_update_attributes()HeliportObjectListView.template_nameHeliportObjectListView.test_func()HeliportObjectListView.update_headingHeliportObjectListView.update_url
- heliport.core.views.images module
- heliport.core.views.landing_page module
- heliport.core.views.project module
- heliport.core.views.search module
- heliport.core.views.tags module
- heliport.core.views.user module
- Module contents
Submodules
heliport.core.adapters module
Account adapters for usage with allauth.
- class heliport.core.adapters.AccountAdapter(request=None)
Bases:
DefaultAccountAdapterAdapter that allows enabling/disabling registration via settings.
- is_open_for_signup(request)
Allow creation of local accounts based on settings.
- save_user(request, user, form, commit=True)
Save the new user.
This takes the user created in the parent class and creates a
HeliportUserobject for it.
- class heliport.core.adapters.HelmholtzIDAccountAdapter(request=None)
Bases:
DefaultSocialAccountAdapterAdapter for use with Helmholtz ID.
- is_open_for_signup(request, sociallogin)
Allow new Helmholtz ID accounts based on settings.
- pre_social_login(request, sociallogin)
Disallow login based on configurable eduperson entitlements.
- save_user(request, sociallogin, form=None)
Save the new user.
The parent class internally calls
AccountAdapter.save_user(), thus the user’s HELIPORT user already exists. Here, we enrich it with more information provided by the sociallogin.
- validate_disconnect(account, accounts)
Allow LDAP users to disconnect their socialaccounts.
heliport.core.admin module
Registers Django admin pages.
See django.contrib.admin.ModelAdmin from Django documentation.
- class heliport.core.admin.DigitalObjectAdmin(model, admin_site)
Bases:
ModelAdminAdmin interface to list digital objects with labels and IDs.
This class can be used for all models which inherit from
DigitalObject.- digital_object_attributes: List[str] = []
- get_list_display(request) List[str]
Return names of the fields to display.
This adds fields mentioned in
self.digital_object_attributesto the default.
- list_display = ['pk', 'digital_object_id', 'label', 'persistent_id', 'generated_persistent_id', 'preferred_identifier']
- property media
- class heliport.core.admin.DigitalObjectIdentifierAdmin(model, admin_site)
Bases:
ModelAdmin- list_display = ['digital_object_identifier_id', 'scheme', 'immutable', 'identifier', 'display_text', 'url', 'digital_object']
- property media
- class heliport.core.admin.HeliportUserAdmin(model, admin_site)
Bases:
ModelAdminDisplay and make searchable the given attributes on the admin site.
- list_display = ['display_name', 'affiliation', 'email', 'orcid']
- property media
- search_fields = ['display_name', 'affiliation', 'orcid', 'stored_email', 'auth_user__email']
- class heliport.core.admin.LoginInfoAdmin(model, admin_site)
Bases:
ModelAdminAdmin interface that only shows non-sensitive information.
- fields = ['user', 'name', 'type']
- property media
- class heliport.core.admin.ProjectAdmin(model, admin_site)
Bases:
DigitalObjectAdmin- filter_horizontal = ('co_owners',)
- property media
heliport.core.app_interaction module
- class heliport.core.app_interaction.DigitalObjectModule
Bases:
ModuleA
Modulethat enables managing a subclass of Digital Object.Subclass this and set
Module.name,Module.module_id,Module.icon,object_classand implementModule.get_url().- can_handle(instance)
Determine whether this module manages a specific instance.
Both exact matches and superclasses of the managed class are considered.
- property form_class: Type[BaseForm] | None
Return form that enables creating and updating objects for this Module.
This is optional and defaults to
None. IfNoneis returned, users of this function may fall back to linking to the result ofget_url().The returned form class should accept the following key word parameters:
context: Can be used to get current user or project. Additionally, itallows cacheing within the context of a request and closing resources later.
instance: The instance to be edited orNoneto create a new instance.Django
ModelFormsalready accept this parameter. Make sure to check that the current modulecan_handle()the instance before passing it to the form.
The returned form class should have a
save()method. DjangoModelFormsalready provide this method.Using Media elements like javascript in the form is fully supported. Additionally, you can have an attribute
alpine_dataon the form. This is passed as anx-dataattribute to a parent element enabling reactive alpine functionality. For example this form synchronizes two text inputs:class MyForm(Form): alpine_data = "{val: ''}" a = CharField(widget=TextInput(attrs={"x-model": "val"})) b = CharField(widget=TextInput(attrs={"x-model": "val"}))
- is_configured(project)
Whether the module is used in the given project.
Returns
Trueif any of the digital objects handled by this module are part of the project and not deleted.
- matches(digital_object_class)
Determine whether this module manages a specific class.
Both exact matches and subclasses of the managed class are considered a match.
- abstract property object_class: Type[DigitalObject] | tuple[Type[DigitalObject]]
Define the types of objects that this module can manage.
This can be a type, or a
tupleof types, if a module manages multiple classes (e.g. files and directories).All returned types must be subclasses of
heliport.core.models.DigitalObject.
- property object_classes: tuple[Type[DigitalObject]]
Same as
object_classbut is always a tuple.
- class heliport.core.app_interaction.Module
Bases:
ABCBase class for HELIPORT modules.
A HELIPORT module is the most basic way to add an extension to heliport. A module can for example be configured to be shown in the HELIPORT project graph.
If your module represents a type of
heliport.core.models.DigitalObject, it is better to useDigitalObjectModuleinstead.- abstract get_url(project) str
Return url to lead a user to when clicking on the module.
- property icon: str
The icon to be used when displaying the module.
Usually a fontawesome class string.
- abstract is_configured(project) bool
Whether the module is in use for the project.
This affects if the module is shown in the project graph. Modules that are configured to have this module as dependency will only be available if this returns
True. Modules in the navbar or project drop-down menu are always shown.This may for example check if the user created at least one object in the module for that project.
- abstract property module_id: str
The id that can be used to refer to this module in settings.
- abstract property name: str
The name displayed to a user representing this module.
- class heliport.core.app_interaction.ModuleSection(name, project, is_configured_cache)
Bases:
object- add(module)
- property addable
- property addable_list
- property included
- property included_list
- is_configured(module)
- class heliport.core.app_interaction.PreconfiguredModuleSection(name, project, is_configured_cache)
Bases:
ModuleSection- is_configured(module)
- heliport.core.app_interaction.generate_graph(project)
- heliport.core.app_interaction.generate_project_dropdown(project)
Get
Moduleinstances that are configured for dropdown in settings.The “project” dropdown is in the HELIPORT base template in the navbar. Use the setting
HELIPORT_PROJECT_DROPDOWN_ITEMSto set this.
Get
Moduleinstances that are configured for navbar in settings.The navbar is in the HELIPORT base template at the top right. Use the setting
HELIPORT_PROJECT_NAVBAR_ITEMSto set this.For contents of the “project” navbar-item see
generate_project_dropdown().
- heliport.core.app_interaction.get_heliport_apps()
- heliport.core.app_interaction.get_module_for_url(url: str, project) Module | None
Find a module under the given
url.Checks each module if
urlis returned byModule.get_url()givenproject.Returns
Noneif no module matches.
- heliport.core.app_interaction.get_module_index()
- heliport.core.app_interaction.get_modules_for_type(digital_object_type: Type[DigitalObject] | Type[GeneralDigitalObject]) dict[str, DigitalObjectModule]
Get all registered HELIPORT modules that manage a given type.
The result is a dict mapping
Module.module_idto aDigitalObjectModuleinstance for each matching module.- Parameters:
digital_object_type – The type of digital objects to look for.
DigitalObjectModule.object_classcan only be a subclass of DigitalObject currently. Butheliport.core.digital_object_interface.GeneralDigitalObjectis also part of the type hint to allow search for specific digital object aspects. (seeheliport.core.digital_object_aspects)
- heliport.core.app_interaction.get_project_create_urls()
- heliport.core.app_interaction.get_search_urls()
- heliport.core.app_interaction.heliport_modules: DecoratorIndex[str, Module] = {'smb_shares': <class 'heliport.smb_files.models.SMBShareModule'>, 'ssh_files_directories': <class 'heliport.ssh.models.SSHModule'>}
Register heliport modules to this in apps.py of your django app. Call
heliport.core.utils.collections.DecoratorIndex.register()with yourModuleorDigitalObjectModulefor this:heliport_modules.register(MyModule).
- heliport.core.app_interaction.is_module_cls(potential_module_class)
Determine whether the given class is a HELIPORT module.
Checks if the given class is a subclass of
Moduleand not abstract.
- heliport.core.app_interaction.project_graph_section_for(module: Module) str | None
Determine the section a heliport module is in.
Returns the first section if a project is in multiple sections. Returns
Noneif the project is in no section. Returns"project dropdown"if a module is in the project dropdown. Returns"project navbar"if a module is configured to be in the project navbar.
heliport.core.apps module
Django app configuration.
Some HELIPORT hooks can be registered in app config django.apps.AppConfig.ready().
See also Django documentation
- class heliport.core.apps.HeliportConfig(app_name, app_module)
Bases:
AppConfigApp configuration for the main HELIPORT app.
This is part of Django’s plugin system.
- name = 'heliport.core'
- ready()
Register hooks and import settings.
- heliport.core.apps.post_migrate_handler(**kwargs)
heliport.core.attribute_description module
- class heliport.core.attribute_description.AttrObj(label, persistent_id, description='')
Bases:
objectAttribute Object to hold information that a normal DigitalObject would have for the purpose of supplying a simple constant value to the attribute_digital_object parameter when creating instances of
BaseAttribute:label- Short string to be shown as the property namepersistent_id- Globally unique persistent identifier for the property (in the format of a URL)description(optional) - Longer string to describe this property
- to_rdflib_node()
Return an
rdflib:rdflib.Nodefor this object.This method is needed when describing a graph in
AttributeType.rdf_triples(). Seeheliport.core.vocabulary_descriptor.TripleDescription.to_node().heliport.core.models.DigitalObject.to_rdflib_node()implements this interface for DigitalObjects.
- class heliport.core.attribute_description.AttrObjT
Bases:
BasicObjTypeRepresent a value that is an
AttrObj.- to_string(obj, options)
- class heliport.core.attribute_description.Attribute(attribute_digital_object, attribute_type, object_field, **kwargs)
Bases:
BaseAttributeGet value from attribute name as string. In the following example “distance_from_sun” is the attribute name:
class Planet: distance_from_sun: str @static_attributes.register(Planet) def planet_attributes() -> typing.List[BaseAttribute]: return [ Attribute( AttrObj("Distance from the sun", "https://example.org/distance_from_sun"), StringT, "distance_from_sun" ) ]
See also
BaseAttributefor more information.- getattr(obj)
Get attribute by name (
object_field).
- object_field: str
The name of the attribute where to get the value from.
- setattr(obj, value)
Set attribute by name.
- Raises:
TypeError – if attribute specified by
object_fieldis a read only property
- class heliport.core.attribute_description.AttributeType
Bases:
objectThe abstract base class for types used in a
BaseAttribute. TheAttributeTypecontrols how values of some property behave and are presented/encoded. Different HELIPORT modules can implement additional subclasses of this class to be able to represent any object they need. Many basic types are already implemented.- deserialize(obj, options)
Generate an object of this type from
obj.- Parameters:
obj – description of an object of this type as a string or primitive type (like
listofdict)options – other kwargs when instantiating a
BaseAttribute
- form_template_name = 'core/form_field/input.html'
Path to a django template for editing an object of this type in a form. The template is rendered with context from
get_form_context_data()
- get_context_data(obj, options)
The context (a dict) to be used when rendering
template_nameto render objects of this type in html. The function can returnNoneto indicate that the object should not be shown at all. The following things are in the context by default:value(string representation of th object)optionsobj
- Parameters:
obj – the object to be rendered as html
options – other kwargs when instantiating a
BaseAttribute
- get_form_context_data(key, obj, options)
The context (a dict) to be used when rendering
form_template_nameto render objects of this type as an html form input. The following things are in the context by default:value(string representation of th object) if availablekeyoptions
- Parameters:
key – the name under which the input should be posted when submitting the form
obj – the object to be shown as an input
options – other kwargs when instantiating a
BaseAttribute
- abstract rdf_triples(sub, pred, the_object, options) Iterator[TripleDescription]
Generator of
heliport.core.vocabulary_descriptor.TripleDescriptions describing objects of this type in rdf. It is necessary to useTripleDescriptionsinstead of returning anrdflib.Graphdirectly becauseTripleDescriptions allow recursive encoding, of the objects used in returned triples, later.
- render_empty_input(key, options)
Represent an empty object of this type as HTML form input. This is similar to
to_input()but for when the object is not created yet. By default, the template specified withform_template_nameis rendered using result formget_form_context_data().- Parameters:
key – the name under which the input should be posted when submitting the form
options – other kwargs when instantiating a
BaseAttribute
- template_name = 'core/types/string.html'
Path to a django template for showing an object of this type. The template is rendered with context from
get_context_data().
- test_exists(obj, options)
Test if
objis considered existent. In some cases only existent objects might be shown. By default, anobjis considered existent if it is notNone.
- to_html(obj, options)
Represent an object of this type in HTML. Returning
Nonesignals to not show the object at all. By default, the template specified withtemplate_nameis rendered using result formget_context_data().- Parameters:
obj – the object to be shown as an input
options – other kwargs when instantiating a
BaseAttribute
- to_id(obj, options)
Generate an id for the
obj. This is used inBaseAttribute.get_id()to generate an id for an attribute-value pair.
- to_inputs(key, obj, options)
Represent an object of this type as HTML form input. By default, the template specified with
form_template_nameis rendered using result formget_form_context_data().- Parameters:
key – the name under which the input should be posted when submitting the form
obj – the object to be shown as an input or
Noneif not object exists yetoptions – other kwargs when instantiating a
BaseAttribute
- to_json(obj, options)
Represent an
objof this type in json.
- to_string(obj, options) str | None
Represent an object of this type as a human-readable string. Return value of
Nonesignals to not show the object at all.- Parameters:
obj – the object to be shown as an input
options – other kwargs when instantiating a
BaseAttribute
- class heliport.core.attribute_description.BaseAttribute(attribute_digital_object, attribute_type, **kwargs)
Bases:
objectBase class for all attribute descriptions.
As an example the description of
distance_from_sun:class Planet: distance_from_sun: str @static_attributes.register(Planet) def planet_attributes() -> typing.List[BaseAttribute]: return [ Attribute( AttrObj("Distance from the sun", "https://example.org/distance_from_sun"), StringT, "distance_from_sun" ) ]
Note
The
DecoratorDictheliport.core.serializers.static_attributescan be imported and used to register the metadata attribute description in heliport. IfPlanetwere aDigitalObjectthe decoratorheliport.core.serializers.register_digital_object_attributes()should be used.Attribute descriptions contain:
- Description of the metadata property
In the example this is detailed information what the “distance from the sun” is. This can include
information like persistent identifier of the property in some metadata standard
human-readable description
detailed description using key value pairs. (Example: Distance from earth)
This information is specified via the first argument
attribute_digital_objectof the constructor and available via theattributeproperty.In the most basic case, like just a persistent identifier and a human-readable label, an
AttrObjcan be used. For more complex descriptions aheliport.core.models.DigitalObjectcan be used. To reference DigitalObjects in code you can create a class similar toheliport.core.models.Vocabulary. To describe DigitalObjects in code (needed before they can be referenced) you can write a function similar toheliport.core.vocabulary_core.insert_core_vocabulary()and call it in your appspost_migratehook (seeheliport.core.apps.HeliportConfigfor an example).- How to get the value given an object
In the example this is the information that the value for the distance from the sun can be gotten from the
"distance_from_sun"parameter of aPlanetobject.This information is determined by the subclass of
BaseAttributethat is used. For example the subclassAttributeusesAttribute.object_field(the attribute name) to get the value. Feel free to write additional subclasses in your app to be able to access complex attributes.- How to work with the value (type specific information)
In the example this is how distance should be displayed and serialized. A generic type or a more useful, but with more effort to implement, specific type for distances could be used. Feel free to implement subclasses of
AttributeTypein your app to control how your objects are displayed and serialized.The type is available via
attribute_typeand specified via the second argumentattribute_typeof the constructor. when specifyingattribute_typean instance ofAttributeTypeor a callable that returns an instance ofAttributeType(like a subclass ofAttributeTypeitself) can be used:attr1 = Attribute(..., StringT(), ...) attr2 = Attribute(..., StringT, ...)
- Additional parameters
Other
kwargsare stored and available toAttributeTypeand in subclasses ofBaseAttribute. Both can define what additional parameters they understand. Some parameters are defined inBaseAttribute. You can look through the attributes and methods to find them. They can be identified by the following style: “ADDITIONAL PARAMETER"<parameter name>"”.- Helper functions
A lot of functions are implemented in this base class. These functions call corresponding functions in the subcomponents of the description in the appropriate way.
- attribute_type: AttributeType
the type all values of the described attribute have
- bind_to(obj)
An attribute description does not contain information about a concrete object that might have the attribute. This enables the construction of queries based on attribute descriptions. However, this means that many methods require an
objparameter.BoundAttributestores aBaseAttributetogether with anobjto address this.- Parameters:
obj – The attribute description may describe attributes of
obj.- Returns:
A
BoundAttributewhereobjis used and not needed any more as parameter.
- property description: str
A longer human-readable description of the metadata attribute.
- deserialize(data)
Deserialize
datato an instance of the type described byattribute_type. SeeAttributeType.deserialize()for more information.
- exists_on(obj)
Determine if the attributes exists on
obj.See
AttributeType.test_exists()for more details.
- get_id(obj)
ID of a property value pair to identify it e.g. in html forms. The ID is generated based on
persistent_id,label,property_category,overwrite_property_idandAttributeType.to_id().
- get_is_public(obj) bool
By default,
is_always_publicandis_public_nameare considered. Subclasses may implement additional behaviour. See alsoset_is_public()andpublic_settable().- Parameters:
obj – The object of which the decision if the described attribute is public should be made.
- Returns:
Decision if the described attribute is public on
obj.
- abstract getattr(obj)
Don’t use this function but instead used
value_from(). Overwrite this function in subclasses to implement how the described attribute is accessed on some object.- Parameters:
obj – The object where the attribute value should be gotten from
- Returns:
The value of the attribute on
objorNoneifobjdoes not have a value for this attribute
- property handles_list: bool
Determines if the value of the described attribute is a list.
- property is_always_public
Some information, like a globally unique id, is always publicly known about any object.
is_always_publiccontains if the described property is such an always publicly known property. This is specified via the ADDITIONAL PARAMETER"is_public".
- property is_public_name: str
Attributes can be specified to be publicly visible. This information could be stored as a separate property on some object:
class A: b: int b_is_public: bool
The name of that attribute (“b_is_public” in the example) is this property. The value is taken from the ADDITIONAL PARAMETER
"is_public_name". Note that subclasses ofAttributegenerate this parameter by default as “<attribute_name>_is_public”.
- property label: str
Short human-readable text to describe the metadata attribute.
- property omit_from_external_objects: bool
Is
Trueif attribute is omitted from metadata of external objects.An object is external if it represents an external identifier. (
heliport.core.models.DigitalObject.represents_external_identifier)This is needed for example to exclude the heliport creation date for external objects from the metadata export since the object already existed before it was “created” in HELIPORT.
The value is taken from the ADDITIONAL PARAMETER
"omit_from_external".
- property overwrite_property_id: str
Property value pairs can be identified via an id returned from
get_id(). This id is normally generated automatically but can be specified explicitly via the ADDITIONAL PARAMETER"property_id". overwrite_property_id contains the explicitly specified id orNoneif it does not exist.
- property persistent_id: str
The persistent identifier of the metadata attribute.
- property property_category: str
Properties can be grouped into categories to split a long list of properties into smaller ones for ease of viewing. This attribute takes its value from ADDITIONAL PARAMETER
"property_category".
- public_settable(obj)
Determine if
set_is_public()is going to succeed onobj.See also
get_is_public().
- rdf_triples(obj)
Serialize
objinto RDF triples. For more details seeAttributeType.rdf_triples().
- property read_only: bool
Specified if the attribute is read only.
The value is taken from the ADDITIONAL PARAMETER
"read_only".
- render_empty_input(key)
Similar to
to_inputs()without obj parameter but behaviour could be customized independently in someAttributeType. SeeAttributeType.render_empty_input()for more information.
- set_is_public(obj, value: bool)
By default,
is_public_nameis used to set the public status of the described attribute. Ifobjhas an attributesave, it is called after attribute specified byis_public_nameis set tovalue. Subclasses may implement additional behaviour. See alsoget_is_public().- Parameters:
obj – The object for which the public status of the described attribute should be changed.
value – The new public status. (
Truemeans the attribute should be public)
- Raises:
AssertionError – If attribute
is_public_namecan not be found.AssertionError – If set
is_always_publicattribute to private.
- setattr(obj, value)
Don’t use this function but instead use
value_to(). Overwrite this function in subclasses to implement the way the described attribute sets the value on some object.- Parameters:
obj – The object where the attribute value should be set to
valuevalue – The value that the described attribute should be set to
- to_html(obj)
Serialize
objas html. For more details seeAttributeType.to_html().
- to_inputs(key, obj=None)
Serialize
objas list of html inputs. For more details seeAttributeType.to_inputs().- Parameters:
key – The key that should be used for this attribute in POST data.
obj – The object for which the inputs should be generated. If
objis not provided empty form inputs are generated.
- Returns:
List of rendered html inputs.
- to_json(obj)
Serialize
objto json. SeeAttributeType.to_json()for more details.
- to_string(obj) str | None
Serialize
objas human-readable string. For more details seeAttributeType.to_string().
- value_from(obj)
Get the value of this attribute from the
obj.Implements the “How to get the value given an object” part of the attribute description.
value_fromusesgetattr()internally to get the value.value_fromshould always be used when a value needs to be gotten whilegetattr()should always be overwritten in subclasses to implement the actual getting functionality. The corresponding method for setting attribute values isvalue_to().- Parameters:
obj – The object of which the attribute value should be determined.
- Returns:
The value of the described attribute on
obj
- value_to(obj, value)
Implements the “How to set the value given an object” part of the attribute description.
value_tousessetattr()internally to set the value.value_toshould always be used when a value needs to be set whilesetattr()should always be overwritten in subclasses to implement the actual setting functionality. The corresponding method for getting attribute values isvalue_from().- Parameters:
obj – The object of which the attribute value should be set.
value – The new value that should be used for the attribute on
obj.
- class heliport.core.attribute_description.BasicLiteralType
Bases:
AttributeTypeSomething that can be passed directly to
rdflib.Literalin order to represent it in anrdflib.Graph.- rdf_triples(sub, pred, the_object, options)
- class heliport.core.attribute_description.BasicObjType
Bases:
AttributeTypeRepresent objects like
AttrObjorheliport.core.models.DigitalObjectthat might have the following Attributes:persistent_id
digital_object_id
identifier_link
label
description
Don’t use this
AttributeTypedirectly. Use a specific subclass likeDigitalObjectTorAttrObjT.- rdf_triples(sub, pred, the_object, options)
- to_id(obj, options)
- to_json(obj, options)
- class heliport.core.attribute_description.BoundAttribute(attribute, bound_to)
Bases:
objectContains information about a subclass of
BaseAttribute(attribute) and a specific object (bound_to). This allows it to offer properties in many places whereBaseAttributehas methods that have anobjparameter. In django templates this is more than a way to simplify code, because only functions without arguments can be called there. One way to create aBoundAttributeis usingBaseAttribute.bind_to().- property as_html
- property as_json
- property as_string
- property exists
- property is_public
- property label
- property property_category
- property property_id
- property public_settable
- property rdf_triples
- property value
- class heliport.core.attribute_description.ConstantAttribute(attribute, value, attribute_type=None, **kwargs)
Bases:
BaseAttributeGet always the same constant
valuewithout looking at the object that has this attribute.- getattr(obj)
- Parameters:
obj – The object that has this constant attribute (ignored)
- Returns:
Always value specified by
value
- value: Any
The constant value always used for this attribute
- class heliport.core.attribute_description.ContributionT
Bases:
BasicObjTypeRepresent a value that is a
heliport.core.models.Contribution.- class ContributionDescription(contribution_type, contributing_heliport_user)
Bases:
InternalValueDescriptionDescription of a
heliport.core.models.Contribution. This is the type returned by deserialization. Deserialization can not return a Contribution directly, because theheliport.core.models.DigitalObject, where a contribution is for, is sometimes unknown during deserialization but is always required when storing aheliport.core.models.Contributionin the database. Additionally, it is bad to create persistent objects during deserialization because deserialization is also used as validation in Django Rest framework.- get_value(parent)
Generate a real
heliport.core.models.Contributionfrom this description.- Parameters:
parent – The object where the attribute of type
ContributionTis set. This is the object where the contribution is for.
- deserialize(obj, options)
- form_template_name = 'core/form_field/contribution.html'
Path to a django template for editing an object of this type in a form. The template is rendered with context from
get_form_context_data()
- get_form_context_data(key, obj, options)
In addition to the base implementation this includes the contribution
"type"and all potentially possible"contribution_types".
- to_id(obj, options)
- to_json(obj, options)
Represent the contribution
objas json. This usesPersonTto represent the contributor as json.
- to_string(obj, options)
- class heliport.core.attribute_description.DateT
Bases:
BasicLiteralTypeRepresent a value that is a python
datetimeobject.- deserialize(obj, options)
Uses
utils.string_tools.parse_date_time()to generate a datetime fromobj.- Raises:
DeserializationError – if no valid format could be found.
- get_form_context_data(key, obj, options)
Includes additionally to the base implementation
typeofdatein context to set it on html input.
- to_string(obj, options)
Use
strftimeto formatobjthat is adatetimeasstring. The time is included only if"include_time"is set toTrueinoptions.
- exception heliport.core.attribute_description.DeserializationError(detail=None, code=None)
Bases:
ValidationErrorIndicates that the data provided to an implementation of
AttributeType.deserialize()is invalid.DeserializationErrorbeing a subclass ofValidationErrorleads to special handling in Django Rest Framework, whereValidationErrors are used to generate an error response for the user.
- class heliport.core.attribute_description.DigitalObjectT
Bases:
BasicObjTypeRepresent a value that is a
heliport.core.models.DigitalObject.- deserialize(obj, options)
- form_template_name = 'core/form_field/digital_object.html'
Path to a django template for editing an object of this type in a form. The template is rendered with context from
get_form_context_data()
- get_form_context_data(key, obj, options)
In addition to base implementation include
"label"and"value"in context.label- Human readable representation of the DigitalObjectvalue-digital_object_idto be used as value in an html input
- template_name = 'core/types/digital_object.html'
Path to a django template for showing a DigitalObject. The template is rendered with context from
AttributeType.get_context_data(). # noqa: E501
- to_string(obj, options)
- class heliport.core.attribute_description.DynamicAttribute(attribute_model, attribute_type=None, **kwargs)
Bases:
BaseAttributeGet value for a
heliport.core.models.DigitalObjectvia itsheliport.core.models.DigitalObjectRelations orheliport.core.models.DigitalObjectAttributes.attribute_modelis an instance of heliport.core.models.DigitalObjectRelation orheliport.core.models.DigitalObjectAttributes. Specifyingattribute_typeis optional. The following rules are used to generate the default:is
DigitalObjectAttribute+ predicate or value indicate url →UrlT
Warning
The object needs to be known (it is the
subjectofattribute_model) when instantiating aDynamicAttributeclass, whereas otherBaseAttributesubclasses are general. So by the nature of dynamic attributesDynamicAttributecan only be used when generating attributes dynamically at runtime for a given object.Note
Why is this class called “DynamicAttribute”?
HELIPORT distinguishes between dynamic attributes that are attributes editable by users at runtime without conforming to any schema and static attributes that are defined in a schema and stored in specialized tables.
- attribute_model: DigitalObjectAttributes | DigitalObjectRelation
The django model where this attribute gets its value from.
- get_id(obj) str
Generate string to identify this attribute in html forms. See
BaseAttribute.get_id()for more information.
- get_is_public(obj)
Get public availability from
attribute_model.- Raises:
AssertionError – if
objdoes not match subject ofattribute_model
- getattr(obj)
Get value from
attribute_model.
- public_settable(obj)
Because it is known how to set
heliport.core.models.DigitalObjectAttributes.is_publicandheliport.core.models.DigitalObjectRelation.is_publicthis always returns True.- Raises:
AssertionError – if
objdoes not match subject ofattribute_model
- set_is_public(obj, value: bool)
Set public availability of
attribute_modeltovalue.- Raises:
AssertionError – if
objdoes not match subject ofattribute_model
- setattr(obj, value)
Set value on
attribute_model.If
valueforheliport.core.models.DigitalObjectAttributesis""orvalueisNoneattribute_modelis deleted. Ifattribute_modelisNonea new instance ofheliport.core.models.DigitalObjectRelationorheliport.core.models.DigitalObjectAttributesis created in the database based on ifvalueis aheliport.core.models.DigitalObjector not.- Raises:
AssertionError – if
objdoes not match subject ofattribute_model
- class heliport.core.attribute_description.EnumAttribute(attribute_digital_object, attribute_type, object_field, **kwargs)
Bases:
AttributeGet value as a tuple of actual value and human-readable string for attributes that are Django enumeration types. Should be used with an
AttributeType, likeEnumStringT, that supports this format of value.- getattr(obj)
Use
get_[object_field]_display()to get the human-readable component of the tuple. Get the first component like the base classAttribute.
- class heliport.core.attribute_description.EnumStringT(value_dict=None)
Bases:
AttributeTypeType that represents values that are tuples of the actual value and a string representation of the value.
EnumStringTis used in conjunction withEnumAttributeto describe attributes that are Django enumeration types.- deserialize(obj, options)
- rdf_triples(sub, pred, value_tuple, options)
- to_id(value_tuple, options)
- to_json(value_tuple, options)
Objects of
EnumStringTare represented like{"value": ..., "description": ...}in json.
- to_string(value_tuple, options)
- value_dict: dict
Maps actual values to their string representations, allowing to replace some default string representations. # noqa: E501 When deserializing, it is allowed to supply string representations that are converted to values via this dict. # noqa: E501
- class heliport.core.attribute_description.FunctionResultAttribute(attribute_digital_object, attribute_type, object_field, **kwargs)
Bases:
AttributeGet the value for this attribute by calling a method of an object specified by
object_field. This is very similar to the base class butAttributewould return a function whereas this class returns the result when calling this function.FunctionResultAttributeis a read only attribute.- getattr(obj)
Get value by calling the method, specified by
object_field, onobjwith no arguments.
- class heliport.core.attribute_description.InternalValueDescription
Bases:
objectContains the information to get or create some object. This is used for implementations of
AttributeType.deserialize(). There are two reasons to return an InternalValueDescription instead of the value itself:The value does not exist yet (no persistent object should be created during validation)
The value depends on things unknown during validation (the parent where this value becomes an attribute)
For an example see
ContributionT.ContributionDescription.- describes_list = False
Specifies if
get_value()returns a list or a single object It might not be possible to deduce this simply from the result ofget_value()because # noqa: E501get_value()might make persistent changes and therefore should be called only once. # noqa: E501
- abstract get_value(parent)
A function that is called when actually needing the value this object is describing.
- Parameters:
parent – The object where the returned object is assigned to an attribute.
- class heliport.core.attribute_description.ListT(item_type: AttributeType | Type[AttributeType])
Bases:
AttributeTypeRepresent a value that is a
listwhere all elements have the typeitem_type. Similar to when instantiating aBaseAttributespecifyingitem_typeas an instance ofAttributeTypeor as a callable that returns an instance ofAttributeType(like a subclass ofAttributeTypeitself) is possible:string_list1 = ListT(StringT()) string_list2 = ListT(StringT)
- class ListDescription(values)
Bases:
InternalValueDescriptionListT.deserialize()returns an instance of this class. This is needed because items might return an instance ofInternalValueDescriptionwhen deserialized soListT.ListDescriptionis used to evaluateInternalValueDescriptions recursively.- describes_list = True
Specifies if
get_value()returns a list or a single object It might not be possible to deduce this simply from the result ofget_value()because # noqa: E501get_value()might make persistent changes and therefore should be called only once. # noqa: E501
- get_value(parent)
Return a list where all
InternalValueDescriptions are evaluated.
- deserialize(obj, options)
- get_context_data(obj, options)
Ignores base implementation and returns instead:
values- A list of html representations of all items in the listoptions- like in the base implementation, other kwargs when instantiating aBaseAttribute
- rdf_triples(sub, pred, the_objects, options)
- render_empty_input(key, options)
- template_name = 'core/types/list.html'
Path to a django template for showing an object of this type. The template is rendered with context from
get_context_data().
- test_exists(obj, options)
- to_inputs(key, obj, options)
Return a list of rendered html inputs. See also
AttributeType.to_inputs().
- to_json(obj, options)
- to_string(object_list, options)
Items of the list are separated by newline characters.
- class heliport.core.attribute_description.ManyAttribute(attribute_digital_object, attribute_type, object_field, **kwargs)
Bases:
AttributeGet the value for this attribute from a Django many-to-many relationship.
attribute_typeis always aListT. If the passedattribute_typeis not a kind ofListT, theattribute_typeis assumed to be aListTof the specifiedattribute_type.An example usage of
ManyAttribute:class Planet(models.Model): orbits = models.ManyToManyField(Star) @static_attributes.register(Planet) def planet_attributes() -> typing.List[BaseAttribute]: return [ ManyAttribute( AttrObj("orbits", "https://example.org/orbits"), StarT, "orbits" ) ]
See
BaseAttributefor details where things likestatic_attributescome from in the example.- getattr(obj)
Get value from many attribute.
If the ADDITIONAL PARAMETER
"casted"is set to True, thecasted_or_self()method is called on all resulting values.heliport.core.models.DigitalObjectimplements such aheliport.core.models.DigitalObject.casted_or_self()method. This is necessary because django returns objects that are not casted to their most specific type but instead to a base class.
- setattr(obj, value)
Set value via many attribute.
- class heliport.core.attribute_description.PersonT
Bases:
BasicObjTypeRepresent a value that is a
heliport.core.models.HeliportUser.- deserialize(obj, options)
- to_id(heliport_user, options)
- to_json(heliport_user, options)
- class heliport.core.attribute_description.ProjectT
Bases:
DigitalObjectTRepresent a value that is a
heliport.core.models.Project.- deserialize(obj, options)
- get_form_context_data(key, obj, options)
In addition to the base implementation include
"type_constraint"to digital_object_id of the project type. This is used when autocompleting in an html form input.
- template_name = 'core/types/digital_object.html'
Path to a django template for showing a DigitalObject. The template is rendered with context from
AttributeType.get_context_data(). # noqa: E501
- to_string(obj, options)
- class heliport.core.attribute_description.StringT
Bases:
BasicLiteralTypeRepresent an object that is a python string.
- deserialize(obj, options)
Deserialize like the base implementation but return
""instead ofNoneif not"allow_null"is set toTrueinoptions.
- class heliport.core.attribute_description.TypeAttribute(the_type, attribute_type=None, **kwargs)
Bases:
ConstantAttributeAn attribute that specifies the type of the object.
Normally subclasses of
BaseAttributehave a description of the property as first parameter of the constructor.TypeAttributefills this information automatically to describe the property is of type.the_typecan be anything (but is aheliport.core.models.DigitalObjectin most cases; see documentation for description of metadata property inBaseAttributefor information how to accessDigitalObjects in code). If the subclass ofAttributeTypecan not be deduced forthe_type, the type ofthe_typecan be specified by theattribute_typeargument.
- class heliport.core.attribute_description.UriRefT
Bases:
AttributeTypeRepresent values that are
rdflib.URIRefs.- rdf_triples(sub, pred, the_object, options)
- template_name = 'core/types/url.html'
Path to a django template for showing an object of this type. The template is rendered with context from
get_context_data().
- class heliport.core.attribute_description.UrlT
Bases:
AttributeTypeA string that encodes a URL.
- rdf_triples(sub, pred, the_url, options)
- template_name = 'core/types/url.html'
Path to a django template for showing an object of this type. The template is rendered with context from
get_context_data().
- test_exists(obj, options)
A URL is considered existed if it is not
Noneand not"".
- heliport.core.attribute_description.get_attribute_type(obj: Any) Type[AttributeType]
This function is used for example to allow the
attribute_typeto be optional forConstantAttribute, where the AttributeType can be deduced from the value usingget_attribute_type().- Parameters:
obj – The instance for which an AttributeType should be found.
- Returns:
Appropriate subclass of
AttributeTypeto be used with theobjinstance.- Raises:
AttributeError – if no matching AttributeType was found.
heliport.core.conf module
Additional settings for this app.
See also django appconf
- class heliport.core.conf.HeliportAppConf(**kwargs)
Bases:
AppConfGeneral settings of the
heliport.coreapp.All settings in this class can be overwritten in settings.py
- ABOUT_URL = 'https://heliport.hzdr.de'
URL pointing to an external about page
- AUTOCOMPLETE_COUNT = 10
The number of entries returned from autocomplete views
- CITE_URL = 'https://heliport.hzdr.de/cite/'
URL pointing to an external page with citation instructions
- CRYPTO_KEY = 'wRgR7w12NiYl0GmI1KeBKodRdeB97XzS7RJME_XG_D8='
The key used for encryption of credentials in the database. (The key shown in the docs is just the dummy value from the CI.)
- DOCS_URL = 'https://heliport.hzdr.de/documentation/'
URL pointing to an external documentation page
- HOST = 'http://127.0.0.1:8000'
Despite the name
HOST, this setting contains the protocol, host, and port of the HELIPORT instance. A HELIPORT instance athttps://heliport.example.com/app/has theHOSTvaluehttps://heliport.example.com.
- IMPRINT_URL = 'https://www.hzdr.de/impressum'
URL pointing to an external imprint page
- MAINTENANCE_MESSAGE = 'No maintenance today'
- MAINTENANCE_MESSAGE_LEVEL = 0
- PRIVACY_URL = 'https://heliport.hzdr.de/privacy/'
URL pointing to an external privacy policy page
- TOS_URL = 'https://heliport.hzdr.de/terms/'
URL pointing to an external terms of service page
heliport.core.context_processors module
Additional context processors for HELIPORT.
- heliport.core.context_processors.auth_settings(request)
Add auth-related settings into context.
This is required in order to access these settings from templates without adapting allauth views.
- heliport.core.context_processors.heliport_version(request)
Add HELIPORT version string into context.
This makes the string available in all templates so that it can be used in the footer.
heliport.core.digital_object_actions module
Module for HELIPORT actions.
Register your actions in apps.py like this:
from django.apps import AppConfig
from heliport.core.digital_object_actions import actions
class MyConfig(AppConfig):
name = "my_app_name"
def ready(self):
from .views import MyAction, my_action_generation_func
actions.register(MyAction)
actions.register(my_action_generation_func)
where my_cation_generation_func is a function returning a list of actions, given
optionally a heliport.core.digital_object_interface.GeneralDigitalObject, a
heliport.core.models.Project and/or a
heliport.core.models.HeliportUser
(same arguments as Action constructor), and MyAction is a subclass of
Action.
- class heliport.core.digital_object_actions.Action(obj: ObjType = None, project: Project = None, user: HeliportUser = None)
Bases:
ABCRepresent an action that can be executed on some digital objects.
The properties:
obj- Theheliport.core.models.DigitalObjectorheliport.core.digital_object_interface.GeneralDigitalObjectto perform the action onproject- The current projectuser- The current user
are available on the action and can be passed to the constructor. They may also be
None.- abstract property applicable: bool
Determine if the action is executable for the given obj, project and user.
- abstract property icon: str
Name of a fontawesome icon.
- abstract property link: str
Link to where the action can be executed.
- abstract property name: str
Display name of this action.
- heliport.core.digital_object_actions.actions: DecoratorList[Type[Action] | ActionBuilder] = [<class 'heliport.data_source.views.OpenDirectory'>, <class 'heliport.data_source.views.DownloadFile'>, <class 'heliport.ssh.views.MigrateSSHDatasource'>]
Register
Actionsubclasses to this in apps.py of your django app. Callheliport.core.utils.collections.DecoratorIndex.register()with yourActionor action generation function for this:actions.register(MyAction).
- heliport.core.digital_object_actions.get_actions(obj: ObjType = None, project: Project = None, user: HeliportUser = None) List[Action]
Get all registered actions that are applicable for the given parameters.
See also
heliport.core.digital_object_interface.actions().
heliport.core.digital_object_aspects module
- class heliport.core.digital_object_aspects.Directory
Bases:
FileOrDirectorybase class for actual directories.
- abstract get_parts() Iterable[FileObj | DirectoryObj]
Get the parts of the digital object.
- is_directory = True
- class heliport.core.digital_object_aspects.DirectoryObj
Bases:
GeneralDigitalObjectA GeneralDigitalObject that represents a Directory.
- abstract as_directory(context: Context) Directory
Return the
Directorythat this object represents.
- is_directory = True
- is_file = False
- class heliport.core.digital_object_aspects.File
Bases:
FileOrDirectorybase class for actual files.
- is_file = True
- abstract mimetype() str
Mimetype of file content. Note that the file may need to be opened before the mimetype is available.
- abstract open()
Bring the file into a state that
read()starts from the beginning of the file. This may allocate resources that need to be freed usingclose(). It is allowed to reopen a closed file or an already opened file to start from the beginning.
- abstract read(number_of_bytes=None) bytes
Get next
number_of_bytesfrom the file or the entire file. Note that the actual number of bytes returned may be different from the number of bytes requested.
- abstract size() int | None
The exact size of this file in bytes.
Noneif no exact size is known.
- class heliport.core.digital_object_aspects.FileObj
Bases:
GeneralDigitalObjectA GeneralDigitalObject that represents a File.
- is_directory = False
- is_file = True
heliport.core.digital_object_class module
Functions to use if importing heliport.core.models.DigitalObject would result
in errors because of cyclical imports.
- heliport.core.digital_object_class.digital_object_class() Type[DigitalObject]
Returns the
heliport.core.models.DigitalObjectclass.
- heliport.core.digital_object_class.digital_objects()
Use this if you would write
DigitalObject.objectsnormally.
heliport.core.digital_object_interface module
This module contains the base that define an interface between heliport apps via digital objects.
The interface is centered around the GeneralDigitalObject.
Digital object implementations may inherit from one or multiple digital object aspects
like heliport.core.digital_object_aspects.FileObj.
Note that these aspect classes do not share any method names
(even including __init__) which allows multiple inheritance without special care.
HELIPORT apps can register their digital object types, in apps.py like so:
from django.apps import AppConfig
from heliport.core.digital_object_resolution import object_types
class MyConfig(AppConfig):
name = "my_app_name"
def ready(self):
from .models import MyGeneralDigitalObject
object_types.register(MyGeneralDigitalObject)
where MyGeneralDigitalObject is a
heliport.core.digital_object_interface.GeneralDigitalObject.
- class heliport.core.digital_object_interface.GeneralDigitalObject
Bases:
GeneralValue,ResolvableRepresent an object.
This is an abstract class. It doesn’t inherit from ABC because this would cause metaclass conflicts when inheriting from it in Django models.
For methods to implement, also check the baseclasses.
- actions(user: HeliportUser = None, project: Project = None)
Actions available for this object given the parameters.
Note that
userandprojectare optional but should be available in most cases.To generate a button for an action returned from this function, use the following attributes:
action.name- the text you can display on the buttonaction.link- the url to link to when someone clicks the button.
- Parameters:
user – is the
heliport.core.models.HeliportUserthat is currently authenticated. You can get this e.g. from a Django request likerequest.user.heliportuser.project – is the current
heliport.core.models.Project.
- Returns:
list of
heliport.core.models.HeliportActionobjects that are available for this object in the context ofuserandproject.
- abstract as_digital_object(context: Context) DigitalObject
Import and save the object as
heliport.core.models.DigitalObject.
heliport.core.digital_object_resolution module
Functionality to allow resolving objects from url parameters.
Register your objects in apps.py like this:
from django.apps import AppConfig
from heliport.core.digital_object_resolution import object_types
class MyConfig(AppConfig):
name = "my_app_name"
def ready(self):
from .models import MyObject
object_types.register(MyObject)
where MyObject is a Resolvable but more specifically a
heliport.core.digital_object_interface.GeneralDigitalObject in most cases.
- class heliport.core.digital_object_resolution.Resolvable
Bases:
objectThis class does not inherit form ABC in order to avoid metaclass conflicts.
- as_digital_object_if_exists(context: Context)
Get digital object from this resolvable.
Uses the fact that
resolve()returns existing digital objects, to return it if aheliport.core.models.DigitalObjectinstance exists for this resolvable.
- abstract get_identifying_params() Dict[str, str]
The params that can be passed to
resolve()to recreate this object.
- abstract static resolve(params: Dict[str, str], context: Context) GeneralDigitalObject | None
Given some parameters, construct or find a matching object and return it.
- abstract static type_id() str
The name used to reference this type in URLs and elsewhere.
- heliport.core.digital_object_resolution.object_types: FDecoratorIndex[str, Resolvable] = {'SMBDirectory': <class 'heliport.smb_files.models.SMBDirectoryObj'>, 'SMBFile': <class 'heliport.smb_files.models.SMBFileObj'>, 'SSHDirectory': <class 'heliport.ssh.models.SSHDirectoryObj'>, 'SSHFile': <class 'heliport.ssh.models.SSHFileObj'>, 'VersionControl': <class 'heliport.version_control.models.VersionControlObj'>, 'VersionControlFile': <class 'heliport.version_control.models.VersionControlFileObj'>}
Register
Resolvablesubclasses to this in apps.py of your django app. Callheliport.core.utils.collections.DecoratorIndex.register()with yourResolvableorheliport.core.digital_object_interface.GeneralDigitalObjectfor this:object_types.register(MyObject).
- heliport.core.digital_object_resolution.params_for(resolvable: Resolvable)
Get a dict of params for some resolvable. This uses
Resolvable.get_identifying_params()but has special handling forheliport.core.models.DigitalObjectinstances. Because they can just be resolved by digital_object_id.
- heliport.core.digital_object_resolution.resolve(params: Dict[str, str], context: Context) GeneralDigitalObject | DigitalObject | None
Resolve an object based on some params.
If “digital_object_id” in
paramsaheliport.core.models.DigitalObjectinstance with that id is returned, casted as the proper subclass. If “type” inparams, the registeredResolvableinstance for that type is used toResolvable.resolve()theparams.- Parameters:
params – Parameters to construct the object from
context – You must make sure to close the context yourself.
- Returns:
The resolved GeneralDigitalObject or
Noneif nothing was found.
- heliport.core.digital_object_resolution.url_for(url_str: str, resolvable: Resolvable, **kwargs)
Generates a URL for a view that takes a
Resolvableas input via get params.- Parameters:
url_str – The name of the url. This is normally a combination of app name and url name separated by “:”. An example would be:
"core:as_digital_object"resolvable – The object that should be provided as parameter to the view.
kwargs – kwargs that are needed for generating the url from the url name. E.g. if you have
".../<int:project>/..."as url config you need to provideprojectas key word argument.
- Returns:
URL as string
heliport.core.forms module
Forms for usage in core HELIPORT views.
- class heliport.core.forms.ChangePasswordForm(*args, **kwargs)
Bases:
HeliportAllauthPasswordChangeFormMixin,ChangePasswordFormAllauth’s
ChangePasswordForm, adapted for HELIPORT.- base_fields = {'oldpassword': <allauth.account.forms.PasswordField object>, 'password1': <allauth.account.forms.SetPasswordField object>, 'password2': <allauth.account.forms.PasswordField object>}
- declared_fields = {'oldpassword': <allauth.account.forms.PasswordField object>, 'password1': <allauth.account.forms.SetPasswordField object>, 'password2': <allauth.account.forms.PasswordField object>}
- property media
- class heliport.core.forms.HeliportAllauthFormMixin(*args, **kwargs)
Bases:
objectCosmetic changes for
allauthforms used in HELIPORT.- field_order = ['email', 'username', 'oldpassword', 'password1', 'password2', 'first_name', 'last_name', 'email2', 'orcid']
Order of the form fields. Fields not present are ignored.
- class heliport.core.forms.HeliportAllauthPasswordChangeFormMixin(*args, **kwargs)
Bases:
HeliportAllauthFormMixinCosmetic changes for
allauthpassword change forms used in HELIPORT.
- class heliport.core.forms.HelmholtzIDSignupForm(*args, **kwargs)
Bases:
HeliportAllauthFormMixin,SignupFormForm for account setup after Helmholtz ID login.
- base_fields = {'email': <django.forms.fields.EmailField object>, 'orcid': <heliport.core.forms.OrcidField object>, 'username': <django.forms.fields.CharField object>}
- declared_fields = {'email': <django.forms.fields.EmailField object>, 'orcid': <heliport.core.forms.OrcidField object>, 'username': <django.forms.fields.CharField object>}
- property media
- class heliport.core.forms.LoginSelectWidget(attrs=None, choices=())
Bases:
SelectA select widget for Login infos to be used in Django forms.
This automatically displays a message that links to the login info page when there are no login infos for the given user.
- property media
- template_name = 'core/base/login_select.html'
- class heliport.core.forms.OrcidField(*args, **kwargs)
Bases:
URLFieldURL field specialized for ORCIDs.
- class heliport.core.forms.OrcidInput(attrs=None)
Bases:
URLInputURL input specialized for entry of ORCIDs.
- property media
- class heliport.core.forms.ResetPasswordKeyForm(*args, **kwargs)
Bases:
HeliportAllauthPasswordChangeFormMixin,ResetPasswordKeyFormAllauth’s
ResetPasswordKeyForm, adapted for HELIPORT.- base_fields = {'password1': <allauth.account.forms.SetPasswordField object>, 'password2': <allauth.account.forms.PasswordField object>}
- declared_fields = {'password1': <allauth.account.forms.SetPasswordField object>, 'password2': <allauth.account.forms.PasswordField object>}
- property media
- class heliport.core.forms.SetPasswordForm(*args, **kwargs)
Bases:
HeliportAllauthFormMixin,SetPasswordFormAllauth’s
SetPasswordForm, adapted for HELIPORT.- base_fields = {'password1': <allauth.account.forms.SetPasswordField object>, 'password2': <allauth.account.forms.PasswordField object>}
- declared_fields = {'password1': <allauth.account.forms.SetPasswordField object>, 'password2': <allauth.account.forms.PasswordField object>}
- property media
- class heliport.core.forms.SignupForm(*args, **kwargs)
Bases:
HeliportAllauthFormMixin,SignupFormForm for user self registration.
- base_fields = {'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'orcid': <heliport.core.forms.OrcidField object>, 'username': <django.forms.fields.CharField object>}
- declared_fields = {'email': <django.forms.fields.EmailField object>, 'first_name': <django.forms.fields.CharField object>, 'last_name': <django.forms.fields.CharField object>, 'orcid': <heliport.core.forms.OrcidField object>, 'username': <django.forms.fields.CharField object>}
- property media
- heliport.core.forms.validate_orcid(input: str) None
Validate whether a given input string is an ORCID.
We only ensure the input looks plausible, i.e. it looks like
https://orcid.org/0000-0002-1825-0097and the checksum is correct. More information on the format and th checksum algorithm can be found on the ORCID support page.
heliport.core.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.
This particular module is the HELIPORT interface of the HELIPORT core app itself.
- class heliport.core.interface.Images
Bases:
DigitalObjectModule- get_url(project)
Return the URL for the entry point of this module.
- module_id = 'images'
- name = 'Images'
- property object_class
Image.
- class heliport.core.interface.ProjectConfigurationModule
Bases:
Module- get_url(project)
Return the URL for the entry point of this module.
- icon = 'fa-solid fa-gear'
- is_configured(project)
Return whether the module is configured, i.e. to show it in the graph.
- module_id = 'project_configuration'
- name = 'Project Configuration'
- class heliport.core.interface.SubProjects
Bases:
Module- get_url(project)
Return the URL for the entry point of this module.
- icon = 'fa-solid fa-table-cells-large'
- is_configured(project)
Return whether the module is configured, i.e. to show it in the graph.
- module_id = 'subprojects'
- name = 'Subprojects'
- class heliport.core.interface.Tags
Bases:
DigitalObjectModule- get_url(project)
Return the URL for the entry point of this module.
- icon = 'fa-solid fa-tags'
- module_id = 'tags'
- name = 'Tags'
- property object_class
Tag.
- class heliport.core.interface.Timeline
Bases:
Module- get_url(project)
Return the URL for the entry point of this module.
- icon = 'fa-solid fa-clock'
- is_configured(project)
Return whether the module is configured, i.e. to show it in the graph.
- module_id = 'timeline'
- name = 'Project Timeline'
- heliport.core.interface.get_project_create_urls()
Return URLs to views in this app that can be used to create a new project.
- heliport.core.interface.get_search_url()
Return the search URL for this app.
This URL is used to implement the global HELIPORT string search.
heliport.core.middleware module
- class heliport.core.middleware.DisableClientSideCachingMiddleware(get_response)
Bases:
object
- class heliport.core.middleware.HeliportVersionMiddleware(get_response)
Bases:
objectMiddleware that adds a HELIPORT version number header to all reponses.
heliport.core.mixins module
- class heliport.core.mixins.HeliportBreadcrumbsMixin
Bases:
objectMixin to handle generating breadcrumbs for navigation in HELIPORT.
Usually there is no need to inherit form this Mixin explicitly because
HeliportProjectMixinandHeliportObjectMixinalready inherit from it.- get_context_data(**kwargs)
- class heliport.core.mixins.HeliportLoginRequiredMixin
Bases:
LoginRequiredMixinMixin to make a view only available for authenticated users.
This is also already part of the
HeliportObjectMixinandHeliportProjectMixin.Note that this should be the first Mixin in the inheritance list to not do anything before ensuring access rights. See also Django’s note on this in
django.contrib.auth.mixins.LoginRequiredMixin.- login_url = '/login'
- permission_denied_message = 'Please log in to view this site'
- raise_exception = False
- class heliport.core.mixins.HeliportObjectMixin
Bases:
HeliportLoginRequiredMixin,UserPassesTestMixin,HeliportBreadcrumbsMixinMixin vor a Django view that shows an aspect of a Digital Object in HELIPORT.
It automatically adds the current
projectto the rendering context and makes sure that the current user is allowed to access the digital object and that the digital object is actually part of the project.It is required that there is a URL argument called “project” that is the id of the project. The object is taken from
get_object()of the View that inherits form this Mixin many Django views, like DetailView, already provide this method.Note that this should be the first Mixin in the inheritance list to not do anything before ensuring access rights.
- get_context_data(**kwargs)
- test_func()
- class heliport.core.mixins.HeliportProjectMixin
Bases:
HeliportLoginRequiredMixin,UserPassesTestMixin,HeliportBreadcrumbsMixinMixin vor a Django view that shows an aspect of a HELIPORT project.
It automatically adds the
projectto the rendering context and makes sure that the current user is allowed to access the project.It is required that there is a URL argument called “project” that is the id of the project.
Note that this should be the first Mixin in the inheritance list to not do anything before ensuring access rights.
- get_context_data(**kwargs)
- test_func()
heliport.core.models module
Contains django.db.models.Model classes for Django ORM.
See Quick example from Django documentation.
This module provides classes like DigitalObject, that can be subclassed in
HELIPORT apps.
- class heliport.core.models.Contribution(*args, **kwargs)
Bases:
ModelPeople who contributed to a
DigitalObjectin some way.This is mostly used for contributions to a
Project.- class ContributionTypes(value)
Bases:
TextChoicesList of contribution types as defined by DataCite.
- CONTACT_PERSON = 'ContactPerson'
- DATA_COLLECTOR = 'DataCollector'
- DATA_CURATOR = 'DataCurator'
- DATA_MANAGER = 'DataManager'
- DISTRIBUTOR = 'Distributor'
- EDITOR = 'Editor'
- HOSTING_INSTITUTION = 'HostingInstitution'
- OTHER = 'Other'
- PRODUCER = 'Producer'
- PROJECT_LEADER = 'ProjectLeader'
- PROJECT_MANAGER = 'ProjectManager'
- PROJECT_MEMBER = 'ProjectMember'
- REGISTRATION_AGENCY = 'RegistrationAgency'
- REGISTRATION_AUTHORITY = 'RegistrationAuthority'
- RELATED_PERSON = 'RelatedPerson'
- RESEARCHER = 'Researcher'
- RESEARCH_GROUP = 'ResearchGroup'
- RIGHTS_HOLDER = 'RightsHolder'
- SPONSOR = 'Sponsor'
- SUPERVISOR = 'Supervisor'
- WORK_PACKAGE_LEADER = 'WorkPackageLeader'
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- contribution_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- contribution_to
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.parentis aForwardManyToOneDescriptorinstance.
- contribution_to_id
- contributor
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.parentis aForwardManyToOneDescriptorinstance.
- contributor_id
- get_type_display(*, field=<django.db.models.fields.CharField: type>)
- objects = <django.db.models.manager.Manager object>
- to_rdflib_node()
Represent contribution as RDF.
Contributions are represented as BNodes using the uuid property of contribution.
- type
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod type_from_str(the_type)
Get contribution type identifier given human readable label.
- uuid
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class heliport.core.models.DigitalObject(*args, **kwargs)
Bases:
Model,GeneralDigitalObjectRepresenting an arbitrary thing that can have metadata.
This is a core model for HELIPORT as basically everything that is added to HELIPORT is a
DigitalObject. The main purpose of many apps is to subclass theDigitalObjectmodel and implement respective functionality.- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- class ObjectPermissions(value)
Bases:
IntegerChoicesDefines levels of permissions.
Note that these are not enforced at the moment.
- PRIVATE = 3
only members of this Digital Object can see and edit
- PROJECT = 2
Private + Members of a project that this object is in can see and edit
- PUBLIC = 1
Everybody can see and edit
- access(context: Context)
Get permission checker for this object and context.
For example:
obj.access(context).assert_read_permission() # raise error otherwise if obj.access(context).check_permission(): obj.label = None # do some update
See also
heliport.core.permissions.PermissionChecker.For serialization as a
heliport.core.digital_object_interface.GeneralDigitalObject.
- add_tag(tag)
Tag the object with
tag. See alsoTag.set_on().
- archive
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.restaurantis aReverseOneToOneDescriptorinstance.
- as_digital_object(context: Context)
Save this object and cast to subclass if necessary.
For serialization as a
heliport.core.digital_object_interface.GeneralDigitalObject.
- as_digital_object_if_exists(context)
Return
selfbecause this is already a digital object that exists.For serialization as a
heliport.core.digital_object_resolution.Resolvable.
- as_html() str
Get html representing this object to be rendered into some template.
For serialization as a
heliport.core.utils.serialization.GeneralValue.
- as_rdf() RootedRDFGraph
Get rdf graph of this object.
This currently returns a blank node if no
persistent_idis set.For serialization as a
heliport.core.utils.serialization.GeneralValue.
- as_text() str
Get a string representation of this object.
For serialization as a
heliport.core.utils.serialization.GeneralValue.
- attributes
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- casted_as_subclass()
Cast a generic DigitalObject instance to the subclass it should be.
Returns
Noneif this object really is just a generic digital object.Note that this works only for direct subclasses. Also note that this is hugely inefficient right now, especially when casting many objects during one request.
This functionality could be much improved by using django-polymorphic.
- casted_or_self()
Cast a generic DigitalObject instance to the subclass or return itself.
Same as
casted_as_subclass()but doesn’t cast if there is no subclass.This functionality could be much improved by using django-polymorphic.
- category
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property category_in_persistent_id
Determine if the namespace a.k.a. category is part of the PID.
- property category_list
Get the category path as list of digital objects.
The category is internally stored as string of ids separated by “/”.
Note that the name “category” is deprecated in favour of “namespace”.
- property category_str
The category of the digital object formatted for the user.
Each category is represented by its label. The labels are separated by “/”.
This is deprecated, use
namespace_strinstead.
- co_owners
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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- property context: Context | None
Get context previously set using
set_context().If this function does not return
Nonethe return value can be used for optimizations where expensive setup and teardown steps can be shared between operations. Seeheliport.core.utils.collections.ExitContextfor more details.
- contribution_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- property contributions
All known
Contributioninstances to this object.This is also settable.
- create_copy()
Related Django docs: Copying model instances.
- created
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- datamanagementplan
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.restaurantis aReverseOneToOneDescriptorinstance.
- datasource
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.restaurantis aReverseOneToOneDescriptorinstance.
- dbsmbdirectory
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.restaurantis aReverseOneToOneDescriptorinstance.
- dbsmbfile
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.restaurantis aReverseOneToOneDescriptorinstance.
- dbsshdirectory
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.restaurantis aReverseOneToOneDescriptorinstance.
- dbsshfile
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.restaurantis aReverseOneToOneDescriptorinstance.
- deleted
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- description
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- description_is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- digital_object_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- documentation
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.restaurantis aReverseOneToOneDescriptorinstance.
- executable
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.restaurantis aReverseOneToOneDescriptorinstance.
- full_url()
Get absolute landing page url as configured in settings.
This url may identify the
DigitalObjectif no other PID exists. This is also the url a PID may redirect to during PID resolution.
- gateproject
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.restaurantis aReverseOneToOneDescriptorinstance.
- generated_persistent_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_identifying_params() Dict[str, str]
For resolution.
- get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)
- get_next_by_last_modified(*, field=<django.db.models.fields.DateTimeField: last_modified>, is_next=True, **kwargs)
- get_permission_display(*, field=<django.db.models.fields.IntegerField: permission>)
- get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)
- get_previous_by_last_modified(*, field=<django.db.models.fields.DateTimeField: last_modified>, is_next=False, **kwargs)
- get_tags(project=None)
Get all tags of this DigitalObject.
See also
add_tag(),remove_tag()andheliport.core.utils.queries.tags_of().- Parameters:
project – if provided the result is limited to tags in this project.
- property identifier_display
Shorter version of the PID for nicer display.
It is common to use this when in html link tags where the actual link refers to
identifier_link.
- property identifier_label
Human-readable label of the identifier scheme of the PID of this object.
- property identifier_link
The PID of digital object.
It is made sure that this works as URL. Fallback is
full_url().
- property identifier_scheme
Scheme of the PID of this object.
The scheme has a URL prefix an id for use in datacite and a scheme label. See
heliport.core.utils.IDsfor more information.
- identifiers
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- image
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.restaurantis aReverseOneToOneDescriptorinstance.
- is_helper
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property is_subclass
Test if this object should be casted to a subclass.
This functionality could be much improved by using django-polymorphic.
- job
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.restaurantis aReverseOneToOneDescriptorinstance.
- label
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- label_is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property last_category
The last category of the digital object.
The last category itself is also a digital object.
- last_modified
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- last_modified_is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- local_url(request)
Get absolute landing page url as the user see it.
For example the user might access HELIPORT through a proxy.
- mark_deleted(user: HeliportUser | None = None)
Mark the DigitalObject as deleted.
Includes final access rights check.
- mediawikipage
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.restaurantis aReverseOneToOneDescriptorinstance.
- members()
All people where this
DigitalObjectbelongs to.This information is frequently used for access control.
- members_is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property namespace_str
A more appropriately named alias for
category_str.Category labels are separated by “/”.
Note that the name “category” is deprecated in favour of “namespace” because the category is part of the PID generation and a namespace conveys that better and a category is basically a type and types can in principle change but the PID not also there can be multiple types. The concept of a type exists separately in HELIPORT as a normal relation.
- static not_subclass_query()
Django ORM query parameters to test if an object is not a subclass.
This functionality could be much improved by using django-polymorphic.
- objectgraph
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.restaurantis aReverseOneToOneDescriptorinstance.
- objects = <django.db.models.manager.Manager object>
- owner
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.parentis aForwardManyToOneDescriptorinstance.
- owner_id
- permission
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- persistent_id
URI that identifies this digital object e.g. the Handle
- predicate_attributes
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- predicate_relations
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- preferred_identifier() DigitalObjectIdentifier | str | None
Return the preferred identifier for the digital object.
Identifiers are ordered by their
immutablefield first, then by scheme. “Immutable” identifiers are preferred over non-“immutable” ones. Scheme preference is given inpreference. If multiple identifiers of the same “immutability” and scheme are preferred, the first one to be found is returned. If no identifier with a scheme from the preferences list is found, the first identifer with a different scheme is returned, again ordered by “immutability”.
- project
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.restaurantis aReverseOneToOneDescriptorinstance.
- projects
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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- projects_is_public
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- publication
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.restaurantis aReverseOneToOneDescriptorinstance.
- relations
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- property relative_url
Get landing page url for this
DigitalObjectat HELIPORT instance.
- remove_tag(tag)
Object is no longer tagged with
tag. See alsoTag.unset_on().
- property represents_external_identifier
Whether this object stands for itself or is an external resource.
An external resource is something that has an identifier that does not resolve to the HELIPORT landing page of this object. For example a publication may be identified in HELIPORT by a DOI that resolves to a publication repository, or a term in an ontology may be identified by a URI that resolves to its definition.
- static resolve(params: Dict[str, str], context: Context) GeneralDigitalObject | None
For resolution.
- reverse_relations
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- save_with_namespace(namespace, project)
Save the object while adding some common extra information.
This encapsulates a very common pattern to save a DigitalObject.
- Parameters:
namespace – The namespace as string of labels separated by “/”
project – A project to add to the DigitalObject.
- set_context(context: Context)
Set context later accessible as
context.Set an
heliport.core.utils.context.Contextto be used by operations of thisDigitalObject. By setting the context you guarantee that, and you are responsible for, closing the context after all operations are done. It is not allowed to change the user or downgrade the permission back to public again. Create a new digital object instance for that.
- set_identifier(new_identifier: str | None)
Set the PID but normalize it first.
The given identifier will be set on the digital object directly. Additionally, a
DigitalObjectIdentifierwill be created that links the identifier to the digital object.In some cases this function may make network requests (HEAD request) to determine if a variation of the identifier is actually valid. Therefore, this function should ideally be called in a celery job.
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.restaurantis aReverseOneToOneDescriptorinstance.
- special_heliport_role
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property suffix_for_pid_generation
A string to use as a suffix in PID generation.
This string can be used by PID registration code as a baseline for this digital object’s PID. Essentially, this is the object’s own suggestion for what it would like to be called. The caller may deviate from this for any and all reasons.
- table
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.restaurantis aReverseOneToOneDescriptorinstance.
- tag
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.restaurantis aReverseOneToOneDescriptorinstance.
- tags_where_property
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- tags_where_type_required
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- tags_where_value
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- test_category_migrated()
Check whether the is migrated from the old format of labels instead of IDs.
I think this function can be deleted by now.
- static type_id() str
For resolution.
- update_modified_date()
Set last_modified to now.
- versioncontrol
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.restaurantis aReverseOneToOneDescriptorinstance.
- versioncontrolfile
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.restaurantis aReverseOneToOneDescriptorinstance.
- property viewing_user: HeliportUser | None
The user that currently deals with this digital object.
Information may be restricted to what the user can see. None means to only include public infos.
- class heliport.core.models.DigitalObjectAttributes(*args, **kwargs)
Bases:
ModelDescribes digital objects using arbitrary properties where values are a strings.
See also
DigitalObjectRelation.- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- digital_object_attribute_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- predicate
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.parentis aForwardManyToOneDescriptorinstance.
- predicate_id
- special_heliport_role
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- subject
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.parentis aForwardManyToOneDescriptorinstance.
- subject_id
- value
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class heliport.core.models.DigitalObjectIdentifier(*args, **kwargs)
Bases:
ModelModel representing identifiers for
DigitalObject.This is not to be confused with DOIs. While DOIs can and will appear in this model, it may store any kind of identifier that HELIPORT apps whish to store. A digital object may be associated with any number of identifiers via this model (including 0).
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- digital_object
The
DigitalObjectreferenced by this identifier.
- digital_object_id
- digital_object_identifier_id
The primary key of the model.
- display_text
The human-readable version of the
identifier. E.g., for the identifierhttps://doi.org/10.14278/rodare.946, thedisplay_textcould be set to10.14278/rodare.946.
- identifier
The identifier, in a format that is useful to the provider. E.g., in the case of a Handle, this could be
20.500.99999/HELIPORT.handle.123.
- immutable
An immutable identifier means that its metadata (e.g. on a handle.net server or any other registry) may not be updated. Typically, this field will be set to
Trueon user-provided identifiers not managed by HELIPORT, e.g. to prevent hijacking of identifiers.
- objects = <django.db.models.manager.Manager object>
- scheme
The scheme of the identifier. This must be a uniquely identifying string from which the correct implementation that handles this identifier can be found.
- url
The identifier as a full URL. E.g., in the case of a Handle, this could be
https://hdl.handle.net/20.500.99999/HELIPORT.handle.123.
- class heliport.core.models.DigitalObjectRelation(*args, **kwargs)
Bases:
ModelTriple that describes the subject using a key value pair.
The subject, predicate (key) and object (value) must all be digital objects. See
DigitalObjectAttributesfor when the value is a string.- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- digital_object_relation_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- object
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.parentis aForwardManyToOneDescriptorinstance.
- object_id
- objects = <django.db.models.manager.Manager object>
- predicate
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.parentis aForwardManyToOneDescriptorinstance.
- predicate_id
- special_heliport_role
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- subject
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.parentis aForwardManyToOneDescriptorinstance.
- subject_id
- class heliport.core.models.FromDB(role_name_in_db)
Bases:
objectGet a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.- property obj
Get the digital object.
- class heliport.core.models.HeliportGroup(*args, **kwargs)
Bases:
ModelHELIPORT specific group information.
The actual group from authentication is available as auth_group.
The user model is extended in a similar way in the
HeliportUsermodel.- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- auth_group
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.placeis aForwardOneToOneDescriptorinstance.
- auth_group_id
- backend_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- display_name
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get_default_group()
Create a default group if it doesn’t exist.
- group_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- project_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class heliport.core.models.HeliportUser(*args, **kwargs)
Bases:
ModelHELIPORT specific user information.
The actual user from authentication is available as auth_user.
The group model is extended in a similar way in the
HeliportGroupmodel.- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- affiliation
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- auth_user
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.placeis aForwardOneToOneDescriptorinstance.
- auth_user_id
- authentication_backend_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- co_experimentalist_gate_projects
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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- co_owned_digital_objects
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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- contribution_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- digitalobject_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- display_name
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property email: str | None
The user’s email address.
Taken from authentication backend with fall back to
stored_email.
- email_is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- email_sha1_is_public
Whether to show sha1 of email in public foaf metadata. Note that email hash can be reversed especially if you have the users name.
- executionlog_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- experimentalist_gate_projects
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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- gateuser
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.restaurantis aReverseOneToOneDescriptorinstance.
- local_contact_gate_projects
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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- logininfo_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- objects = <django.db.models.manager.Manager object>
- orcid
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- set_orcid(orcid)
Validate and set ORCID.
If the given ORCID is not valid, a ValidationError is raised.
This function is kept for backwards compatibility.
- stored_email
Email to use when no auth_user exists
- to_rdflib_node()
Represent user by orcid or uuid.
This method is needed when describing a graph in
heliport.core.attribute_description.AttributeType.rdf_triples(). Seeheliport.core.vocabulary_descriptor.TripleDescription.to_node().
- user_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- uuid
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class heliport.core.models.Image(*args, **kwargs)
Bases:
DigitalObjectRepresent an Image in HELIPORT.
- exception DoesNotExist
Bases:
DoesNotExist
- class ImageStates(value)
Bases:
IntegerChoicesWhen creating new image state is “UPLOADING”.
After uploading it is either “OK” or “FAILED”.
- FAILED = 3
- OK = 1
- UPLOADING = 2
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- access(context: Context)
Get permission checker for this object and context.
See
heliport.core.models.DigitalObject.access()for base implementation.There is also a check that only gives write permission if the current user owns the login.
- 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.placeis aForwardOneToOneDescriptorinstance.
- digitalobject_ptr_id
- directory
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- download_data()
Get image data as bytes.
Download from server specified by
login. If download fails status is set toFAILED.
- download_url_is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- fail(message)
Set status to FAILED with user message.
- filename
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_custom_url(user=None)
Get custom landing page URL.
This function is recognized when showing the landing page and the landing page becomes the image data itself when using the default landing page type.
If the user does not have access the normal landing page is shown.
- get_status_display(*, field=<django.db.models.fields.IntegerField: status>)
- login
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.parentis aForwardManyToOneDescriptorinstance.
- login_id
- message
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property mimetype
Image mimetype.
- property path
Get pathlib
Pathof image at computer specified bylogin.
- replace_if_exists
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.
- tablecell_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- upload_image(image_url)
Upload image to computer defined by
login.The image data is taken from base46 encoded
image_urlparameter.
- class heliport.core.models.LoginInfo(*args, **kwargs)
Bases:
ModelEncrypted user credentials and SSH keys.
Note that tokens are stored as
keyattribute.- exception DoesNotExist
Bases:
ObjectDoesNotExist
- class LoginTypes(value)
Bases:
TextChoicesDefine allowed login types using Django TextChoices.
- SSH = 'ssh connection'
- TOKEN = 'authentication token'
- USER_PASSWORD = 'username and password'
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- build_command_executor(depth=10)
Generate
heliport.core.utils.command_line_execution.CommandExecutor.Only applicable to SSH keys. The connection is performed to the machine using the SSH key. SSH logins can be recursive by the via property up to a maximum depth specified by the depth parameter.
- build_command_executor_indirection()
Build command executor for the SSH indirection specified via
via.Returns
Noneif no indirection is specified. See alsobuild_command_executor().
- property connected: bool
Connected status of SSH logins.
SSH logins are considered connected if there is an SSH key generated for them. If the connection gets disconnected by the User the SSH key is deleted also from the allowed hosts on the specified machine.
- data
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- datasource_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- dbsmbdirectory_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- dbsmbfile_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- dbsshdirectory_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- dbsshfile_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- encrypted_password
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_to_connect_list(depth=10, exclude_self=False) list
Get list of SSH Logins parameters that need to be connected before this one.
- Parameters:
depth – Max recursion depth. Raise
ValueErrorwhen exceeded.exclude_self – exclude the current login from the list.
- get_type_display(*, field=<django.db.models.fields.CharField: type>)
- get_unconnected_parents() list
Get unconnected ssh indirections.
Same as
get_to_connect_list()withexclude_self=True.
- image_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- key
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- login_info_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- logininfo_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- machine
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- property password
Decrypted password.
- slurm
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- type
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- 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.parentis aForwardManyToOneDescriptorinstance.
- user_id
- userjobconfig_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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- username
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- via
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.parentis aForwardManyToOneDescriptorinstance.
- via_id
- class heliport.core.models.MetadataField(attribute_vocab, normalizer=<class 'str'>, *, role_name_in_db='attribute')
Bases:
objectDefines a python descriptor for metadata properties.
This descriptor should be used on
DigitalObjectsubclasses.In principle most properties of subclasses of
DigitalObjectcan be considered “Metadata Properties” however usingMetadataFiledhas the added convenience that metadata serialization is automatically taken care of just by specifying the metadata property in the class definition. On top of that Storage if the property is public and can be shown on the landing page to everybody is handled without extra code.Use it for example like this:
class MyClass(DigitalObject): link = MetadataField(Vocabulary.primary_topic, url_normalizer)
The first argument comes from
Vocabularyand defines the metadata property to use for serialization. The second argument is optional and is just a function that is called before setting the value.heliport.core.utils.normalization.url_normalizer()is used in the example.The values are stored as
DigitalObjectAttributesand identified by thir property as well as an additional identification string that is by default “attribute”. This means if you have multiple properties with the same metadata property you need to set therole_name_in_dbparameter uniquely for each. Also if you change the metadata attribute or therole_name_in_dbyou need to write a database migration.- query(instance)
Get the Django ORM query parameters to query relevant values.
These query parameters are for querying
DigitalObjectAttributes.
- class heliport.core.models.NamedToken(*args, **kwargs)
Bases:
ModelHELIPORT API Token that is assigned a name by the user.
- exception DoesNotExist
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- auth_token
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.placeis aForwardOneToOneDescriptorinstance.
- auth_token_id
- name
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>
- token_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class heliport.core.models.Project(*args, **kwargs)
Bases:
DigitalObjectClass for storing a HELIPORT project.
Projectis the main container for all kinds ofDigitalObjectinstances. A project is also the main way of managing access to digital objects.- exception DoesNotExist
Bases:
DoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- access(context: Context)
Get permission checker for this object and context.
See
heliport.core.models.DigitalObject.access()for base implementation.There is an additional check that current user must be owner to delete the object.
- digital_object_lookup()
Get parts as dict of query sets keyed by type as string.
- 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.placeis aForwardOneToOneDescriptorinstance.
- digitalobject_ptr_id
- get_custom_view_url(user=None)
This defines the custom landing page to be the object graph.
- get_parent_projects(exclude: Iterable | None = None)
Get set of all projects that have this project as subproject.
Ignore subprojects and subprojects of subprojects that are in the
excludeset. The project itself is also part of the result.
- group
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.parentis aForwardManyToOneDescriptorinstance.
- group_id
- last_modified_aggregate()
Get the last date this project or one of its parts was modified.
Note that parts in subprojects are not counted.
- original_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- parts
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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- parts_is_public
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- project_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- sub_project_list(max_level=8, level=1, parent_path=None)
Get a list of named tuples with the following attributes:
path: list of parent project ids
level: how deep is the subproject nested (as iterable python range)
project: the subproject model instance
has_child: boolean indicating if there are more subprojects under this
for each subproject
- class heliport.core.models.Tag(*args, **kwargs)
Bases:
DigitalObjectA Digital Object D is tagged with a tag if relation (D, attribute, value) exists.
The
attributeandvalueare set/defined as properties of the tag.- exception DoesNotExist
Bases:
DoesNotExist
- exception MultipleObjectsReturned
Bases:
MultipleObjectsReturned
- applicable_for(obj: DigitalObject)
Determine if
objhas type required by the tag.
- property as_dict
Return a serialized version of this tag as dict to be converted to JSON.
- attribute
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.parentis aForwardManyToOneDescriptorinstance.
- attribute_id
- 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.placeis aForwardOneToOneDescriptorinstance.
- digitalobject_ptr_id
- get_key_value()
Return tuple of attribute and value.
Attribute defaults to has_tag and value to the tag itself if they are None.
- get_next_by_last_use_date(*, field=<django.db.models.fields.DateTimeField: last_use_date>, is_next=True, **kwargs)
- get_previous_by_last_use_date(*, field=<django.db.models.fields.DateTimeField: last_use_date>, is_next=False, **kwargs)
- 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
Color to be used in html e.g. #00FF35.
- property html_foreground_color
Color to be used for text if background has
html_color.
- last_use_date
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- relation_query_set()
Get a django ORM query set for this tag.
The query set contains the
DigitalObjectRelationinstances that make aDigitalObjecttagged by this tag.
- requires_type
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.parentis aForwardManyToOneDescriptorinstance.
- property requires_type_display
Displayable version of
requires_type.Tag might be for specific type or any type. This property can be used in an HTML template.
- requires_type_id
- property rgb_color
Same as
html_colorbut returns a tuple of values up to 255.
- set_on(obj: DigitalObject)
Tag
objwith this tag. See alsoDigitalObject.add_tag().
- tag_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- unset_on(obj: DigitalObject)
Remove tag from
obj. See alsoDigitalObject.remove_tag().
- update_usage_date()
Set last used to now.
- value
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.parentis aForwardManyToOneDescriptorinstance.
- value_id
- class heliport.core.models.Vocabulary
Bases:
objectTo get a digital object use Vocabulary.<name>.obj or Vocabulary().<name>.
- Class
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- HELIPORT
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- Namespace
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- Project
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- Property
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- described_by_parameter
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- described_by_process
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- description
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- filename
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- has_identifier
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- has_input
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- has_part
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- has_tag
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- input_of
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- is_version_of
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- label
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- primary_topic
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- same_as
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- status
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- sub_property_of
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- subclass_of
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- subnamespace_of
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- suggested_property
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- type
Get a digital object by special_heliport_role.
This is a python descriptor used in
Vocabulary. It hanldes getting objects lazily (need to callobjlater) when attribute is accessed on class and get object directly when attribute is accessed on instance.
- heliport.core.models.assert_not_relation(subj: DigitalObject, pred: DigitalObject, obj: DigitalObject)
Opposite of
assert_relation().Means that the statement is no longer assumed to be true.
- heliport.core.models.assert_relation(subj: DigitalObject, pred: DigitalObject, obj: DigitalObject)
Insert the triple (subj, pred, obj) into
DigitalObjectRelationtable.Semantically this makes the statement considered true in HELIPORT. Another way to view this is to set the key-value-pair “pred: obj” in the metadata of subj.
Consider the example, where
HELIPORT,usesandDjangoareDigitalObjectinstances:assert_relation(HELIPORT, uses, Django)
This means that the statement “HELIPORT uses Django” is assumed to be true or that the metadata of HELIPORT includes the key-value-pair “uses: Django”.
- heliport.core.models.assert_relation_truth(subj: DigitalObject, pred: DigitalObject, obj: DigitalObject, truth: bool)
Assert the truthiness of a relation based on a boolean.
Same as
assert_relation()andassert_not_relation()but which one is decided bytruth.
- heliport.core.models.digital_object_form_label_and_pk(label, pk) DigitalObject | None
Resolve a DigitalObject from pk.
If pk is not truthy, label is used if it uniquely identifies a DigitalObject. This is useful for getting a digital object from an autocomplete. if pk is not an integer or a string representing an integer and label is not truthy, this function returns
None.
- heliport.core.models.get_or_create_with_relation(label, category, pred, obj)
Get or create a digital object that has a specific relation.
The returned digital object (that might be newly created) is the subject in the relation. The subject must have the
label. When the subject is newly created also thecategoryis set on it along with thelabel. The relation has subject (the digital object of interest),predandobjwhich form a triple of digital objects. See alsoDigitalObjectRelation.
- heliport.core.models.get_special_object(special_heliport_role: str, allow_create_with: dict | None = None)
Get a digital object by
special_heliport_role.The
special_heliport_roleis a string to identify a digital object in the database inside the source code itself. If the object does not existNoneis returned.If
allow_create_withis set to adictthe object is created with the default values specified in the dict.This function only exists for special cases. The normal approach is to use
heliport.core.vocabulary_coreto define what objects should exist and with which parameters. (These are created when migrating the database) And then useVocabularyto get the objects in code.
heliport.core.negotiation module
Custom content negotiation.
- class heliport.core.negotiation.HeliportContentNegotiation
Bases:
DefaultContentNegotiationCustom content negotiation for the HELIPORT API.
This class reuses most functionality of Django REST Framework’s
DefaultContentNegotiationbut for requests made with HTMX, it selects theheliport.core.renderers.HeliportPartialRendererwhen appropriate.More info on custom content negotiation can be found in the Django REST Framework docs.
- select_renderer(request, renderers, format_suffix=None)
Select the appropriate renderer for the response to
request.The implementation reuses logic from
DefaultContentNegotiationbut explicitly asks it to return a renderer withformat_suffix="partial"if appropriate and supported by the view. We consider it appropriate to use a partial renderer for requests made with HTMX that either accept all media types (*/*, the HTMX default) or specifically ask fortext/html.
heliport.core.permissions module
- class heliport.core.permissions.HeliportObjectPermission
Bases:
BasePermissionPermission class to be used in django rest framework views.
- has_object_permission(request, view, obj)
Permission is granted if user
has_permission_for()the digital object.
- class heliport.core.permissions.HeliportProjectPermission
Bases:
BasePermissionPermission class to be used in django rest framework views.
- has_object_permission(request, view, obj)
Permission is granted if user is member of the project.
- class heliport.core.permissions.LoginPermissionChecker(obj, context, login_fields=('login',))
Bases:
PermissionCheckerA
PermissionCheckerthat also checks logins.Checks read permission like the base class but only allows to write if additionally the current user owns the login.
The model field that stores the
heliport.core.models.LoginInfois by default calledlogin. You may change this and also check multiple logins by supplying a tuple of strings to thelogin_fieldsparameter of the constructor.If the current object has the login
None, no additional constraints are checked.- check_delete_permission() bool
Check delete permission.
Delete permission is not affected by whether the user owns the login.
- check_permission()
Check read and write permission.
Same as base class, but with additional check for logins.
- class heliport.core.permissions.OnlyOwnerCanDeleteChecker(obj: DigitalObject | None, context: Context)
Bases:
PermissionCheckerPermission checker that allows only the owner to delete an object.
Note that objects without owner can be deleted by people that have regular write permission.
- check_delete_permission() bool
Check delete permission by comparing current user to owner.
- class heliport.core.permissions.PermissionChecker(obj: DigitalObject | None, context: Context)
Bases:
objectClass that checks permission given an object and a context (
heliport.core.utils.context.Context, which may provide a current user and current project). This is used for return value ofheliport.core.digital_object_interface.GeneralDigitalObject.access(). It might be necessary to implement a subclass that overwrites some methods if you want to use permission with objects that are notheliport.core.models.DigitalObjectinstances.- assert_delete_permission()
Raise error if no delete permission.
heliport.core.utils.exceptions.AccessDeniedis Raised.
- assert_permission()
Raises
heliport.core.utils.exceptions.AccessDeniedif no permission.
- assert_read_permission()
Raises
heliport.core.utils.exceptions.AccessDeniedif no permission.
- check_delete_permission() bool
Check if current user has permission to delete this object.
The user is taken from
context.This defaults to
check_permission().
- check_permission() bool
Check if current user (from
context) has read and write permissions for this digital object.
- check_read_permission() bool
Check if current user (from
context) has permission to read this digital object.
- obj: DigitalObject | None
The object where permission should be checked for.
- class heliport.core.permissions.StaffOrReadOnly
Bases:
BasePermissionPermission class to be used in django rest framework views.
- has_object_permission(request, view, obj)
Only admins can edit; everybody can read.
- heliport.core.permissions.allowed_objects(heliport_user, obj_type=<class 'heliport.core.models.DigitalObject'>)
QuerySet of all objects a user is allowed to access. This is the same as
objects_of()but also includes all public projects.
- heliport.core.permissions.direct_objects_of(heliport_user, obj_type=<class 'heliport.core.models.DigitalObject'>)
QuerySet of
heliport.core.models.DigitalObjectinstances of typeobj_typewhere user is a member.
- heliport.core.permissions.has_permission_for(user: HeliportUser, obj: DigitalObject)
Check if a
useris allowed to access non-public attributes ofobj.Currently, this is implemented by checking if the user is a member of a project that contains
obj. This might change in the future.See also
object_of().
- heliport.core.permissions.has_read_permission(user: HeliportUser | None, obj: DigitalObject)
Check if
userhas read permission to non-public attributes ofobj. This is currently the same ashas_permission_for()but might change in the future.
- heliport.core.permissions.has_write_permission(user: HeliportUser | None, obj: DigitalObject)
Check if
userhas write permission forobj. This is currently the same ashas_permission_for().
- heliport.core.permissions.is_object_member(heliport_user)
Query that can be used to construct filters on objects. This filters the same objects as
objects_of().
- heliport.core.permissions.is_public()
Query that can be used to construct filters on objects. This filters objects that are public and is used in
allowed_objects(). Currently, aDigitalObjectis public if it has no owner. Because most objects have no owner, most objects are public. This is subject to change.
- heliport.core.permissions.objects_of(heliport_user, obj_type=<class 'heliport.core.models.DigitalObject'>)
QuerySet of objects where
heliport_userhas access to. Currently, a userhas_permission_for()an object if the object is in a project where the user is member of. This might change in the future.
- heliport.core.permissions.projects_of(heliport_user)
QuerySet of projects where user is a member.
heliport.core.renderers module
Renderers for the HELIPORT API.
heliport.core.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.
This particular serializer module of the HELIPORT core app also contains renderer classes for rendering the RDF into a particular representation as well as other helper functionality for serialization.
- class heliport.core.serializers.AttrObjRDFSerializer
Bases:
RDFSerializer- triples(the_object, user)
- class heliport.core.serializers.ContributionRDFSerializer
Bases:
RDFSerializer- triples(contribution, user)
- static type2role()
- class heliport.core.serializers.ContributionSerializer(*args, **kwargs)
Bases:
ModelSerializer- class Meta
Bases:
object- fields = ['contribution_id', 'type', 'contributor', 'contribution_to']
- model
alias of
Contribution
- class heliport.core.serializers.DATACITESerializer
Bases:
object- abstract as_dict(object_to_serialize, user)
- as_json(object_to_serialize, user)
- abstract resource_type(object_to_serialize)
- resource_type_dict(object_to_serialize)
- class heliport.core.serializers.DataCiteJSONRenderer
Bases:
object- name = 'Datacite JSON'
- static render(obj, user)
- class heliport.core.serializers.DataCiteRenderer
Bases:
object- name = 'Datacite XML'
- static render(obj, user)
- class heliport.core.serializers.DigitalObjectAPISerializer(*args, **kwargs)
Bases:
ModelSerializer- class Meta
Bases:
object- fields = ['digital_object_id']
- list_serializer_class
alias of
DigitalObjectListSerializer
- model
alias of
DigitalObject
- create(validated_data)
- set_values(instance, validated_data)
- update(instance, validated_data)
- property user
- validate(data)
- class heliport.core.serializers.DigitalObjectDATACITESerializer
Bases:
DATACITESerializerhttps://github.com/datacite/schema/blob/master/source/json/kernel-4.3/datacite_4.3_schema.json.
- as_dict(digital_object, user)
- resource_type(object_to_serialize)
- class heliport.core.serializers.DigitalObjectListSerializer(*args, **kwargs)
Bases:
ListSerializer- create(validated_data)
- to_representation(digital_objects)
- update(instance, validated_data)
- class heliport.core.serializers.DigitalObjectRDFSerializer
Bases:
RDFSerializer- static dynamic_triples(digital_object, user)
- static static_triples(digital_object, user)
- triples(digital_object, user)
- class heliport.core.serializers.GroupSerializer(*args, **kwargs)
Bases:
ModelSerializer- class Meta
Bases:
object- fields = ['display_name']
- model
alias of
HeliportGroup
- class heliport.core.serializers.HtmlRenderer
Bases:
object- name = 'Specific Landing Page'
- classmethod render(obj, user)
- class heliport.core.serializers.ImageDATACITESerializer
Bases:
DigitalObjectDATACITESerializer- resource_type(image)
- class heliport.core.serializers.ImageUrlAttribute(**kwargs)
Bases:
BaseAttribute- getattr(image)
- class heliport.core.serializers.JsonLdRenderer
Bases:
object- static filter_prefixes(graph, prefixes)
- classmethod find_id_usages(item, parent, id_usages)
- classmethod inline(graph)
- static len_sum(d: dict)
- name = 'JSON-LD'
- classmethod render(obj, user)
- class heliport.core.serializers.LandingPageRenderer
Bases:
object- name = 'Default Landing Page'
- classmethod render(obj, user)
- class heliport.core.serializers.MetadataBoundField(field, value, error, instance)
Bases:
BoundField- as_form_field()
- render_form_inputs()
- class heliport.core.serializers.MetadataRestField(*args, **kwargs)
Bases:
Field- get_attribute(instance)
- get_or_generate_predicate_obj()
- get_value(dictionary)
- property read_only_attrs
- render_new_input()
- set_values(instance, validated_value_list)
- property source_attrs
- split_value_list(value_list)
- to_internal_value(data)
- to_representation(value)
- property writable_attrs
- property writable_list_attrs
- property writable_single_attrs
- class heliport.core.serializers.NamespaceField(*args, **kwargs)
Bases:
FieldThis is a constant field for setting the namespace in API serializers.
The field is by default write-only, which means the namespace is not returned as json but is only set when data is posted or patched.
- get_value(dictionary)
Given the incoming primitive data, return the value for this field.
This should be the value that should be validated and transformed to a native value.
- to_internal_value(data)
Transform the incoming primitive data into a native value.
- to_representation(value)
Transform the outgoing native value into primitive data.
- class heliport.core.serializers.ProjectDATACITESerializer
Bases:
DigitalObjectDATACITESerializer- resource_type(object_to_serialize)
- class heliport.core.serializers.ProjectSerializer(*args, **kwargs)
Bases:
ModelSerializer
- class heliport.core.serializers.RDFSerializer
Bases:
object- abstract triples(the_object, user) Iterable[TripleDescription]
Yield triples for the given object.
See
heliport.core.vocabulary_descriptorfor some kinds of triple description you could return, or implement your own.
- class heliport.core.serializers.RdfXmlRenderer
Bases:
object- name = 'RDF XML'
- static render(obj, user)
- class heliport.core.serializers.TemplateField(*args, **kwargs)
Bases:
Field- get_attribute(instance)
- to_internal_value(data)
- to_representation(value)
- class heliport.core.serializers.TokenSerializer(*args, **kwargs)
Bases:
ModelSerializer
- class heliport.core.serializers.TripleRenderer
Bases:
object- name = 'N-Triples'
- static render(obj, user)
- class heliport.core.serializers.TurtleRenderer
Bases:
object- name = 'Turtle'
- static render(obj, user)
- class heliport.core.serializers.UserRDFSerializer
Bases:
RDFSerializer- triples(user, user_that_wants_to_know)
- class heliport.core.serializers.UserSerializer(*args, **kwargs)
Bases:
ModelSerializer- class Meta
Bases:
object- fields = ['user_id', 'authentication_backend_id', 'display_name', 'orcid', 'affiliation']
- model
alias of
HeliportUser
- heliport.core.serializers.datacite_serializers = {<class 'heliport.archive.models.Archive'>: <class 'heliport.archive.serializers.ArchiveDATACITESerializer'>, <class 'heliport.core.models.DigitalObject'>: <class 'heliport.core.serializers.DigitalObjectDATACITESerializer'>, <class 'heliport.core.models.Image'>: <class 'heliport.core.serializers.ImageDATACITESerializer'>, <class 'heliport.core.models.Project'>: <class 'heliport.core.serializers.ProjectDATACITESerializer'>}
Register a
DATACITESerializerorDigitalObjectDATACITESerializersubclass here for metadata export in DataCite format.
- heliport.core.serializers.digital_object_attributes() List[BaseAttribute]
- heliport.core.serializers.get_all_attributes(obj)
- heliport.core.serializers.get_all_attributes_bound(obj)
- heliport.core.serializers.get_attributes_as(user, obj)
- heliport.core.serializers.get_attributes_by_category(obj, user)
- heliport.core.serializers.get_bound_attributes_as(user, obj)
- heliport.core.serializers.get_dynamic_attributes(obj)
- heliport.core.serializers.get_static_attributes(cls)
- heliport.core.serializers.get_unique_renderers()
- heliport.core.serializers.image_attributes()
Compute the attribute list, including some general attributes.
- heliport.core.serializers.project_attributes()
Compute the attribute list, including some general attributes.
- heliport.core.serializers.rdf_serializers = {<class 'heliport.core.attribute_description.AttrObj'>: <class 'heliport.core.serializers.AttrObjRDFSerializer'>, <class 'heliport.core.models.Contribution'>: <class 'heliport.core.serializers.ContributionRDFSerializer'>, <class 'heliport.core.models.DigitalObject'>: <class 'heliport.core.serializers.DigitalObjectRDFSerializer'>, <class 'heliport.core.models.HeliportUser'>: <class 'heliport.core.serializers.UserRDFSerializer'>}
Low level rdf serializers. Register a subclass of
RDFSerializerfor your custom class. For subclasses of digital object the default serializer uses the thestatic_attributesfor serialization.
- heliport.core.serializers.register_digital_object_attributes(cls)
Decorate a function to register attributes.
clsis a subclass ofheliport.core.models.DigitalObject. This decorator includes some general attributes automatically.
- heliport.core.serializers.renderers = {'datacite': <class 'heliport.core.serializers.DataCiteRenderer'>, 'datacite_json': <class 'heliport.core.serializers.DataCiteJSONRenderer'>, 'html': <class 'heliport.core.serializers.HtmlRenderer'>, 'json': <class 'heliport.core.serializers.JsonLdRenderer'>, 'jsonld': <class 'heliport.core.serializers.JsonLdRenderer'>, 'landing_page': <class 'heliport.core.serializers.LandingPageRenderer'>, 'nt': <class 'heliport.core.serializers.TripleRenderer'>, 'turtle': <class 'heliport.core.serializers.TurtleRenderer'>, 'xml': <class 'heliport.core.serializers.RdfXmlRenderer'>}
The most low level registry of serializers that just return any django response object. The dict is keyed by a short string a user can add to the url to use this renderer for metadata serialization. Register your custom renderer to support metadata formats that are not DataCite or RDF or additional serializations of those. Look at the implementation of
select_renderer()to see how content negotiation is performed to select the renderer.
- heliport.core.serializers.select_renderer(format_code, accept_header)
- heliport.core.serializers.static_attributes = {<class 'heliport.archive.models.Archive'>: <function register_digital_object_attributes.<locals>.decorator.<locals>.attributes>, <class 'heliport.core.models.DigitalObject'>: <function digital_object_attributes>, <class 'heliport.core.models.Image'>: <function register_digital_object_attributes.<locals>.decorator.<locals>.attributes>, <class 'heliport.core.models.Project'>: <function register_digital_object_attributes.<locals>.decorator.<locals>.attributes>}
Metadata attributes for each class. Register a function that returns a list of
heliport.core.attribute_description.BaseAttributesubclass instances. For registering attributes for a subclass of DigitalObject useregister_digital_object_attributes(). The extension point is called “static” because it is mostly used to describe properties from the static database model which causes these attributes to be included in the metadata export and in principle even enables these attributes to be used by other apps just based on the underlying metadata standard. For dynamic attributes, without hardcoded scheme, seeheliport.core.models.assert_relation(). For working with dynamic attributes similar to static attributes just likemy_instance.my_propertyseeheliport.core.models.MetadataAttribute- so these are almost as simple as normal django fields but don’t require to be described/registered asstatic_attributesseparately.
- heliport.core.serializers.to_datacite(obj, user)
- heliport.core.serializers.to_rdf(digital_object, user, max_depth=100)
Serialize any object as rdflib graph.
The type of object needs to be registered at
rdf_serializersto be serialized.
- heliport.core.serializers.types(obj, bound_attributes=False)
heliport.core.signal_handlers module
Signal handlers for the core HELIPORT app.
- heliport.core.signal_handlers.register_heliport_identifier_handler(sender, instance: DigitalObject, created: bool, using, update_fields, **kwargs)
Register a default identifier for a digial object.
An identifier for the digital object is created from
DigitalObject.suffix_for_pid_generationand registered in theDigitalObjectIdentifiermodel using the scheme “heliport”.This identifier can be used if no external PID is known for the object and no PID system is hooked up to HELIPORT.
heliport.core.tests module
Test the behaviour of this app.
This follows the Writing tests guide in Django.
- class heliport.core.tests.APITest(methodName='runTest')
Bases:
WithHeliportUser- static getattr_path(obj, name_path, default=None)
- subclasses_recursive(the_class)
- test_deletion()
- test_digital_object_api()
- test_projects()
- test_token_auth()
- test_users()
- class heliport.core.tests.CoreVocabularyTest(methodName='runTest')
Bases:
TestCase- test_query_by_type()
- test_vocabularies_exist_and_are_property_or_class()
- class heliport.core.tests.DigitalObjectIdentifierTest(methodName='runTest')
Bases:
TestCaseTests for
DigitalObjectIdentifier.- test_digital_object_set_identifier()
Test DigitalObjectIdentifier model instances created in set_identifier.
- test_heliport_identifier_created()
Test automatic creation of
heliport-scheme identifier.
- test_preferred_identifier()
Test priority rules in preferred_identifier method.
- class heliport.core.tests.DigitalObjectInterfaceTest(methodName='runTest')
Bases:
WithHeliportUser- test_actions()
- test_file()
- test_resolution()
- class heliport.core.tests.DummyAction(obj: ObjType = None, project: Project = None, user: HeliportUser = None)
Bases:
Action- applicable = True
- icon = 'fa-kiwi-bird'
- link = 'dummy/action'
- name = 'dummy'
- class heliport.core.tests.DummyFile
Bases:
File- close()
- get_file_info() Dict[str, str]
- mimetype = 'text/text'
- open()
- read(number_of_bytes=None) bytes
- size() int | None
- class heliport.core.tests.DummyResolvable
Bases:
GeneralDigitalObject- as_digital_object(context: Context) DigitalObject
- as_html() str
- as_rdf() RootedRDFGraph
- as_text() str
- get_identifying_params() Dict[str, str]
- classmethod resolve(params: Dict[str, str], context: Context) GeneralDigitalObject | None
- static type_id() str
- class heliport.core.tests.FormTest(methodName='runTest')
Bases:
TestCaseTests for form validation.
- test_orcid_validation_only_id()
A valid ORCID without the full URL does not pass validation.
- test_orcid_validation_valid_orcid()
A valid ORCID with full URL passes validation.
- test_orcid_validation_wrong_checksum()
An ORCID with an invalid checksum does not pass validation.
- test_orcid_validation_x_check_digit()
An ORCID with an X as the check digit passes validation.
- class heliport.core.tests.HELIPORTTest(methodName='runTest')
Bases:
WithHeliportUser- setUp()
- test_as_digital_object()
- test_copy_digital_object()
- test_icons_exist_landing_page()
- test_icons_exist_main_page()
- test_importing_digital_objects()
- test_maintenance_message_api()
On maintenance level > 0, the correct level and message should be returned.
- test_maintenance_message_no_partial_on_media_type()
HTMX requests asking for non-html media type should not receive partials.
- test_maintenance_message_partial()
On maintenance level > 0, HTMX requests should receive a partial containing the message. The
divshould havealertclasses.
- test_no_maintenance_message_api()
On maintenance level 0, the message in the response should be null.
- test_no_maintenance_message_partial()
On maintenance message level 0, HTMX requests should receive a partial without any code.
- test_project_graph()
- test_project_independent_tag_autocomplete()
- test_simple_api_docu()
Mirroring the way it is described in projects api view.
- test_tag_autocomplete()
- test_tag_is_added_when_tagging_project()
- test_tag_json_view()
- test_tag_view()
- class heliport.core.tests.HeliportVersionTest(methodName='runTest')
Bases:
TestCaseTest version handling and reporting.
- test_version_header()
Test existence of the version header.
Implemented in
heliport.core.middleware.HeliportVersionMiddleware.
- test_version_string_on_index_page()
Test existence of version string on the index page.
- class heliport.core.tests.IconsParser(*args, **kwargs)
Bases:
HTMLParser- handle_startendtag(tag, attrs)
- class heliport.core.tests.LdJsonContextTest(methodName='runTest')
Bases:
TestCase- test_add_to_end_of_chain()
- test_basic_set()
- test_chained_renaming()
- test_match_context()
- test_rename_keys()
- test_reverse_compatible_with_generation()
- test_unique_keys()
- class heliport.core.tests.ModelsTest(methodName='runTest')
Bases:
WithHeliportUser- test_digital_object()
- test_project()
- test_tag()
- test_user()
- class heliport.core.tests.OpenSearchTest(methodName='runTest')
Bases:
TestCaseTests for HELIPORT’s implementation of the OpenSearch specification.
More information on the spec can be found here: https://en.wikipedia.org/wiki/OpenSearch_(specification)
- test_description_absolute_url_with_placeholder()
Absolute URL must be used and contain placeholder.
- test_description_content_type()
The description must be sent as XML.
- test_description_is_linked()
The search description must be linked on the main page.
- test_description_xml_declaration()
The description must start with XML declaration.
- class heliport.core.tests.PackageMetadataTest(methodName='runTest')
Bases:
TestCaseTests for
heliport.core.utils.version.- test_heliport_homepage()
Make sure a HELIPORT homepage is linked.
- test_project_urls()
Test for
get_project_urls.
- class heliport.core.tests.QueryTest(methodName='runTest')
Bases:
WithHeliportUser- test_create_project()
- test_deletion()
- test_group()
- test_tags()
- class heliport.core.tests.RedocApiDocsTest(methodName='runTest')
Bases:
TestCaseTest Redoc API docs.
- test_no_google_fonts()
Make sure no Google Fonts are used.
- class heliport.core.tests.SearchTest(methodName='runTest')
Bases:
WithHeliportUser- assertEqualNoOrder(list_goal, list_actual)
- test_access_search()
- test_digital_object_autocomplete()
- test_group_findable()
- test_heliport_user_and_project_findable()
- test_landing_page_by_persistent_id()
- test_search_valid_redirect_urls()
- class heliport.core.tests.TemplateRenderingTest(methodName='runTest')
Bases:
TestCase- test_isinstance()
- test_query_params()
- test_repr()
- test_type()
- test_zip()
- class heliport.core.tests.UtilsTest(methodName='runTest')
Bases:
TestCase- test_context()
- test_digital_object_breadcrumb()
- test_exceptions()
- test_first()
- test_format_byte_count()
- test_format_time()
- test_manually_closing_context()
- test_merge_iterables()
- test_parse_date_time()
- test_remove_prefix()
- class heliport.core.tests.WithHeliportUser(methodName='runTest')
Bases:
TestCase- setUp()
Set up logged-in heliport user.
- class heliport.core.tests.WithProject(methodName='runTest')
Bases:
WithHeliportUser- setUp()
Set up project and logged-in heliport user.
- heliport.core.tests.build_action(obj, project, user)
heliport.core.urls module
Map django views to urls.
See this Example including explanation from the Django documentation.
heliport.core.vocabulary module
- class heliport.core.vocabulary.DATACITE
Bases:
DefinedNamespaceDataCite2RDF http://dx.doi.org/10.6084/m9.figshare.2075356.
- AgentIdentifierScheme: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/AgentIdentifierScheme')
- AlternateResourceIdentifier: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/AlternateResourceIdentifier')
- FunderIdentifierScheme: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/FunderIdentifierScheme')
- OrganizationIdentifier: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/OrganizationIdentifier')
- OrganizationIdentifierScheme: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/OrganizationIdentifierScheme')
- PersonalIdentifier: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/PersonalIdentifier')
- PersonalIdentifierScheme: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/PersonalIdentifierScheme')
- PrimaryResourceIdentifier: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/PrimaryResourceIdentifier')
- ResourceIdentifier: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/ResourceIdentifier')
- ResourceIdentifierScheme: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/ResourceIdentifierScheme')
- hasDescriptionType: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/hasDescriptionType')
- hasGeneralResourceType: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/hasGeneralResourceType')
- usesIdentifierScheme: URIRef = rdflib.term.URIRef('http://purl.org/spar/datacite/usesIdentifierScheme')
- class heliport.core.vocabulary.FABIO
Bases:
DefinedNamespace
- class heliport.core.vocabulary.PRO
Bases:
DefinedNamespacePRO, the Publishing Roles Ontology.
- class heliport.core.vocabulary.SemanticDesktop
Bases:
objectNEPOMUK Ontology.
- class NFO
Bases:
DefinedNamespace
- class NIE
Bases:
DefinedNamespace
heliport.core.vocabulary_core module
- heliport.core.vocabulary_core.insert_core_vocabulary()
To be called in post migration signal handler.
- heliport.core.vocabulary_core.set_attribs(role_name_in_db, label, persistent_id=None, append_to=None)
- heliport.core.vocabulary_core.set_property(obj, predicate, value)
heliport.core.vocabulary_descriptor module
- class heliport.core.vocabulary_descriptor.LiteralTriple(subj, pred, literal, recursive=True)
Bases:
TripleDescription- add_to_graph(graph)
- objects()
- class heliport.core.vocabulary_descriptor.PropertyList(subj, pred, key_values, intermediate=None, recursive=True)
Bases:
TripleDescription- add_to_graph(graph)
- objects()
- class heliport.core.vocabulary_descriptor.RelationTriple(subj, pred, obj, recursive=True)
Bases:
TripleDescription- add_to_graph(graph)
- objects()
Module contents
This is the core HELIPORT django app that contains all general functionality.
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()).