heliport.documentation package
Subpackages
Submodules
heliport.documentation.admin module
Registers Django admin pages.
See django.contrib.admin.ModelAdmin
from Django documentation.
heliport.documentation.apps module
Django app configuration.
Some HELIPORT hooks can be registered in app config django.apps.AppConfig.ready()
.
See also Django documentation
heliport.documentation.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.documentation.interface.DocumentationModule
Bases:
DigitalObjectModule
- get_url(project)
Return the URL for the entry point of this module.
- module_id = 'documentation'
- name = 'Documentation'
- property object_class
Documentation.
- heliport.documentation.interface.get_search_url()
Return the search URL for this app.
This URL is used to implement the global HELIPORT string search.
heliport.documentation.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.documentation.models.Documentation(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, documentation_id, system)
Bases:
DigitalObject
- DOCU_HEDGEDOC = 4
- DOCU_LIMS = 3
- DOCU_MEDIA_WIKI = 2
- DOCU_OPEN_BIS = 1
- DOCU_OTHER = 5
- DOCU_SYSTEMS = [(1, 'OpenBis'), (2, 'MediaWiki'), (3, 'Lims'), (4, 'HedgeDoc'), (5, 'Other')]
- 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 aForwardOneToOneDescriptor
instance.
- digitalobject_ptr_id
- documentation_id
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_system_display(*, field=<django.db.models.fields.IntegerField: system>)
- link
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 usingMetadataFiled
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 therole_name_in_db
parameter uniquely for each. Also if you change the metadata attribute or therole_name_in_db
you need to write a database migration.
- system
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
heliport.documentation.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.documentation.serializers.DocumentationDATACITESerializer
Bases:
DigitalObjectDATACITESerializer
- resource_type(doc)
heliport.documentation.tests module
Test the behaviour of this app.
This follows the Writing tests guide in Django.
- class heliport.documentation.tests.DocumentationTests(methodName='runTest')
Bases:
TestCase
- setUp()
Set up project and logged-in heliport user.
- test_add_protocol_create()
- test_add_protocol_update()
- test_create()
- test_delete()
- test_list()
- test_update()
heliport.documentation.urls module
Map django views to urls.
See this Example including explanation from the Django documentation.
heliport.documentation.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.documentation.views.DocumentationUpdateView(**kwargs)
Bases:
HeliportObjectMixin
,UpdateView
- fields = ['description', 'system']
- form_valid(form)
- get_context_data(**kwargs)
Add extra context for rendering template (Called by django base view).
The extra context includes the documentation pages to show.
- get_success_url()
- model
alias of
Documentation
- template_name = 'documentation/documentation.html'
- class heliport.documentation.views.DocumentationView(**kwargs)
Bases:
HeliportProjectMixin
,CreateView
- fields = ['description', 'system']
- form_valid(form)
- get_context_data(**kwargs)
Add extra context for rendering template (Called by django base view).
The extra context includes the documentations to show.
- get_success_url()
- model
alias of
Documentation
- post(request, *args, **kwargs)
- template_name = 'documentation/documentation.html'
- class heliport.documentation.views.DocumentationViewSet(**kwargs)
Bases:
HeliportModelViewSet
Documentation.
- filter_backends = [<class 'rest_framework.filters.SearchFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]
- filterset_fields = ['documentation_id', 'system']
- get_queryset()
- search_fields = ['attributes__value']
- serializer_class
alias of
DocumentationSerializer
- class heliport.documentation.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 = 'documentation/search.html'
Module contents
App to store metadata about documentation related to a HELIPORT project.
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()
).