heliport.sharelatex package

Subpackages

Submodules

heliport.sharelatex.admin module

Registers Django admin pages.

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

heliport.sharelatex.apps module

Django app configuration.

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

See also Django documentation

class heliport.sharelatex.apps.SharelatexConfig(app_name, app_module)

Bases: AppConfig

App configuration for sharelatex app.

name = 'heliport.sharelatex'

heliport.sharelatex.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.sharelatex.interface.ShareLaTeXModule

Bases: DigitalObjectModule

get_url(project)

Return the URL for the entry point of this module.

module_id = 'sharelatex'
name = 'Share LaTeX'
property object_class

ShareLaTeX.

heliport.sharelatex.interface.get_search_url()

Return the search URL for this app.

This URL is used to implement the global HELIPORT string search.

heliport.sharelatex.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.sharelatex.models.ShareLaTeX(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, latex_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
latex_id

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

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.

heliport.sharelatex.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.sharelatex.serializers.LatexSerializer(*args, **kwargs)

Bases: ModelSerializer

class Meta

Bases: object

fields = ['latex_id', 'label', 'projects', 'url', 'namespace_str']
model

alias of ShareLaTeX

create(validated_data)
class heliport.sharelatex.serializers.TexDATACITESerializer

Bases: DigitalObjectDATACITESerializer

resource_type(tex)

heliport.sharelatex.tests module

Test the behaviour of this app.

This follows the Writing tests guide in Django.

class heliport.sharelatex.tests.LatexTest(methodName='runTest')

Bases: TestCase

static landing_page_url(obj)
setUp()

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

test_api()
test_create()
test_datacite()
test_json_ld()
test_lat_findable()
test_list()

heliport.sharelatex.urls module

Map django views to urls.

See this Example including explanation from the Django documentation.

heliport.sharelatex.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.sharelatex.views.LaTeXView

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://collabtex.helmholtz.cloud', 'text': 'ColLabTeX'}]

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/share_latex'

Namespace used for handle generation

columns = [('ID', 'latex_id', 'small'), ('Name', 'label', '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 ShareLaTex Project'

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

edit_fields = [('Link', 'link', 'normal'), ('Name', 'label', 'normal')]

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 = 'ShareLaTeX'

Text displayed as heading

list_url = 'sharelatex:list'

Url that leads to this view for listing objects. The list_url attribute should be a string that is valid when passed to Django’s reverse() function with kwarg “project”. list_url is required by the default action_edit() implementation to link back to original page after editing.

model

alias of ShareLaTeX

update_url = 'sharelatex:update'

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

class heliport.sharelatex.views.LatexViewSet(**kwargs)

Bases: HeliportModelViewSet

ShareLaTeX.

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

alias of LatexSerializer

class heliport.sharelatex.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 = 'sharelatex/search.html'

Module contents

App to store metadata about latex used in 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()).