heliport.publication package

Subpackages

Submodules

heliport.publication.admin module

Registers Django admin pages.

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

heliport.publication.apps module

Django app configuration.

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

See also Django documentation

class heliport.publication.apps.PublicationConfig(app_name, app_module)

Bases: AppConfig

App configuration for publication app.

name = 'heliport.publication'

heliport.publication.interface module

Module with special name “interface” hooks into HELIPORT.

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

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

class heliport.publication.interface.PublicationModule

Bases: Module

get_url(project)
is_configured(project)
module_id = 'publication'
name = 'Publication'
heliport.publication.interface.get_search_url()
heliport.publication.interface.serialize_project(project)

heliport.publication.models module

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

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

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

Bases: DigitalObject

exception DoesNotExist

Bases: DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

digitalobject_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

digitalobject_ptr_id

Defines a python descriptor for metadata properties.

This descriptor should be used on DigitalObject subclasses.

In principle most properties of subclasses of DigitalObject can be considered “Metadata Properties” however using MetadataFiled has 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 Vocabulary and 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 DigitalObjectAttributes and 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 the role_name_in_db parameter uniquely for each. Also if you change the metadata attribute or the role_name_in_db you need to write a database migration.

publication_id

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

heliport.publication.serializers module

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

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

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

class heliport.publication.serializers.PublicationDATACITESerializer

Bases: DigitalObjectDATACITESerializer

resource_type(pub)
class heliport.publication.serializers.PublicationSerializer(*args, **kwargs)

Bases: ModelSerializer

class Meta

Bases: object

fields = ['publication_id', 'description', 'projects', 'persistent_id', 'url']
model

alias of Publication

create(validated_data)

heliport.publication.tests module

Test the behaviour of this app.

This follows the Writing tests guide in Django.

class heliport.publication.tests.ProjectSerializeTest(methodName='runTest')

Bases: TestCase

static landing_page_url(obj)
setUp()
test_datacite()
test_json_ld()
test_rest_api()
class heliport.publication.tests.PublicationTests(methodName='runTest')

Bases: TestCase

setUp()

Set up project and logged-in heliport user.

test_create()
test_list()
test_url()
class heliport.publication.tests.SearchAndAPITest(methodName='runTest')

Bases: TestCase

Test search including via API.

setUp()

Set up project and logged-in heliport user.

Test that search URL is accessible.

test_api()

Test api.

test_publication_findable()

Test that publication is findable.

heliport.publication.urls module

Map django views to urls.

See this Example including explanation from the Django documentation.

heliport.publication.views module

Contains Django View classes to handle HTTP requests.

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

class heliport.publication.views.PublicationView

Bases: HeliportObjectListView

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

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

add_text = ['or create one first with', {'link': 'https://rodare.hzdr.de/deposit/new', 'text': 'RODARE'}, 'or', {'link': 'https://www.hzdr.de/db/!Publications', 'text': 'ROBIS'}, 'or', {'link': 'https://www.hzdr.de/db/!WebAppl.Publ_Input_V5.Data', 'text': 'ROBIS directly'}]

List of strings that are concatenated and put next to the add button for creating a new object. # noqa: E501 See utils.form_description.FormDescription.get_add_text() for more information. # noqa: E501

after_save_attributes = {'link'}

List of attribute names (second value in triples of edit_fields) that should # noqa: E501 be set after obj.save() is called when creating an obj.

category = 'HELIPORT/publication'

Namespace used for handle generation

columns = [('ID', 'publication_id', 'small'), ('DOI/Handle/...', 'persistent_id', 'normal'), ('Description', 'description', 'large')]

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

create_heading = 'Add a Publication'

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

edit_fields = [('DOI/Handle/...', 'persistent_id', 'normal'), ('Link', 'link', 'normal'), ('Description', 'description', 'large')]

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

list_heading = 'Publications'

Text displayed as heading

list_url = 'publication:list'

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

model

alias of Publication

register_handle = False

True if handles should be registered for new objects

update_url = 'publication:update'

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

class heliport.publication.views.PublicationViewSet(**kwargs)

Bases: HeliportModelViewSet

Publication.

filter_backends = [<class 'rest_framework.filters.SearchFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]
filterset_fields = ['publication_id', 'persistent_id']
get_queryset()
search_fields = ['attributes__value']
serializer_class

alias of PublicationSerializer

class heliport.publication.views.SearchView(**kwargs)

Bases: HeliportLoginRequiredMixin, TemplateView

get_context_data(**kwargs)

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

The extra context includes the search results.

template_name = 'publication/search.html'

Module contents

App to store metadata about publications.

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