heliport.core.views package
Submodules
heliport.core.views.api module
- class heliport.core.views.api.ContributionViewSet(**kwargs)
Bases:
ModelViewSet
Showing contributions to projects of the current user.
- get_queryset()
Return contributions to projects of the user that are not deleted.
- permission_class = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'heliport.core.permissions.StaffOrReadOnly'>]
- serializer_class
alias of
ContributionSerializer
- class heliport.core.views.api.DeleteAllTokensView(**kwargs)
Bases:
APIView
Custom
LogoutAllView
using the default authentication classes.- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]
- post(request, *args, **kwargs)
- class heliport.core.views.api.DigitalObjectAPI(*args, **kwargs)
Bases:
HeliportModelViewSet
API for all digital objects in HELIPORT.
For digital objects that are files it is also possible to download them at /api/digital-objects/complete/<digital_object_id>/download/
For digital objects that are directories it is also possible to get contents at /api/digital-objects/complete/<digital_object_id>/contents/
- contents(request, pk=None)
Get files and directories in directory.
- contents_from_description(request)
Get files and directories in directory.
directory is specified via describing parameters to allow download of subdirectories
- download(request, pk=None)
Get streaming file response to download file contents.
- download_from_description(request)
Get streaming file response to download file contents.
The file to download is specified by request parameters. This enables downloading files not directly stored in heliport e.g. inside a directory.
- finalize_response(request, response, *args, **kwargs)
Add json-ld context to response to make this api more interoperable.
- permission_classes = [<class 'rest_framework.permissions.IsAuthenticatedOrReadOnly'>]
Even without login public attributes are accessible.
- queryset
This api allows access to all DigitalObjects. Permissions (read/write) are respected per attribute. # noqa: E501
- serializer_class
DigitalObjectAPISerializer
contains the code that makes this general api possible. # noqa: E501alias of
DigitalObjectAPISerializer
- class heliport.core.views.api.GroupViewSet(**kwargs)
Bases:
ModelViewSet
Showing user groups.
- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'heliport.core.permissions.StaffOrReadOnly'>]
- queryset
- serializer_class
alias of
GroupSerializer
- class heliport.core.views.api.HeliportModelViewSet(**kwargs)
Bases:
ModelViewSet
Base class for API ViewSets in HELIPORT for DigitalObjects.
- perform_destroy(instance)
Deleting objects by setting deleted to the current time.
- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'heliport.core.permissions.HeliportObjectPermission'>]
Make sure user is authenticated and is allowed to access the DigitalObject
- class heliport.core.views.api.LoginNamedTokenView(**kwargs)
Bases:
LoginView
Customized
LoginView
for named HELIPORT API tokens.- create_token()
- get_post_response_data(request, token, instance)
Put “hash” into response for displaying token.
- get_token_ttl()
Get the token’s TTL.
The TTL is calculated from the “expiry” request parameter which must use the format “YYYY-MM-DD”. An empty string means the token does not expire.
- class heliport.core.views.api.LogoutTokenView(**kwargs)
Bases:
APIView
Custom
LogoutView
that can delete tokens other than the currently used one.The
LogoutView
provided bydjango-rest-knox
can only delete the token that is authenticating the current request, or all tokens of a user. This view however allows deletion of any single one of the user’s tokens.- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]
- post(request, *args, **kwargs)
Delete token specified by “pk” parameter.
- class heliport.core.views.api.MaintenanceMessageView(**kwargs)
Bases:
APIView
Returns the maintenance message which can be specified in the settings.
- get(request, *args, **kwargs)
Handle GET request.
- renderer_classes = [<class 'rest_framework.renderers.JSONRenderer'>, <class 'rest_framework.renderers.BrowsableAPIRenderer'>, <class 'heliport.core.renderers.HeliportPartialRenderer'>]
- template_name = 'core/partials/maintenance_message.html'
- class heliport.core.views.api.ProjectViewSet(**kwargs)
Bases:
HeliportModelViewSet
Showing the most general HELIPORT project properties. Request more detailed information by appending urls/ to the url Go to a specific project by appending its id/ to the url For more information on how to authenticate look in HELIPORT (user > settings).
- filter_backends = [<class 'rest_framework.filters.SearchFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]
- filterset_fields = ['group', 'owner', 'persistent_id']
- get_queryset()
Get projects of current user that are not deleted.
- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'heliport.core.permissions.HeliportProjectPermission'>]
Make sure user is authenticated and is allowed to access the DigitalObject
- search_fields = ['label', 'description', 'owner__display_name']
- serializer_class
alias of
ProjectSerializer
- class heliport.core.views.api.TokenViewSet(**kwargs)
Bases:
ModelViewSet
Showing HELIPORT user tokens.
- filter_backends = [<class 'rest_framework.filters.SearchFilter'>, <class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]
- filterset_fields = ['login_info_id']
- get_queryset()
Get tokens (stored in heliport as LoginInfos, not HELIPORT API tokens) of current user.
- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]
- search_fields = ['name']
- serializer_class
alias of
TokenSerializer
- class heliport.core.views.api.UserViewSet(**kwargs)
Bases:
ModelViewSet
Showing HELIPORT user model.
- filterset_fields = ['user_id', 'authentication_backend_id', 'display_name']
- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'heliport.core.permissions.StaffOrReadOnly'>]
- queryset
- serializer_class
alias of
UserSerializer
heliport.core.views.digital_objects module
- class heliport.core.views.digital_objects.AsDigitalObjectView(**kwargs)
Bases:
HeliportProjectMixin
,DetailView
Creates a
heliport.core.models.DigitalObject
instance given aheliport.core.digital_object_resolution.Resolvable
provided as GET or POST parameters and returns it as JSON using"pk"
,"digital_object_id"
,"url"
and"label"
. If an error occurs the JSON contains an"error"
attribute.This uses
heliport.core.digital_object_interface.GeneralDigitalObject.as_digital_object`()
internally.If you set POST parameter is_helper to
True
the resulting digital object is marked as “helper”. This can be used when querying digital objects to not show automatically generated helpers to the user.- pk_url_kwarg = 'project'
- post(request, *args, **kwargs)
Handle post.
- class heliport.core.views.digital_objects.DigitalObjectAutocompleteView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,View
Handles getting information for autocomplete inputs for
heliport.core.models.DigitalObject
.- get(request, *args, **kwargs)
Responde to GET request.
Returns json list like:
[ {"label": "aa", "pk": 1}, {"label": "xa", "pk": 55} ]
Excludes deleted objects and respects user rights. Maximum dumber of results is configurable in settings.py
HELIPORT_CORE_AUTOCOMPLETE_COUNT
Supports the following get parameters:
type
- Restrict autocomplete to a type. Seeheliport.core.utils.queries.digital_objects_by_type()
for allowed values....?type=1&type=2
results in union of results to...?type=1
and...?type=2
.q
orterm
- search term for label and persistent_idexact
- false (default): case-insensitive and allow part match; case_insensitive: case-insensitive full match; true: case-sensitive full match. psersistent_id is always matched exact
heliport.core.views.generic module
- class heliport.core.views.generic.HeliportCreateAndUpdateView(*args, **kwargs)
Bases:
HeliportLoginRequiredMixin
,HeliportBreadcrumbsMixin
,TemplateView
,Generic
[T
]For writing a HELIPORT view that can create and update digital objects.
This combines the functionality of
heliport.core.mixins.HeliportProjectMixin
andheliport.core.mixins.HeliportObjectMixin
allowing to have two URLs handled by the same view instead of having a separate create and update view with potentially lots of duplicated code.By default, the URL patterns could look something like this:
project/<int:project>/my-object/<int:pk>/update/ project/<int:project>/my-object/list
Look at
project_url_kwarg
,pk_url_kwarg
andmodel
for more detail.A typical view could look like this:
class MyView(HeliportCreateAndUpdateView[MyDigitalObjectSubclass]): model = MyDigitalObjectSubclass list_url = "myapp:list" update_url = "myapp:update" template_name = "myapp/my_object_template.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["my_key"] = "my_value" return context def post(self, request, *args, **kwargs): # handle post data self.object.save_with_namespace("my/namespace", self.project) return self.get_response()
This view provides quite a few helpful properties to use:
The following auth checks are always automatically performed:
The view automatically handles when
heliport.core.utils.exceptions.UserMessage
instances are raised in your code.- assert_permission()
Raise error if current user has not the right permissions.
This is automatically called during dispatch of any HTTP methods.
The following permissions are checked:
permission for
project
permission for
object
when notNone
permission for the
objects
is not checked as it is assumed a user always is allowed to access all the objects in a project.
Permission is checked via
heliport.core.permission.PermissionChecker.assert_permission()
on theheliport.core.permission.PermissionChecker
returned byheliport.core.models.DigitalObject.access()
. If a DigitalObject subclass overwrites this method it is essential that the object is casted to the correct subclass before the permission check. This is done by callingheliport.core.models.DigitalObject.casted_or_self()
during every dispatch on the DigitalObject returned byget_object()
if it is notNone
.
- context: Context
A context usable for all kinds of operations in HELIPORT. See also the documentation of
heliport.core.utils.context.Context
. Note that the context manager is already handled for you. This also means if you need the context after the request is handled (e.g. for streaming download) you need to make sure the context is not exited.
- dispatch(request, *args, **kwargs)
Dispatch a HTTP request.
This is called by Django and handles the following things:
set
context
and handle it properly using a context mangerset context on
object
if notNone
catch
heliport.core.utils.exceptions.AccessDenied
- raise HTTP errorhandle
heliport.core.utils.exceptions.UserMessage
- show to usercheck permission using
assert_permission()
convert result of
get_object()
to correct subclass
- get_context_data(**kwargs)
Add some useful values to the template rendering context.
The following are added:
project
:project
object
:object
objects
:objects
heliport_user
:user
is_create
:is_create
is_update
:is_update
update
:is_update
- the old convention
Also, the following are added and are used by the heliport base template:
project_dropdown_modules
(seeheliport.core.app_interaction.generate_project_dropdown()
) andproject_navbar_modules
(seeheliport.core.app_interaction.generate_project_navbar()
)
- get_object() T | None
Get the object if
pk_url_kwarg
is in the URL.Overwrite this for custom behaviour.
Note that it is not required to call
heliport.core.models.DigitalObject.casted_or_self()
. DigitalObject subclasses may have additional security checks, therefore this cast is critical and performed automatically whenobject
is set.
- get_project() Project
Get project based on
project_url_kwarg
.Overwrite this for custom behaviour.
- get_response(error=False)
Get default response returned by
post()
.This is also used when a
heliport.core.utils.exceptions.UserMessage
is raised during get or post to return a response that shows the message on it.The default behaviour is to redirect to the
list_url
. Whenerror
isTrue
a redirect to the next item of the following list is returned to avoid infinite redirect loops:update view
list view
heliport project graph
Note that the kwarg
project_url_kwarg
is automatically supplied when generating the URL fromlist_url
.
- property is_create
Whether this view is in create mode (creating a new object on POST).
This is
True
ifpk_url_kwarg
is not provided in the current URL.Opposite of
is_update
.
- property is_update
Whether this view is in update mode (updating an object on POST).
This is
True
ifpk_url_kwarg
is provided in the current URL.Opposite of
is_update
.
- list_url: str
This is required by the default implementation of
get_response()
to redirect back to the list after successful operation. See alsoHeliportObjectListView.list_url
for a similar concept.
- model
The type of
heliport.core.models.DigitalObject
to use in this View. This is important for what id is used aspk_url_kwarg
. The default isheliport.core.models.DigitalObject
which means the pk argument of the URL is theheliport.core.models.DigitalObject.digital_object_id
. If you set a model class the primary key of your class is used. Note thatobject
is always converted to the most specific class no matter this parameter.alias of
DigitalObject
- object: T | None
The current digital object to update, or
None
if this view is not called withpk_url_kwarg
in the URL.
- objects: QuerySet
All digital objects of the provided model for the current project as Django query set. Deleted objects are not included.
- pk_url_kwarg = 'pk'
The name of the url parameter where the digital object is taken from. See also
model
andget_object()
.
- project: Project
The current HELIPORT Project. This is taken from
get_project()
.
- project_url_kwarg = 'project'
The name of the url parameter where the project pk is taken from. See also
get_project()
.
- update_url: str
This is required by the default implementation of
get_response()
to redirect back to the list after unsuccessful operation. See alsoHeliportObjectListView.update_url
for a similar concept.
- user: HeliportUser
The current user taken from the request.
- class heliport.core.views.generic.HeliportFormView(*args, **kwargs)
Bases:
HeliportCreateAndUpdateView
[T
],ModelFormMixin
,ProcessFormView
,Generic
[T
]A thin wrapper around
HeliportCreateAndUpdateView
.The purpose is to also support forms by using Django
ModelFormMixin
.A typical view could look like this:
class MyView(HeliportCreateAndUpdateView[MyDigitalObjectSubclass]): model = MyDigitalObjectSubclass form_class = MyDigitalObjectSubclassForm list_url = "myapp:list" update_url = "myapp:update" template_name = "myapp/my_object_template.html"
You can use all the functionality of normal model form views in Django. For example
fields = ["field1", "field2"]
instead ofform_class
works.- get_success_url()
Go to list url after successful form saving.
- class heliport.core.views.generic.HeliportObjectListView
Bases:
HeliportLoginRequiredMixin
,UserPassesTestMixin
,HeliportBreadcrumbsMixin
,TemplateView
Base view to get a simple list view of some type of Digital Objects.
No template is needed, just some simple configuration. There is still some flexibility and hence alot of configuration options. To get something quickly, coppy and paste an existing example and modify it for your needs.
This view requires to set the
list_url
to a registered url that points to this view.It is usually required to set the
model
property to the subclass ofheliport.core.models.DigitalObject
that should be listed and to create two urls that point to this view which can be passed aslist_url
andupdate_url
.- action_delete(obj: DigitalObject)
Implements the delete action so that the string “action_delete” can be used in
actions
. The default implementation setsdeleted
to the current time and saves the object.
- action_edit(obj)
Implements the edit action so that the string “action_edit” can be used in
actions
. The edit action is a link action that links toupdate_url
, which points normally to this view itself.
- actions = [('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 ofregister_actions()
for definitions of style information. # noqa: E501
- add_text = []
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 = ()
List of attribute names (second value in triples of
edit_fields
) that should # noqa: E501 be set afterobj.save()
is called when creating anobj
.
- category = 'HELIPORT/thing'
Namespace used for handle generation
- columns = [('ID', 'pk', 'small'), ('Name', 'label', 'normal')]
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 ofregister_columns()
for definition of column sizes
- create_heading = None
Text displayed as heading over form when creating obj. See also
get_create_heading()
. # noqa: E501
- dynamic_actions(obj)
- edit_fields = [('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 ofregister_form_columns()
for definitions of field styles. # noqa: E501
- edit_tags = True
True if tags should be editable in this view
- extract_action()
Helper function to extract the action to be dispatched from POST data.
- extract_form_fields()
Helper function to extract form fields out of the posted data. Data from autocomplete inputs with data separated into a label input and an hidden id input is supported.
- get(request, *args, **kwargs)
Called by django on http get. Sets
project
for which the list should be shown.
- get_context_data(**kwargs)
Called by django to get context when rendering template. Collects information like
list_heading
and generates table (get_table()
) and form (get_form()
) into context.
- get_create_heading()
Return
create_heading
. Generate a creation heading if this is not specified. Generation is done for example based onupdate_heading
by replacing a prefix of “Update” or “Edit” with “Add”.
- get_form() FormDescription
Helper function for form generation. This calls
register_form_columns()
to populate the form description.
- get_object()
Return the project for which a list of objects should be shown.
- get_table() TableDescription
Helper function for table generation. This calls
register_columns()
andregister_actions()
to populate the table description.
- get_update_heading()
Return
update_heading
. Generate an update heading if this is not specified. Generation is done for example based oncreate_heading
by replacing a prefix “Add” or “Create” with “Update”.
- handle_action(action_name: str, target_pk: str)
Dispatches an action on a table row.
- handle_error(message)
Called by
post()
if aUserMessage
is raised. It renders the list including the error message.
- info_snippet_add = None
An HTML template containing a snippet to be used to provide additional information to the “Add” section.
- list_heading = 'HELIPORT Object List'
Text displayed as heading
- list_url = None
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 defaultaction_edit()
implementation to link back to original page after editing.
- model
Instances of this model are shown in the list and created/edited
alias of
DigitalObject
- post(request, *args, **kwargs)
Set
project
and call the correct one ofhandle_update()
,handle_create()
orhandle_action()
.Called by django on http post.
- register_actions(table: TableDescription)
Register the actions on a
table
by calling utils.table_description.TableDescription.add_action. The default implementation usesactions
to get information about what actions to add. Feel free to implementregister_actions
in a subclass.
- register_columns(table: TableDescription)
Register the columns on a
table
by calling utils.table_description.TableDescription.add_column. The default implementation usescolumns
to get information about what columns to add. Feel free to implementregister_columns
in a subclass.
- register_form_columns(form: FormDescription)
Register the columns on a
form
by calling utils.form_description.FormDescription.add_column. The default implementation usesedit_fields
to get information about what columns to add. Feel free to implementregister_form_columns
in a subclass.
- set_update_attributes(obj, form_fields, obj_saved=False)
Is called by
handle_create()
andhandle_update()
after theobj
is saved. The default implementation sets all attributes inafter_save_attributes
.
- template_name = 'core/base/simple_table_view.html'
HTML templated rendered by this View
- test_func()
Called by Djangos
UserPassesTestMixin
. Make sure that user is a project member.
- update_heading = None
Text displayed as heading over form when editing obj. See also
get_update_heading()
. # noqa: E501
- update_url = None
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 defaultaction_edit()
implementation.
heliport.core.views.images module
- class heliport.core.views.images.ImageView(**kwargs)
Bases:
HeliportObjectMixin
,DetailView
View for showing
heliport.core.models.Image
s to use them in html.- get(request, *args, **kwargs)
Image pk is taken from url. This view may be cached (configured in
heliport.core.urls
). Called by django on http get.
- class heliport.core.views.images.ImagesView(**kwargs)
Bases:
HeliportProjectMixin
,TemplateView
List all
heliport.core.models.Image
s in a project.- get_context_data(**kwargs)
Called by django to get context when rendering template. Includes “images”, the list of relevant images, in context.
- post(request, *args, **kwargs)
Handles image deletion. Called by django on http post.
- template_name = 'core/digital_object/picture_list.html'
HTML template rendered by this View
- class heliport.core.views.images.TakePictureView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,TemplateView
Handles taking pictures in HELIPORT these pictures are stored as
heliport.core.models.Image
.- get_context_data(**kwargs)
Generate default values for storing image and include them in context. Support
next
get parameter to redirect to arbitrary page after image has been taken.
- post(request, *args, **kwargs)
Create new
heliport.core.models.Image
with user supplied metadata and upload image itself to file system specified by login info (selected by user).Return redirect to image list or view specified by “next” parameter. If “next” parameter ends with “=” append pk of newly taken image. For example
https://some/url?image=
becomeshttps://some/url?imgae=13
if13
is the newly taken image.Called by django on http post.
- template_name = 'core/digital_object/take_picture.html'
HTML template rendered by this View
heliport.core.views.landing_page module
- class heliport.core.views.landing_page.IndexView(**kwargs: Any)
Bases:
TemplateView
View for the HELIPORT front page.
The page shows some basic information about HELIPORT similarly to the about page, as well as some stats on digital objects on the instance.
The page is cached to prevent bots and scrapers from straining the database. However, since the cache is based on the client’s cookies, this mechanism is only effective for clients that do not malicously send random cookies.
- create_sparkline(data: DataFrame) str
Create a sparkline for the given data and return it as an image data URL.
- dispatch(request, *args, **kwargs)
- get_context_data(**kwargs: Any) dict[str, Any]
Add digital object stats to the rendering context.
- get_digital_object_sparkline(objects: Iterable[DigitalObject]) str
Return a sparkline showing the number of existing digital objects.
The number is calculated by a cumulative summation of +1 or -1 at the respective creation and deletion dates of the given digital objects
- get_user_sparkline(users: Iterable[HeliportUser]) str
Return a sparkline showing the number of existing users.
The number is calculated by a cumulative summation of +1 at the respective
date_joined
of each given user’s auth user.
- template_name = 'core/base/index.html'
- time_series_to_dataframe(time_series: dict) DataFrame
Massage “time series” into dataframe.
“Time series” in this case is a dictionary mapping from timestamps to +1 / -1.
- class heliport.core.views.landing_page.LandingPageView(**kwargs)
Bases:
DetailView
Landing page for Digital Objects.
Landing pages are rendered in different formats using custom content negotiation.
- get(request, *args, **kwargs)
Renderer selection based on Accept header and handling of special renderers like showing individual page with
get_custom_url()
.Called by django on http get.
- get_context_data(**kwargs)
Get relevant infos in addition to the Digital Object itself. Called by django to get context when rendering html template.
- static get_custom_url(obj, request)
Get the url of a special page in heliport for showing
obj
. This information is defined onobj
via aget_custom_url()
function. For example a project is shown as the heliport project graph. (seeheliport.core.models.Project.get_custom_view_url()
).
- model
Django model handled in this view - used by django
DetailView
alias of
DigitalObject
- post(request, *args, **kwargs)
Handle editing what attributes are publicly shown. Called by django on http post.
- template_name = 'core/digital_object/landingpage.html'
HTML template rendered by this View
- class heliport.core.views.landing_page.ResolveDigitalObjectView(**kwargs)
Bases:
RedirectView
Redirect to Digital Object landing page.
Try to resolve a given identifier to a digital object, then redirect to its landing page. If the digital object is not found, return 404.
- get_redirect_url(*args, **kwargs)
Resolve the identifier and return the landing page URL.
- query_string = True
heliport.core.views.project module
- class heliport.core.views.project.CreateProjectView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,TemplateView
Create new HELIPORT project.
Including options for specifying initial project settings and importing contents of other projects.
- get_context_data(**kwargs)
Called by django to get context when rendering template.
Context includes group information and list of projects of current user.
- post(request, *args, **kwargs)
Create project and configure settings.
If template project is selected to import digital objects from, redirect to
ImportFromProjectView
.Called by django on http post.
- template_name = 'core/project/create_project.html'
HTML template rendered by this View (page for entering initial project settings)
- class heliport.core.views.project.CreateSampleProjectView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,View
Create sample HELIPORT project.
- post(request)
Create sample project in HELIPORT database.
- class heliport.core.views.project.ImportFromProjectView(**kwargs)
Bases:
HeliportProjectMixin
,TemplateView
Handle importing or copying digital objects from another project.
- get_context_data(**kwargs)
Called by django to get context when rendering template.
Include list of object that can be imported in context, including their label, types and id. Also for each object, the “default_type” (completely different meaning than “types”; one of ignore, copy, import) and “copy_disabled” (bool; not every object is copyable) is included.
- post(request, *args, **kwargs)
Do the importing / copying. “import_objects” is the list of all objects. E.g. for obj with pk 7 a value import-type-7 (import, copy, ignore) specifies the kind of import.
- template_name = 'core/project/import_from.html'
HTML template rendered by this View
- test_func()
Called by django to test if user has access to this view. In addition to normal test if user has access to current project also test if user has read access to project where things should be imported from.
- class heliport.core.views.project.OpenInProjectView(**kwargs)
Bases:
RedirectView
This view has special handling in the
heliport.core.utils.context.project_header_breadcrumbs()
function to allow resetting the breadcrumbs to the project name.- get_redirect_url(*args, **kwargs)
Reset breadcrumbs and redirect to
next
specified by query parameter.
- class heliport.core.views.project.ProjectGraphView(**kwargs)
Bases:
HeliportProjectMixin
,DetailView
Handle showing the HELIPORT project graph.
- get_breadcrumb_label_and_reset()
- get_context_data(**kwargs)
Generate heliport project graph.
- pk_url_kwarg = 'project'
Expect url parameter “project” instead of “pk”
- template_name = 'core/project/project_graph.html'
HTML template rendered by this View
- class heliport.core.views.project.ProjectListView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,ListView
Handle listing a users HELIPORT project.
- get_context_data(**kwargs)
Called by django to get context when rendering template.
- get_queryset()
Called by ListView to get the list to show. Query: projects of user that are not deleted; handle sorting; no subprojects.
- paginate_by = 10
Pagination
- template_name = 'core/project/project_list.html'
HTML template rendered by this View
- class heliport.core.views.project.ProjectTimelineView(**kwargs)
Bases:
HeliportProjectMixin
,TemplateView
Show a timeline of all digital objects in a project, including the project.
- get_context_data(**kwargs)
Called by django to get context when rendering template. Query all not deleted digital objects in project ordered by creation date.
- template_name = 'core/project/timeline.html'
HTML template rendered by this View
- class heliport.core.views.project.ProjectUpdateView(**kwargs)
Bases:
HeliportProjectMixin
,UpdateView
Update project title, description and group.
This renders the same template as
ProjectView
.- fields = ['label', 'description', 'group']
Used by django
UpdateView
to generate input form for editing project
- get_context_data(**kwargs)
See
ProjectView.get_context_data()
for more information.
- get_success_url()
Return to
ProjectView
after updating and saving project.
- pk_url_kwarg = 'project'
In
heliport.core.urls
project id is called “project” not “pk”
- template_name = 'core/project/project_update.html'
HTML template rendered by this View
- class heliport.core.views.project.ProjectView(**kwargs)
Bases:
HeliportProjectMixin
,DetailView
Show general information about a HELIPORT project (“Project Configuration”).
This includes key value pairs like the Title, description or identifiers of a project and information about project participants.
Basic project actions, like deleting the project, can be done via this view too.
- get_context_data(**kwargs)
Called by django to get context when rendering template.
The context includes:
“isOwner”, “update” to configure the template for what should be shown
preprocessed information about project participants
“groups” the list of all groups to display a select box
- pk_url_kwarg = 'project'
In
heliport.core.urls
project id is called “project” not “pk”
- post(request, *args, **kwargs)
Respond to POST request.
Handles one of:
Delete project
Add file system user group to project
Add / Remove co-owner
Add all members of a group as co-owners
Add / Delete Contribution
Edit contribution type (request is send to this view but ui is rendered in
ProjectUpdateView
)
- template_name = 'core/project/project_update.html'
HTML template rendered by this View
- class heliport.core.views.project.SubprojectsView(**kwargs)
Bases:
HeliportProjectMixin
,DetailView
Handle other HELIPORT projects that are part of the current project.
- get_context_data(**kwargs)
Called by django to get context when rendering template. Subprojects, all projects of user and user are included in context.
- pk_url_kwarg = 'project'
In
heliport.core.urls
project id is called “project” not “pk”
- post(request, **kwargs)
Add or remove a subproject.
- template_name = 'core/project/subprojects.html'
HTML template rendered by this View
- heliport.core.views.project.get_users_autocomplete(request, **kwargs)
View that handles user autocomplete. The query string is taken from get parameter q. Respects
HELIPORT_CORE_AUTOCOMPLETE_COUNT
in settings.py.Returns json like:
[ {"name": "ax", "pk": 1}, {"name": "xyyy", "pk": 55} ]
heliport.core.views.search module
- class heliport.core.views.search.SearchBaseView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,TemplateView
Base view for the HELIPORT search feature. This view uses javascript to get the actual search results from each apps search view.
- get_context_data(**kwargs)
Called by django to get context when rendering template. Includes urls of all search views.
- template_name = 'core/search/search_base.html'
HTML template rendered by this View
- class heliport.core.views.search.SearchView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,TemplateView
Handle searching objects in the HELIPORT core app.
- get_context_data(**kwargs)
Query all objects matching “q” parameter.
- template_name = 'core/search/search.html'
HTML template rendered by this View
heliport.core.views.user module
- class heliport.core.views.user.LoginInfoUpdateView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,UpdateView
Handle editing/showing login details, of other web services, in HELIPORT so that HELIPORT can make requests on behalf of the user. There exists a very similar view for creation/showing such login details:
LoginInfoView
.- dispatch(request: HttpRequest, *args: Any, **kwargs: Any) HttpResponse
Don’t allow users to edit a connected or someone else’s LoginInfo.
- fields = ['name', 'type', 'username', 'key', 'machine', 'via', 'slurm']
Used by django
UpdateView
to generate input form for editing login infos
- form_valid(form)
Assert that
heliport.core.models.LoginInfo
belongs to current user and set password. SeeLoginInfoView.form_valid()
for more details.
- get_context_data(**kwargs)
Called by django to get context when rendering template.
- get_success_url()
Redirect to
LoginInfoView
after updating login info.
- template_name = 'core/user/login_infos.html'
HTML template rendered by this View
- class heliport.core.views.user.LoginInfoView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,CreateView
Handle creating/showing login details of other web services in HELIPORT so that HELIPORT can make requests on behalf of the user. There exists a very similar view for editing/showing such login details:
LoginInfoUpdateView
.- fields = ['name', 'type', 'username', 'key', 'machine', 'via', 'slurm']
Used by django
CreateView
to generate input form for creating new login infos
- form_valid(form)
Validate form.
Called by django
CreateView
after form has been deemed valid. Set additional attributes before saving LoginInfo:user - current heliport user added automatically (not from input form)
password - password field can not be generated automatically in form because password is a python property and not a django model field
- get_context_data(**kwargs)
Called by django to get context when rendering template.
- get_success_url()
Called by django to get url to redirect to after successful
heliport.core.models.LoginInfo
creation.- Returns:
URL of this view itself.
- post(request, *args, **kwargs)
Handle deletion of login infos here and creation in superclass
CreateView
. Called by django on http post.
- template_name = 'core/user/login_infos.html'
HTML template rendered by this View
- class heliport.core.views.user.RemoteServerLoginView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,DetailView
Show username and password prompt for an SSH login and put public SSH key in allowed hosts on the server specified in the SSH login (
heliport.core.models.LoginInfo
) while private key is stored encrypted in the HELIPORT database. When the key of an SSH LoginInfo is on the remote server we say it is “connected”.The corresponding view for logout is the
RemoteServerLogoutView
.- get_context_data(**kwargs)
Called by django to get context when rendering template. In addition to the LoginInfo (automatically included by
DetailView
) include error message in context.
- post(request, *args, **kwargs)
Connect LoginInfo. Called by django on http post.
As a side effect the username is stored in the
LoginInfo
. This removes the need to enter the username twice (when creating the login info and when connecting the login info). The username is used e.g. for searching login infos.
- template_name = 'core/user/remote_server_login.html'
HTML template rendered by this View
- static validate_login(login, request)
Check if SSH
heliport.core.models.LoginInfo
can be connected. This is the case if the login info belongs to the user and all necessary SSH indirections are connected.
- class heliport.core.views.user.RemoteServerLogoutView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,View
Handle removing SSH key from external server. For more details see
RemoteServerLoginView
. This view does not render a template. The key is deleted without any questions asked and the user is redirected toLoginInfoView
.- get(request, *args, **kwargs)
Disconnect SSH
heliport.core.models.LoginInfo
. Called by django on http get.
- class heliport.core.views.user.TokenListView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,TemplateView
Display the user’s API tokens.
- get_context_data(**kwargs)
Update the rendering context with token data.
- template_name = 'core/user/tokens.html'
HTML template rendered by this View
- class heliport.core.views.user.UserProfileView(**kwargs)
Bases:
HeliportLoginRequiredMixin
,TemplateView
Handle showing and editing settings of a HELIPORT user. (most information is read only).
- get_context_data(**kwargs)
Called by django to get context when rendering template. Context includes the user and information for HELIPORT API token creation form (like the current time).
- post(request, *args, **kwargs)
Set orcid for user. Called by django on http post.
- template_name = 'core/user/profile.html'
HTML template rendered by this View
Module contents
This module contains Django class based views
to handle incoming http requests. Each View
is mapped to a URL in heliport.core.urls
.
Each django app can have its own views. This module contains views for all main heliport functionality.